// // sub_1005735E0 from 0x1005735e0 to 0x100573f8c (2476 bytes) // // 2 xrefs: // > sub_100554164 @ 0x100554264 // > sub_10055C8FC @ 0x10055c94c // // This function is hookable on this platform! // // Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA // Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings // __int64 __fastcall sub_1005735E0(const char *a1, const char *a2, char *__s, int a4, int a5, _QWORD **a6) { __int64 v10; // x21 _QWORD *v11; // x19 int v12; // w27 size_t v13; // x0 size_t v14; // x24 bool v15; // w28 __int64 v17; // x27 int v18; // w0 __int64 v20; // x23 int v21; // w0 size_t i; // x27 __int64 v23; // x8 int v24; // w0 size_t v25; // x27 size_t v26; // x23 size_t v27; // x26 __int64 v28; // x27 __int16 *v29; // x25 size_t v30; // x26 __int64 v31; // x8 int v32; // w0 int v33; // w0 __int64 v35; // x24 char *v36; // x9 size_t v37; // x24 __int64 v38; // x25 __int16 *v39; // x23 size_t j; // x24 _QWORD *v41; // x1 __int64 v42; // x8 int v43; // w9 _BYTE *v44; // x23 _BYTE *v45; // x8 __int64 v46; // x8 int v47; // w0 unsigned __int64 v48; // x8 __int64 v49; // x24 unsigned __int64 v50; // x25 _BYTE *v51; // x22 size_t v52; // x23 __int64 v53; // x8 int v54; // w0 __int64 v55; // [xsp+0h] [xbp-380h] __int64 v56; // [xsp+A0h] [xbp-2E0h] __int16 *v57; // [xsp+A8h] [xbp-2D8h] _QWORD *v59; // [xsp+B8h] [xbp-2C8h] BYREF ssize_t v60; // [xsp+C0h] [xbp-2C0h] BYREF ssize_t v61; // [xsp+C8h] [xbp-2B8h] BYREF __int16 v62; // [xsp+D0h] [xbp-2B0h] BYREF char v63; // [xsp+D2h] [xbp-2AEh] BYREF char v64; // [xsp+D3h] [xbp-2ADh] unsigned __int8 v65; // [xsp+D4h] [xbp-2ACh] unsigned __int8 v66; // [xsp+D5h] [xbp-2ABh] BYREF unsigned __int8 v67; // [xsp+D6h] [xbp-2AAh] unsigned __int8 v68; // [xsp+D7h] [xbp-2A9h] unsigned __int8 v69; // [xsp+D8h] [xbp-2A8h] unsigned __int8 v70; // [xsp+D9h] [xbp-2A7h] _BYTE v71[590]; // [xsp+DAh] [xbp-2A6h] BYREF v10 = *((unsigned int *)a6 + a5 + 116); v11 = *a6; v12 = *((_DWORD *)a6 + 104); v13 = strlen(__s); v14 = v13; v15 = v12 == 5; if ( v13 >= 0x100 && v12 != 5 ) { sub_1005524A4( (size_t)v11, "SOCKS5: server resolving disabled for hostnames of length > 255 [actual len=%zu]\n", v13); v15 = 1; } v17 = sub_10056A280(v11, nullptr, 1); if ( v17 < 0 ) { sub_100552734((__int64)v11, "Connection time-out"); return 28; } sub_1005748EC(v10, 1); v18 = sub_100570DE8(-1, -1, v10, v17); if ( !v18 ) { sub_100552734((__int64)*a6, "SOCKS5: connection timeout"); return 28; } if ( v18 == -1 ) { sub_100552734((__int64)*a6, "SOCKS5: no connection here"); return 7; } if ( (v18 & 4) != 0 ) { sub_100552734((__int64)*a6, "SOCKS5: error occurred during connection"); return 7; } LOBYTE(v62) = 5; if ( a1 ) v20 = 2; else v20 = 1; HIBYTE(v62) = v20; v63 = 0; v64 = 2; sub_1005748EC(v10, 0); if ( (unsigned int)sub_100552A80(a6, v10, &v62, v20 + 2, &v60) || v60 != HIBYTE(v62) + 2LL ) { sub_100552734((__int64)v11, "Unable to send initial SOCKS5 request.", v55); return 7; } sub_1005748EC(v10, 1); v21 = sub_100570DE8(v10, -1, -1, v17); if ( !v21 ) { sub_100552734((__int64)*a6, "SOCKS5 read timeout"); return 28; } if ( v21 == -1 ) { sub_100552734((__int64)*a6, "SOCKS5 nothing to read"); return 7; } if ( (v21 & 4) != 0 ) { sub_100552734((__int64)*a6, "SOCKS5 read error occurred"); return 56; } v57 = &v62; sub_1005748EC(v10, 0); v56 = 0; for ( i = 2; ; i -= v61 ) { do { v23 = sub_10056A280(*a6, nullptr, 1); if ( v23 < 0 || (int)sub_100570DE8(v10, -1, -1, v23) < 1 ) goto LABEL_41; v24 = sub_1005530CC(v10, v57, i, &v61); } while ( v24 == 81 ); if ( v24 ) goto LABEL_41; if ( i == v61 ) break; if ( !v61 ) goto LABEL_41; v57 = (__int16 *)((char *)v57 + v61); v56 += v61; } if ( v56 + i != 2 ) { LABEL_41: sub_100552734((__int64)v11, "Unable to receive initial SOCKS5 response."); return 7; } if ( (unsigned __int8)v62 != 5 ) { sub_100552734((__int64)v11, "Received invalid version in initial SOCKS5 response.", v55); return 7; } switch ( HIBYTE(v62) ) { case 0xFF: if ( a1 && *a1 ) sub_100552734((__int64)v11, "No authentication method was acceptable.", v55); else sub_100552734( (__int64)v11, "No authentication method was acceptable. (It is quite likely that the SOCKS5 server wanted a username/password" ", since none was supplied to the server on this connection.)", v55); return 7; case 0: goto LABEL_73; case 1: sub_100552734((__int64)v11, "SOCKS5 GSSAPI per-message authentication is not supported.", v55); return 7; case 2: if ( a1 && a2 ) { v25 = strlen(a1); v26 = strlen(a2); LOBYTE(v62) = 1; HIBYTE(v62) = v25; if ( v25 ) __memcpy_chk(&v63, a1, v25, 598); else v25 = 0; } else { v26 = 0; v25 = 0; v62 = 1; } v27 = v25 + 3; *((_BYTE *)&v62 + v25 + 2) = v26; if ( a2 && v26 ) memcpy((char *)&v62 + v27, a2, v26); if ( (unsigned int)sub_100552A80(a6, v10, &v62, v27 + v26, &v60) || v27 + v26 != v60 ) { sub_100552734((__int64)v11, "Failed to send SOCKS5 sub-negotiation request.", v55); return 7; } v28 = 0; v29 = &v62; v30 = 2; break; default: sub_100552734((__int64)v11, "Undocumented SOCKS5 mode attempted to be used by server.", v55); return 7; } while ( 1 ) { do { v31 = sub_10056A280(*a6, nullptr, 1); if ( v31 < 0 || (int)sub_100570DE8(v10, -1, -1, v31) < 1 ) goto LABEL_84; v32 = sub_1005530CC(v10, v29, v30, &v61); } while ( v32 == 81 ); if ( v32 ) goto LABEL_84; if ( v30 == v61 ) break; if ( !v61 ) goto LABEL_84; v29 = (__int16 *)((char *)v29 + v61); v28 += v61; v30 -= v61; } if ( v28 + v30 != 2 ) { LABEL_84: sub_100552734((__int64)v11, "Unable to receive SOCKS5 sub-negotiation response.", v55); return 7; } if ( HIBYTE(v62) ) { sub_100552734((__int64)v11, "User was rejected by the SOCKS5 server (%d %d)."); return 7; } LABEL_73: v62 = 261; v63 = 0; if ( v15 ) { v33 = sub_100549994((__int64 *)a6, __s, a4, (__int64 *)&v59); if ( v33 == -1 || v33 == 1 ) return 6; v41 = v59; if ( v59 ) { v42 = *v59; if ( *v59 ) { v43 = *(_DWORD *)(v42 + 4); if ( v43 == 2 ) { v64 = 1; v44 = *(_BYTE **)(v42 + 32); v65 = v44[4]; sub_1005524A4((size_t)v11, "%d\n", v65); v66 = v44[5]; sub_1005524A4((size_t)v11, "%d\n", v66); v67 = v44[6]; sub_1005524A4((size_t)v11, "%d\n", v67); v68 = v44[7]; sub_1005524A4((size_t)v11, "%d\n", v68); v35 = 8; v41 = v59; LABEL_92: sub_100549D10((__int64)v11, v41); goto LABEL_81; } if ( v43 == 30 ) { v64 = 4; v45 = *(_BYTE **)(v42 + 32); v65 = v45[8]; v66 = v45[9]; v67 = v45[10]; v68 = v45[11]; v69 = v45[12]; v70 = v45[13]; v71[0] = v45[14]; v71[1] = v45[15]; v71[2] = v45[16]; v71[3] = v45[17]; v71[4] = v45[18]; v71[5] = v45[19]; v71[6] = v45[20]; v71[7] = v45[21]; v71[8] = v45[22]; v71[9] = v45[23]; v35 = 20; goto LABEL_92; } sub_100549D10((__int64)v11, v59); } } sub_100552734((__int64)v11, "Failed to resolve \"%s\" for SOCKS5 connect.", __s); return 6; } v64 = 3; v65 = v14; __memcpy_chk(&v66, __s, v14, 595); v35 = v14 + 5; LABEL_81: v36 = (char *)&v62 + v35; *v36 = BYTE1(a4); v37 = v35 + 2; v36[1] = a4; if ( (unsigned int)sub_100552A80(a6, v10, &v62, v37, &v60) || v37 != v60 ) { sub_100552734((__int64)v11, "Failed to send SOCKS5 connect request.", v55); return 7; } v38 = 0; v39 = &v62; for ( j = 10; ; j -= v61 ) { do { v46 = sub_10056A280(*a6, nullptr, 1); if ( v46 < 0 || (int)sub_100570DE8(v10, -1, -1, v46) < 1 ) goto LABEL_128; v47 = sub_1005530CC(v10, v39, j, &v61); } while ( v47 == 81 ); if ( v47 ) goto LABEL_128; if ( j == v61 ) break; if ( !v61 ) goto LABEL_128; v39 = (__int16 *)((char *)v39 + v61); v38 += v61; } if ( v38 + j != 10 ) { LABEL_128: sub_100552734((__int64)v11, "Failed to receive SOCKS5 connect request ack.", v55); return 7; } if ( (unsigned __int8)v62 != 5 ) { sub_100552734((__int64)v11, "SOCKS5 reply has wrong version, version should be 5.", v55); return 7; } if ( !HIBYTE(v62) ) { v48 = 22; if ( v64 != 4 ) { if ( v64 != 3 || (v48 = v65 + 7LL, v48 < 0xB) ) { LABEL_127: sub_1005748EC(v10, 1); return 0; } } v49 = 0; v50 = v48 - 10; v51 = v71; v52 = v48 - 10; while ( 1 ) { v53 = sub_10056A280(*a6, nullptr, 1); if ( v53 < 0 || (int)sub_100570DE8(v10, -1, -1, v53) < 1 ) goto LABEL_128; v54 = sub_1005530CC(v10, v51, v52, &v61); if ( v54 != 81 ) { if ( v54 ) goto LABEL_128; if ( v52 == v61 ) { if ( v50 != v49 + v52 ) goto LABEL_128; goto LABEL_127; } if ( !v61 ) goto LABEL_128; v51 += v61; v49 += v61; v52 -= v61; } } } switch ( v64 ) { case 4: sub_100552734( (__int64)v11, "Can't complete SOCKS5 connection to %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%d. (%d)", v65, v66, v67, v68, v69, v70); return 7; case 3: sub_100552734((__int64)v11, "Can't complete SOCKS5 connection to %s:%d. (%d)"); return 7; case 1: sub_100552734((__int64)v11, "Can't complete SOCKS5 connection to %d.%d.%d.%d:%d. (%d)"); return 7; } return 7; }
GD Web Decomp Icon

GD Web Decomp

Raw Source