Feature: Embed the server TLS certificate in delivered DLLs

Add a "高级 → DLL内嵌TLS证书" toggle (off by default, persisted as
[settings] EmbedTlsInDll). When it is on, ReadKernelDll patches the server's
current TLS anchor into the ServerDll and ShellCode payloads, so clients that
come online through the loaders start their own session over TLS without
waiting for an online push. The plaintext DLL loader in client/main.c is
untouched; only the DLL's fresh connection is protected. The write happens
after SetServer and before CalcMD5FromBytes, and the anchor records the host
part of the master address rather than "ip:port" because the client matches
the anchor against its configured address set. TinyRun has no anchor block and
keeps working as before.

Toggling the switch, and confirming the certificate dialog, rebuild the six
payloads in place, so no server restart is needed after a certificate change.
The payload pointers are replaced as a whole, and the network threads that read
them (SendServerDll and TOKEN_GETVERSION) now take a dedicated critical section
for the full duration of use.

COMMAND_UPDATE no longer clears the tls_disabled marker on the client. Now that
any delivered DLL may carry the anchor, "the payload has an anchor" no longer
means the operator opted this host into TLS, and clearing the marker would
silently flip a host that was explicitly set to plaintext onto TLS against a
plaintext path. Re-enabling TLS stays an explicit action through
COMMAND_TLS_ENABLE and COMMAND_SET_PROTO, which still clear the marker.

Menu and notice strings were added to en_US, zh_TW and de_DE, and the embedded
TLS design document records the new switch and the revised update semantics.

The new menu entry also takes a feature-limits slot so a subordinate master
can hide it like every other 高级 item (see 8807321):
HIDE_MENU_EMBED_TLS_ANCHOR in UIBranding.h, MF_EMBED_TLS_ANCHOR at bit 57
in FeatureFlags.h (the first free one after MF_FILE_SPEED), a row in the
主菜单 tab of CFeatureLimitsDlg, and the matching DeleteMenu on the 高级
menu. The entry still has no bitmap of its own, so it renders without an
icon next to its three siblings.

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-11-02 18:30:37 +01:00
1 parent 8b92f32c47
commit c66f410831
12 files changed
+210 -45

No files matched your search

+9
View File
@@ -2120,6 +2120,15 @@ JPEG
%s · 不受限速(受网络带宽约束)=%s · Unbegrenzt (durch Netzwerkbandbreite begrenzt)
文件传输速度已保存。上传速度重启主控端后生效;下载速度已推送到在线客户端,新连接的主机也会自动获取。=Uebertragungsgeschwindigkeit gespeichert. Upload-Geschwindigkeit wird nach Neustart des Masters wirksam; Download-Geschwindigkeit wurde an Online-Clients gesendet, neu verbundene Hosts erhalten sie automatisch.
; ============================================
; Advanced -> DLL embeds TLS certificate (DLL内嵌TLS证书)
; ============================================
DLL内嵌TLS证书=DLL bettet TLS-Zertifikat ein
服务端还没有可用的 TLS 证书,无法内嵌。\r\n请先在 TLS 证书配置里启用证书,再打开此开关。=Der Server hat noch kein nutzbares TLS-Zertifikat, Einbetten ist nicht moeglich.\r\nBitte zuerst in den TLS-Zertifikatseinstellungen ein Zertifikat aktivieren und dann diesen Schalter einschalten.
已开启:此后经 MDLL/ShellCode 形式上线的客户端会自动启用 TLS。\r\n\r\n已上线的客户端不会自动变,需要重启(重新走一遍加载器)才会拿到带证书的 DLL。=Eingeschaltet: Clients, die kuenftig per MDLL/ShellCode online gehen, verwenden automatisch TLS.\r\n\r\nBereits online befindliche Clients bleiben unveraendert; sie muessen neu starten (den Loader erneut durchlaufen), um die DLL mit Zertifikat zu erhalten.
已关闭:此后下发的 DLL 不再内嵌证书。\r\n\r\n已经内嵌了证书的客户端不受影响。=Ausgeschaltet: Ab jetzt ausgelieferte DLLs enthalten kein Zertifikat mehr.\r\n\r\nClients mit bereits eingebettetem Zertifikat sind nicht betroffen.
重新生成内核载荷失败(资源缺失),仍沿用原来的 DLL。=Neuerstellung der Kern-Payloads fehlgeschlagen (Ressource fehlt); die bisherige DLL bleibt in Verwendung.
; ===== TLS =====
TLS证书(&T)...=TLS-Zertifikat(&T)...
TLS证书=TLS-Zertifikat
+9
View File
@@ -2135,6 +2135,15 @@ JPEG
强制断开=Force Disconnect
远程交谈=Talk
; ============================================
; Advanced -> DLL embeds TLS certificate (DLL内嵌TLS证书)
; ============================================
DLL内嵌TLS证书=DLL embeds TLS certificate
服务端还没有可用的 TLS 证书,无法内嵌。\r\n请先在 TLS 证书配置里启用证书,再打开此开关。=The server has no usable TLS certificate yet, so it cannot be embedded.\r\nEnable a certificate in the TLS certificate settings first, then turn this switch on.
已开启:此后经 MDLL/ShellCode 形式上线的客户端会自动启用 TLS。\r\n\r\n已上线的客户端不会自动变,需要重启(重新走一遍加载器)才会拿到带证书的 DLL。=Enabled: clients that come online via MDLL/ShellCode from now on will use TLS automatically.\r\n\r\nClients already online are unchanged; they must restart (run through the loader again) to receive the DLL with the certificate.
已关闭:此后下发的 DLL 不再内嵌证书。\r\n\r\n已经内嵌了证书的客户端不受影响。=Disabled: DLLs delivered from now on no longer carry a certificate.\r\n\r\nClients that already have an embedded certificate are not affected.
重新生成内核载荷失败(资源缺失),仍沿用原来的 DLL。=Failed to regenerate kernel payloads (missing resource); the previous DLL is still in use.
; ===== TLS =====
TLS证书(&T)...=TLS Certificate(&T)...
TLS证书=TLS Certificate
+9
View File
@@ -2128,6 +2128,15 @@ JPEG
强制断开=強制中斷
远程交谈=遠程交談
; ============================================
; Advanced -> DLL embeds TLS certificate (DLL內嵌TLS憑證)
; ============================================
DLL内嵌TLS证书=DLL 內嵌 TLS 憑證
服务端还没有可用的 TLS 证书,无法内嵌。\r\n请先在 TLS 证书配置里启用证书,再打开此开关。=伺服器尚無可用的 TLS 憑證,無法內嵌。\r\n請先在 TLS 憑證設定中啟用憑證,再開啟此開關。
已开启:此后经 MDLL/ShellCode 形式上线的客户端会自动启用 TLS。\r\n\r\n已上线的客户端不会自动变,需要重启(重新走一遍加载器)才会拿到带证书的 DLL。=已開啟:此後經 MDLL/ShellCode 形式上線的用戶端會自動啟用 TLS。\r\n\r\n已上線的用戶端不會自動改變,需要重新啟動(重新執行一次載入器)才會取得內嵌憑證的 DLL。
已关闭:此后下发的 DLL 不再内嵌证书。\r\n\r\n已经内嵌了证书的客户端不受影响。=已關閉:此後下發的 DLL 不再內嵌憑證。\r\n\r\n已內嵌憑證的用戶端不受影響。
重新生成内核载荷失败(资源缺失),仍沿用原来的 DLL。=重新產生核心負載失敗(資源缺失),仍沿用原本的 DLL。
; ===== TLS =====
TLS证书(&T)...=TLS 憑證(&T)...
TLS证书=TLS 憑證