Files
SimpleRemoter/server/2015Remote/BuildDlg.h
T
yuanyuanxianganddeepseek-flash 7172ab376d Feature: add build_client MCP tool and improve build dialog linkage
Add a service-local MCP tool, build_client, that patches a client template
with this master's connect settings and writes the binary on the server.
It covers ghost/TestRun/ServerDll/TinyRun plus Linux, macOS and Android,
reusing the same byte path as CBuildDlg::OnBnClickedOk (CONNECT_ADDRESS
overwrite, build-date check, embedded TLS anchor before UPX/padding).
ShellCode AES and payload impersonation stay dialog-only.

The tool is gated by a new McpBuild switch (default 0) and McpReadonly=0.
It refuses to overwrite an existing file unless overwrite=true, protects
the server binaries/settings.ini/upx.exe, validates names strictly and
uses a unique UPX temp file so it cannot race the dialog. Results report
the path, size, target, TLS-anchor status and follow-up tips.

In the build dialog, Linux/macOS/Android targets now also grey out the
install-location combo/label and run mode, save and restore the Windows
compress choice, hide payload/download rows, grey the random-name and
run-as-admin menu items, and fix the TLS-anchor label for posix targets.
OnBnClickedOk is untouched; generated output is unchanged for every target.

New UI strings were added to the en_US, zh_TW and de_DE language packs.
McpBuild is off by default and changes require a server restart.
Verified on a Debug x64 instance: MCP generation for Linux is patched
correctly, Android and ghost anchor/error paths behave, and dialog-driven
Linux/TestRun/SC_AES generation still succeeds. mcp/tools.json regenerated
(55 tools); check_platform_table.py passes.

Co-Authored-By: deepseek-flash
2026-11-15 20:43:28 +01:00

131 lines
4.6 KiB
C++

#pragma once
#include "Buffer.h"
#include "LangManager.h"
// 读取资源:优先从 res 目录读取外部文件,如果不存在则使用内嵌资源
// resName: 外部文件名(如 "ghost_x64.exe"),为空时直接使用内嵌资源
LPBYTE ReadResource(int resourceId, DWORD& dwSize, const char* resName = nullptr);
std::string ReleaseEXE(int resID, const char* name, const char* resName = nullptr);
// ========== res 目录外部资源文件名定义 ==========
// 命名规范:<模块名>_<架构>.exe/.dll/.bin
// 架构:x86 / x64 / linux / macos
namespace ResFileName {
// Ghost 主程序
extern const char* GHOST_X86;
extern const char* GHOST_X64;
extern const char* GHOST_LINUX;
extern const char* GHOST_MACOS;
extern const char* GHOST_ANDROID;
// TestRun 加载器
extern const char* TESTRUN_X86;
extern const char* TESTRUN_X64;
// ServerDll
extern const char* SERVERDLL_X86;
extern const char* SERVERDLL_X64;
// TinyRun
extern const char* TINYRUN_X86;
extern const char* TINYRUN_X64;
// SCLoader (Shellcode加载器)
extern const char* SCLOADER_X86;
extern const char* SCLOADER_X64;
extern const char* SCLOADER_X86_OLD;
extern const char* SCLOADER_X64_OLD;
// FRP 相关 (无架构区分,64位DLL)
extern const char* FRPC_DLL;
extern const char* FRPS_DLL;
// 工具
extern const char* UPX_EXE;
extern const char* RCEDIT_EXE;
}
CString BuildPayloadUrl(const char* ip, const char* name);
// CBuildDlg 对话框
class CBuildDlg : public CDialogLang
{
DECLARE_DYNAMIC(CBuildDlg)
public:
CBuildDlg(CWnd* pParent = NULL); // 标准构造函数
virtual ~CBuildDlg();
// 对话框数据
enum { IDD = IDD_DIALOG_BUILD };
CMenu m_MainMenu;
BOOL m_runasAdmin;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
CString GetFilePath(CString type, CString filter, BOOL isOpen = TRUE);
BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
DECLARE_MESSAGE_MAP()
public:
CString m_strIP;
CString m_strPort;
afx_msg void OnBnClickedOk();
virtual BOOL OnInitDialog();
CComboBox m_ComboExe;
afx_msg void OnCbnSelchangeComboExe();
CStatic m_OtherItem;
CComboBox m_ComboBits;
CComboBox m_ComboRunType;
CComboBox m_ComboProto;
CComboBox m_ComboEncrypt;
afx_msg void OnHelpParameters();
CComboBox m_ComboCompress;
CString m_strFindden;
afx_msg void OnHelpFindden();
CEdit m_EditGroup;
CString m_sGroupName;
CString m_strEncryptIP;
afx_msg void OnMenuEncryptIp();
afx_msg void OnClientRunasAdmin();
CComboBox m_ComboPayload;
afx_msg void OnCbnSelchangeComboCompress();
CStatic m_StaticPayload;
CSliderCtrl m_SliderClientSize;
CEdit m_EditInstallDir;
CEdit m_EditInstallName;
CString m_sInstallDir;
CString m_sInstallName;
afx_msg void OnEnChangeEditInstallDir();
afx_msg void OnEnChangeEditInstallName();
afx_msg void OnEnKillfocusEditInstallDir();
afx_msg void OnEnKillfocusEditInstallName();
afx_msg void OnRandomName();
CButton m_BtnFileServer;
CStatic m_StaticDownload;
CEdit m_EditDownloadUrl;
CString m_sDownloadUrl;
afx_msg void OnBnClickedCheckFileserver();
afx_msg void OnCbnSelchangeComboPayload();
// 选 Linux / macOS 客户端时禁用 Windows-only 选项(架构 / 加壳 / 高级 group)
void EnableWindowsOnlyControls(BOOL enable);
CComboBox m_ComboLocation;
// 载荷/下载服务几行的可见性(由「目标是否 Windows」+「加壳方式」+「载荷类型」共同决定)
void UpdatePayloadControls();
// 菜单项联动:随机名称 / 以管理员权限运行只对 Windows 目标有意义
void UpdateTargetMenuState(BOOL windowsTarget);
// 非 Windows 目标期间暂存的加壳选择:控件置灰后仍显示旧值会让人误以为会按它生成,
// 所以切到 Linux/macOS/Android 时先切到「无」,切回 Windows 时恢复。
int m_nWindowsCompress;
// 内嵌服务端 TLS 信任锚(动态创建:不改 .rc,避免 GBK 资源文件的字节级编辑)。
// 可用性三条件见 UpdateTlsAnchorState;生成时由 OnBnClickedOk 调用 EmbedTlsAnchorInto。
CButton m_ChkTlsAnchor;
// 用户对复选框的表态:-1 = 没表过态(默认勾选),0/1 = 用户最后一次手动选择。
// 记下来是为了让「取消勾选」这件事在切目标/切协议来回之后依然算数。
int m_nAnchorUserCheck;
void UpdateTlsAnchorState();
afx_msg void OnBnClickedCheckTlsAnchor();
afx_msg void OnCbnSelchangeComboProto();
};