fix(native): handle local HTTPS and allow shared log reads
Use the loopback service certificate for the offline HTTPS path. Retain original host names for host-based routing and allow the network log to be read while the client is running.
This commit is contained in:
1 parent
b6b6effef3
commit
ddb381d7f9
5 files changed
+65
-18
No files matched your search
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"method": "signature",
|
||||
"section": ".text",
|
||||
|
||||
"how": [
|
||||
"libcurl 的 Curl_clone_primary_ssl_config(从入口到读取 cert_blob 判空跳转,共 176 字节)。跳转位移已通配(authoring.py 生成)。",
|
||||
"在 2.61.0.37 原版 aces.exe 上唯一命中 0x56463c0;要改的指令在 +0x52(0x5646412)。"
|
||||
],
|
||||
|
||||
"pattern": "56 57 53 48 83 ec 20 48 89 d6 48 89 cf 8b 82 98 00 00 00 83 c8 20 89 82 98 00 00 00 0f b6 89 95 00 00 00 88 8a 95 00 00 00 8b 8f 90 00 00 00 89 8a 90 00 00 00 8b 8f 98 00 00 00 83 e1 01 83 e0 fe 09 c8 89 82 98 00 00 00 8b 8f 98 00 00 00 83 e1 02 83 e0 fd 09 c8 89 82 98 00 00 00 8b 8f 98 00 00 00 83 e1 04 83 e0 fb 09 c8 89 82 98 00 00 00 8b 8f 98 00 00 00 83 e1 08 83 e0 f7 09 c8 89 82 98 00 00 00 8b 8f 98 00 00 00 83 e1 10 83 e0 ef 09 c8 89 82 98 00 00 00 0f b6 87 94 00 00 00 88 82 94 00 00 00 48 8b 5f 68 48 85 db 74 ??"
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"id": "online/accept-local-tls-certificate",
|
||||
"title": "让客户端的 HTTPS 连接接受本地服务的自签证书",
|
||||
|
||||
"program_behaviour": {
|
||||
"stock": "libcurl 建立新连接时用 Curl_clone_primary_ssl_config 把请求侧的 SSL 配置复制到连接侧(+0x98 的第 0 位 verifypeer、第 1 位 verifyhost 默认都是 1)。对于没有读取 enableSslCertCheck 开关的 HTTPS 请求(如脚本的 dagor.http、yuplay2 的购买与兑换码、事件上报),连接被 wto_ws.dll 改道到本地服务后,因本地服务使用自签证书而报 CURLE_PEER_FAILED_VERIFICATION(60)断开。",
|
||||
"patched": "复制 SSL 配置到连接侧时,把 verifypeer 和 verifyhost 两位一并清零,所有经 wto_ws.dll 改道到本地服务的 HTTPS 连接都直接接受本地服务的自签证书。"
|
||||
},
|
||||
|
||||
"derivation": {
|
||||
"requirement": "handover 6.1 方案 B(用户原话 82、115)与功能清单 G「礼包商店」「兑换码」。被 wto_ws.dll 改道到本地服务的 https 请求(api.gaijinent.com 的 GJN 付款、商品信息、兑换码等)必须能完成 TLS 握手并把请求送达本地服务。",
|
||||
"cause": "network.blk 的 enableSslCertCheck 只被 0x155c950 的 4 个调用点读取;dagor.http(httpRequest)等请求不读它,保留了 libcurl 默认的证书链和主机名校验。实测日志:newsfeed.gap.gaijin.net 握手后报 SSL peer certificate or SSH remote key was not OK。",
|
||||
"lighter_options_ruled_out": [
|
||||
"network.blk 的 enableSslCertCheck:已设为 false,但 dagor.http 等路径根本不读取这个配置。",
|
||||
"把本地服务的根证书装进 Windows 系统受信任根证书库:会改动玩家操作系统的全局信任链,影响正版和其他软件,违反隔离原则。"
|
||||
],
|
||||
"conclusion": "在 libcurl 复制连接 SSL 配置的单点清掉 verifypeer 和 verifyhost 两位(仅改 5 字节),同时由于 wto_ws.dll 已拦截所有外部连接,客户端不会连向任何真实外网服务器。",
|
||||
"if_not_applied": "经 wto_ws.dll 改道到本地服务的 https 请求在 TLS 握手后因自签证书校验失败断开,GJN 付款、商品价格查询(item_info.php)和兑换码等无法到达本地服务。"
|
||||
},
|
||||
|
||||
"why_this_site": [
|
||||
"aces.exe 只静态链接了一份 libcurl(OpenSSL 后端),AsyncHTTPClient、dagor.http、YuHttp 全部共用它;Curl_clone_primary_ssl_config 是每个连接初始化 SSL 配置的必经入口。",
|
||||
"0x5646412 原本是清除第 1 位后把 verifyhost 合进 eax,紧接着 0x5646417 写回 [rdx+0x98]。改成 and eax, -4 加两个 nop,一次把第 0 位(verifypeer)和第 1 位(verifyhost)都清零并写回,只改 5 字节,不改变栈和跳转结构。"
|
||||
],
|
||||
|
||||
"features": ["A-不连 Gaijin", "G-礼包商店", "G-兑换码"],
|
||||
"requires": ["online/network-hook-library"],
|
||||
"evidence": [
|
||||
"2.61.0.37 原版 aces.exe:Curl_clone_primary_ssl_config 位于 0x56463c0,由 0x5646360 对主连接(+0x1b0)和代理连接(+0x250)调用;OpenSSL 校验函数 0x63adb70 在 0x63afed5、0x63b0522、0x63b05b7 读取 +0x98 的第 0、1 位。"
|
||||
],
|
||||
"verified_on": [],
|
||||
|
||||
"edit": {
|
||||
"offset": 82,
|
||||
"asm": ["and eax, -4", "nop", "nop"],
|
||||
"bytes": "83e0fc9090",
|
||||
"expect_original": "83e0fd09c8"
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "hook_config.h"
|
||||
#include "redirect_rules.h"
|
||||
|
||||
#include <share.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -60,7 +61,7 @@ void config_load(HMODULE self)
|
||||
find_folder(self);
|
||||
read_port();
|
||||
if (_snwprintf_s(path, MAX_PATH, _TRUNCATE, L"%swto_ws.log", g_folder) >= 0)
|
||||
_wfopen_s(&g_log, path, L"w");
|
||||
g_log = _wfsopen(path, L"w", _SH_DENYWR);
|
||||
log_line("wto_ws: local service port %u%s", g_service_port, g_service_port ? "" : " (none: outside connections are refused)");
|
||||
}
|
||||
|
||||
|
||||
@@ -5,13 +5,14 @@
|
||||
* http(s)://host[:port]/path -> http://127.0.0.1:<port>/host/path (host is a Gaijin domain or an external IP)
|
||||
* ws(s)://host[:port]/path -> ws://127.0.0.1:<port>/host/path
|
||||
* host:port -> 127.0.0.1:<port> (raw TCP endpoints: matching, chat)
|
||||
* host -> 127.0.0.1 (bare Gaijin domain, e.g. the event log host)
|
||||
*
|
||||
* Everything else (file patterns, placeholders such as "https://not.used", DNS server IPs)
|
||||
* is left as it is.
|
||||
* Bare Gaijin host names without a port (e.g. the event log host) are left as they are so the
|
||||
* client keeps their Host header and SNI; wto_ws.dll resolves them locally and sends their
|
||||
* connections to the local service port. Everything else (file patterns,
|
||||
* placeholders such as "https://not.used", DNS server IPs) is also left as it is.
|
||||
*/
|
||||
import { visitParams, type BlkBlock } from '@wto/blk';
|
||||
import { hostPort, localUrl, LOOPBACK, type LocalEndpoint } from './local-endpoint.ts';
|
||||
import { hostPort, localUrl, type LocalEndpoint } from './local-endpoint.ts';
|
||||
|
||||
export interface AddressChange {
|
||||
readonly path: string;
|
||||
@@ -47,7 +48,7 @@ export function rewriteAddress(value: string, endpoint: LocalEndpoint): string |
|
||||
}
|
||||
const hostAndPort = HOST_PORT_PATTERN.exec(value);
|
||||
if (hostAndPort) return isServerHost(hostAndPort[1]!.toLowerCase()) ? hostPort(endpoint) : null;
|
||||
return isGaijinDomain(value.toLowerCase()) ? LOOPBACK : null;
|
||||
return null;
|
||||
}
|
||||
|
||||
function isServerHost(host: string): boolean {
|
||||
|
||||
@@ -7,12 +7,13 @@
|
||||
* certain (https://auth.gaijinent.com/login.php); the others are matched by name to the
|
||||
* addresses in the executable's string table.
|
||||
*
|
||||
* The host keys replace only the host name of every login-related address and keep the
|
||||
* address's port (yuplay2 YuSession::updateApiHost sets the host part). They therefore get
|
||||
* the bare loopback address: "127.0.0.1:<port>" would turn the local login URL into
|
||||
* http://127.0.0.1:<port>:<port>/..., which the game rejects as malformed.
|
||||
* The host-only keys (authHost, ssoHost, storeApiHost, authFallbackHost) are intentionally not
|
||||
* set: they replace only the host name and keep port 443, and turning the host into 127.0.0.1
|
||||
* would strip the original Host header and bypass wto_ws.dll's redirection. Leaving the Gaijin
|
||||
* host names in place lets wto_ws.dll resolve them to 127.0.0.2 and route their TLS connections
|
||||
* to the local service port with the original Host header intact.
|
||||
*/
|
||||
import { localUrl, LOOPBACK, type LocalEndpoint } from './local-endpoint.ts';
|
||||
import { localUrl, type LocalEndpoint } from './local-endpoint.ts';
|
||||
|
||||
const URL_DEFAULTS: ReadonlyArray<readonly [key: string, host: string, path: string]> = [
|
||||
['loginURL', 'auth.gaijinent.com', '/login.php'],
|
||||
@@ -23,12 +24,6 @@ const URL_DEFAULTS: ReadonlyArray<readonly [key: string, host: string, path: str
|
||||
['yupURL', 'yupmaster.gaijinent.com', '/yuitem/get_yup.php'],
|
||||
];
|
||||
|
||||
const HOST_KEYS = ['authHost', 'ssoHost', 'storeApiHost', 'authFallbackHost'];
|
||||
|
||||
export function loginOverrides(endpoint: LocalEndpoint): ReadonlyArray<readonly [key: string, value: string]> {
|
||||
return [
|
||||
...URL_DEFAULTS.map(([key, host, path]) => [key, localUrl(endpoint, host, path)] as const),
|
||||
...HOST_KEYS.map((key) => [key, LOOPBACK] as const),
|
||||
['fallbackIP', LOOPBACK],
|
||||
];
|
||||
return URL_DEFAULTS.map(([key, host, path]) => [key, localUrl(endpoint, host, path)] as const);
|
||||
}
|
||||
Reference in new issue
Block a user