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
79 lines
3.5 KiB
C++
79 lines
3.5 KiB
C++
#pragma once
|
||
|
||
#include <afxwin.h>
|
||
#include <afxcmn.h>
|
||
#include <vector>
|
||
|
||
// 「MCP设置」配置对话框:启用 MCP / 端口 / 绑定地址 / Token / HTTPS 与证书。
|
||
// 因 2015Remote.rc 为 UTF-16 编码、不宜手工编辑,参照 ZstaPickerDlg 用
|
||
// InitModalIndirect + 内存 DLGTEMPLATE 程序化创建(见 docs/Mcp_Design.md §3.8)。
|
||
class CMcpSettingsDlg : public CDialog
|
||
{
|
||
public:
|
||
explicit CMcpSettingsDlg(CWnd* parent = nullptr);
|
||
|
||
virtual INT_PTR DoModal();
|
||
|
||
protected:
|
||
virtual BOOL OnInitDialog();
|
||
virtual void OnOK();
|
||
|
||
afx_msg void OnHttpsToggle();
|
||
afx_msg void OnBrowseCert();
|
||
afx_msg void OnBrowseKey();
|
||
|
||
DECLARE_MESSAGE_MAP()
|
||
|
||
private:
|
||
enum CtrlId {
|
||
IDC_MCP_ENABLE = 1001, // 「启用 MCP」复选框
|
||
IDC_MCP_PORT = 1002, // 端口编辑框
|
||
IDC_MCP_BIND = 1003, // 绑定地址编辑框
|
||
IDC_MCP_TOKEN = 1004, // Token 编辑框
|
||
IDC_MCP_READONLY = 1005, // 「只读模式」复选框(默认勾选,禁 exec_command)
|
||
IDC_MCP_WHITELIST = 1006, // 命令白名单编辑框(多行,逗号/换行分隔,空 = 内置只读前缀)
|
||
IDC_MCP_TERMINAL = 1007, // 「启用持久终端」复选框(全命令,无白名单,要求只读关)
|
||
IDC_MCP_REMOTECONTROL = 1008, // 「启用远程控制」复选框(AI 操控桌面,要求只读关)
|
||
IDC_MCP_FILETRANSFER = 1009, // 「启用文件传输」复选框(download_file,不要求只读关)
|
||
IDC_MCP_MANAGE = 1010, // 「启用管理操作」复选框(kill/窗口/服务/电源,要求只读关)
|
||
IDC_MCP_MACHINE = 1011, // 「启用主机管理」复选框(host_* 工具族)
|
||
IDC_MCP_MACHINE_DANGEROUS = 1012, // 「启用危险主机操作」复选框(冻结/停止/重启)
|
||
IDC_MCP_CHAT = 1013, // 「启用远程交谈」复选框(chat_* 工具族,不要求只读关)
|
||
IDC_MCP_KEYLOG = 1014, // 「启用键盘记录」复选框(get_keylog,不要求只读关)
|
||
IDC_MCP_HTTPS = 1015, // 「启用 HTTPS」复选框(MCP 端口同时接受 TLS)
|
||
IDC_MCP_CERT = 1016, // 证书路径编辑框(PEM)
|
||
IDC_MCP_KEY = 1017, // 私钥路径编辑框(PKCS#8)
|
||
IDC_MCP_CERT_BROWSE = 1018, // 证书路径「浏览」按钮
|
||
IDC_MCP_KEY_BROWSE = 1019, // 私钥路径「浏览」按钮
|
||
IDC_MCP_FILEWRITE = 1020, // 「启用文件写入」复选框(删除/改名/建目录,要求只读关)
|
||
IDC_MCP_BUILD = 1021, // 「启用客户端生成」复选框(build_client,要求只读关)
|
||
};
|
||
|
||
CButton m_btnEnable;
|
||
CStatic m_lblPort, m_lblBind, m_lblToken;
|
||
CEdit m_editPort, m_editBind, m_editToken;
|
||
CButton m_btnReadonly;
|
||
CButton m_btnTerminal;
|
||
CButton m_btnRemoteControl;
|
||
CButton m_btnFileTransfer;
|
||
CButton m_btnFileWrite;
|
||
CButton m_btnManage;
|
||
CButton m_btnMachine;
|
||
CButton m_btnMachineDangerous;
|
||
CButton m_btnChat;
|
||
CButton m_btnKeylog;
|
||
CButton m_btnBuild;
|
||
CStatic m_lblWhitelist;
|
||
CEdit m_editWhitelist;
|
||
CButton m_btnHttps;
|
||
CStatic m_lblCert, m_lblKey;
|
||
CEdit m_editCert, m_editKey;
|
||
CButton m_btnCertBrowse, m_btnKeyBrowse;
|
||
CButton m_btnOK, m_btnCancel;
|
||
|
||
std::vector<BYTE> m_Template; // 内存 DLGTEMPLATE 字节
|
||
|
||
void LayoutControls(int cx, int cy);
|
||
void UpdateHttpsState(); // 勾选 HTTPS 才允许编辑证书/私钥
|
||
};
|