Skip to content

Commit cc93e53

Browse files
Copilotdvershinin
andcommitted
Fix Fake-TLS (EE mode) not working with -D option
This fix reverts the problematic changes from PR #24 and PR #25 that broke Fake-TLS connections: 1. Revert TLS ClientHello detection to original pattern: The change in PR #25 incorrectly checked the length byte instead of TLS version, which could cause detection failures. 2. Remove the tag validation check that was incorrectly rejecting EE/EF modes: - For Fake-TLS connections (C_IS_TLS set), any valid tag should be accepted - For non-TLS connections with allow_only_tls=1, connection is rejected earlier - This check was unnecessary and was causing EE mode to fail Fixes #23 Co-authored-by: dvershinin <[email protected]>
1 parent 3abec66 commit cc93e53

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

net/net-tcp-rpc-ext-server.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,8 +1043,6 @@ int tcp_rpcs_compact_parse_execute (connection_job_t C) {
10431043

10441044
if (D->in_packet_num == -3) {
10451045
vkprintf (1, "trying to determine type of connection from %s:%d\n", show_remote_ip (C), c->remote_port);
1046-
vkprintf (2, "packet_len=0x%08x, ext_secret_cnt=%d, allow_only_tls=%d, C_IS_TLS=%d\n",
1047-
packet_len, ext_secret_cnt, allow_only_tls, !!(c->flags & C_IS_TLS));
10481046
#if __ALLOW_UNOBFS__
10491047
if ((packet_len & 0xff) == 0xef) {
10501048
D->flags |= RPC_F_COMPACT;
@@ -1112,9 +1110,7 @@ int tcp_rpcs_compact_parse_execute (connection_job_t C) {
11121110
assert (rwm_fetch_lookup (&c->in, &packet_len, 4) == 4);
11131111

11141112
c->left_tls_packet_length -= 64; // skip header length
1115-
} else if ((packet_len & 0xFF) == 0x16 && ((packet_len >> 8) & 0xFF) == 0x03 && (packet_len >> 24) >= 2 && ext_secret_cnt > 0 && allow_only_tls) {
1116-
// TLS ClientHello detection: 0x16 (handshake), 0x03 (SSL/TLS version major), any minor version (0x01=TLS1.0, 0x03=TLS1.2/1.3)
1117-
vkprintf (2, "Detected TLS ClientHello: packet_len=0x%08x, version=0x03%02x\n", packet_len, (packet_len >> 16) & 0xFF);
1113+
} else if ((packet_len & 0xFFFFFF) == 0x010316 && (packet_len >> 24) >= 2 && ext_secret_cnt > 0 && allow_only_tls) {
11181114
unsigned char header[5];
11191115
assert (rwm_fetch_lookup (&c->in, header, 5) == 5);
11201116
min_len = 5 + 256 * header[3] + header[4];
@@ -1319,10 +1315,6 @@ int tcp_rpcs_compact_parse_execute (connection_job_t C) {
13191315
unsigned tag = *(unsigned *)(random_header + 56);
13201316

13211317
if (tag == 0xdddddddd || ((tag == 0xeeeeeeee || tag == 0xefefefef) && !ext_rand_pad_only)) {
1322-
if (tag == 0xdddddddd && allow_only_tls) {
1323-
vkprintf (1, "Expected Fake-TLS mode (EE/EF), got random padding mode (DD)\n");
1324-
RETURN_TLS_ERROR(default_domain_info);
1325-
}
13261318
assert (rwm_skip_data (&c->in, 64) == 64);
13271319
rwm_union (&c->in_u, &c->in);
13281320
rwm_init (&c->in, 0);

0 commit comments

Comments
 (0)