// // sub_84542C from 0x84542c to 0x845adc (1712 bytes) // // 1 xrefs: // > sub_831254 @ 0x8312ca // // This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False! // // Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA // Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings // Generated at Fri, 27 Nov 2026 12:02:24 +0000 // int __fastcall sub_84542C(const char *a1, const char *a2, char *a3, int a4, int a5, int a6) { int v8; // r8 _DWORD *v9; // r6 size_t v10; // r9 int v11; // r10 int v12; // r0 int v13; // r2 char v14; // r2 int v16; // r0 char *v17; // r1 int v18; // r7 int v19; // r9 int v20; // r3 int v21; // r3 char *v22; // r1 int v23; // r2 int v24; // r3 char v25; // t1 int v26; // r3 char *v27; // r1 int v28; // r2 int v29; // r3 char v30; // t1 size_t v31; // r10 size_t v32; // r0 size_t v33; // r3 size_t v34; // r2 int v35; // r10 size_t v36; // r10 int v37; // r5 int v38; // r4 unsigned int v39; // [sp+44h] [bp-2C8h] char *v41; // [sp+48h] [bp-2C4h] void *v43; // [sp+58h] [bp-2B4h] int v44; // [sp+64h] [bp-2A8h] BYREF ssize_t v45; // [sp+68h] [bp-2A4h] BYREF char *v46; // [sp+6Ch] [bp-2A0h] BYREF char buf[64]; // [sp+70h] [bp-29Ch] BYREF unsigned __int8 v48; // [sp+B0h] [bp-25Ch] BYREF unsigned __int8 v49; // [sp+B1h] [bp-25Bh] char v50; // [sp+B2h] [bp-25Ah] BYREF char v51; // [sp+B3h] [bp-259h] BYREF unsigned __int8 v52; // [sp+B4h] [bp-258h] unsigned __int8 v53; // [sp+B5h] [bp-257h] BYREF unsigned __int8 v54; // [sp+B6h] [bp-256h] unsigned __int8 v55; // [sp+B7h] [bp-255h] unsigned __int8 v56; // [sp+B8h] [bp-254h] unsigned __int8 v57; // [sp+B9h] [bp-253h] char v58[594]; // [sp+BAh] [bp-252h] BYREF v8 = *(_DWORD *)(a6 + 4 * (a5 + 104)); v9 = *(_DWORD **)a6; v39 = *(_DWORD *)(a6 + 216) == 5; v10 = strlen(a3); if ( *(_BYTE *)(a6 + 618) ) sub_8280FC((size_t)v9, "SOCKS5: connecting to HTTP proxy %s port %d\n", a3, a4); if ( (v10 > 0xFF) > v39 ) { v39 = 1; sub_8280FC(*(_DWORD *)a6, "SOCKS5: server resolving disabled for hostnames of length > 255 [actual len=%zu]\n", v10); } v11 = sub_83D604(v9, nullptr, 1); if ( v11 < 0 ) { sub_828178((int)v9, "Connection time-out"); return 28; } sub_8461C8(v8, 1); v12 = sub_842E08(-1, -1, v8, v11); v13 = v12 + 1; if ( v12 == -1 ) { sub_828178(*(_DWORD *)a6, "SOCKS5: no connection here", v13); return 7; } if ( !v12 ) { sub_828178(*(_DWORD *)a6, "SOCKS5: connection timeout", v13); return 28; } if ( (v12 & 4) != 0 ) { sub_828178(*(_DWORD *)a6, "SOCKS5: error occurred during connection", v13, v12 & 4); return 7; } v50 = 0; if ( a1 ) v14 = 2; else v14 = 1; v48 = 5; v49 = v14; v51 = 2; sub_8461C8(v8, 0); sub_8280FC((size_t)v9, "SOCKS5 communication to %s:%d\n", a3, a4); if ( sub_828470((int *)a6, v8, &v48, v49 + 2, &v45) || v49 + 2 != v45 ) { sub_828178((int)v9, "Unable to send initial SOCKS5 request."); return 7; } sub_8461C8(v8, 1); v16 = sub_842E08(v8, -1, -1, v11); if ( v16 == -1 ) { sub_828178(*(_DWORD *)a6, "SOCKS5 nothing to read"); return 7; } if ( !v16 ) { sub_828178(*(_DWORD *)a6, "SOCKS5 read timeout"); return 28; } if ( (v16 & 4) != 0 ) { sub_828178(*(_DWORD *)a6, "SOCKS5 read error occurred"); return 56; } sub_8461C8(v8, 0); if ( sub_844F8C((_DWORD **)a6, v8, (char *)&v48, 2u, &v44) || v44 != 2 ) { sub_828178((int)v9, "Unable to receive initial SOCKS5 response."); return 7; } if ( v48 != 5 ) { sub_828178((int)v9, "Received invalid version in initial SOCKS5 response."); return 7; } if ( v49 ) { if ( v49 != 2 ) { if ( v49 == 1 ) { sub_828178((int)v9, "SOCKS5 GSSAPI per-message authentication is not supported."); return 7; } else if ( v49 == 255 ) { if ( a1 && *a1 ) { sub_828178((int)v9, "No authentication method was acceptable."); return 7; } else { sub_828178( (int)v9, "No authentication method was acceptable. (It is quite likely that the SOCKS5 server wanted a username/passwo" "rd, since none was supplied to the server on this connection.)"); return 7; } } else { sub_828178((int)v9, "Undocumented SOCKS5 mode attempted to be used by server."); return 7; } } if ( a1 && a2 ) { v31 = strlen(a1); v32 = strlen(a2); v49 = v31; v48 = 1; v33 = v32; if ( v31 ) { v43 = (void *)v32; memcpy(&v50, a1, v31); v33 = (size_t)v43; } v34 = v31 + 2; v35 = v31 + 3; *(&v48 + v34) = v33; if ( v33 ) { v41 = (char *)v33; memcpy(&v48 + v35, a2, v33); v33 = (size_t)v41; } } else { v49 = 0; v33 = 0; v50 = 0; v35 = 3; v48 = 1; } v36 = v35 + v33; if ( sub_828470((int *)a6, v8, &v48, v36, &v45) || v36 != v45 ) { sub_828178((int)v9, "Failed to send SOCKS5 sub-negotiation request."); return 7; } if ( sub_844F8C((_DWORD **)a6, v8, (char *)&v48, 2u, &v44) || v44 != 2 ) { sub_828178((int)v9, "Unable to receive SOCKS5 sub-negotiation response."); return 7; } if ( v49 ) { sub_828178((int)v9, "User was rejected by the SOCKS5 server (%d %d).", v48, v49); return 7; } } v48 = 5; v50 = 0; v49 = 1; if ( v39 ) { if ( ((sub_8202A4((int *)a6, a3, a4, (const char **)&v46) + 1) & 0xFFFFFFFD) != 0 ) { if ( v46 ) { v19 = *(_DWORD *)v46; if ( *(_DWORD *)v46 ) { sub_820040(*(_DWORD *)v46, buf, 64); v20 = *(_DWORD *)(v19 + 4); if ( v20 == 2 ) { v51 = 1; v26 = *(_DWORD *)(v19 + 24); v27 = &v51; v28 = v26 + 3; v29 = v26 + 7; do { v30 = *(_BYTE *)++v28; *++v27 = v30; } while ( v28 != v29 ); v18 = 8; sub_8280FC((size_t)v9, "SOCKS5 connect to IPv4 %s (locally resolved)\n", buf); goto LABEL_48; } if ( v20 == 10 ) { v51 = 4; v21 = *(_DWORD *)(v19 + 24); v22 = &v51; v23 = v21 + 7; v24 = v21 + 23; do { v25 = *(_BYTE *)++v23; *++v22 = v25; } while ( v23 != v24 ); v18 = 20; sub_8280FC((size_t)v9, "SOCKS5 connect to IPv6 %s (locally resolved)\n", buf); LABEL_48: sub_8205A4((int)v9, v46); goto LABEL_37; } sub_828178((int)v9, "SOCKS5 connection to %s not supported\n", buf); sub_8205A4((int)v9, v46); } } sub_828178((int)v9, "Failed to resolve \"%s\" for SOCKS5 connect.", a3); } return 6; } v17 = a3; v52 = v10; v51 = 3; v18 = v10 + 5; memcpy(&v53, v17, v10); LABEL_37: *(&v48 + v18) = BYTE1(a4); *(&v48 + v18 + 1) = a4; if ( sub_828470((int *)a6, v8, &v48, v18 + 2, &v45) || v18 + 2 != v45 ) { sub_828178((int)v9, "Failed to send SOCKS5 connect request."); return 7; } if ( sub_844F8C((_DWORD **)a6, v8, (char *)&v48, 0xAu, &v44) ) goto LABEL_76; v37 = v44; if ( v44 != 10 ) goto LABEL_76; if ( v48 != 5 ) { sub_828178((int)v9, "SOCKS5 reply has wrong version, version should be 5."); return 7; } if ( v51 == 3 ) { v37 = v52 + 7; if ( v37 <= 10 ) { if ( v49 ) goto LABEL_90; LABEL_91: sub_8280FC((size_t)v9, "SOCKS5 request granted.\n"); sub_8461C8(v8, 1); return 0; } } else { if ( v51 != 4 ) goto LABEL_82; v37 = 22; } if ( sub_844F8C((_DWORD **)a6, v8, v58, v37 - 10, &v44) || v37 - 10 != v44 ) { LABEL_76: sub_828178((int)v9, "Failed to receive SOCKS5 connect request ack."); return 7; } LABEL_82: if ( !v49 ) goto LABEL_91; switch ( v51 ) { case 1: sub_828178( (int)v9, "Can't complete SOCKS5 connection to %d.%d.%d.%d:%d. (%d)", v52, v53, v54, v55, v57 | (v56 << 8), v49); return 7; case 3: LABEL_90: v38 = *(&v48 + v37 - 2); *(&v48 + v37 - 2) = 0; sub_828178( (int)v9, "Can't complete SOCKS5 connection to %s:%d. (%d)", (const char *)&v53, *(&v48 + v37 - 1) | (v38 << 8), v49); return 7; case 4: sub_828178( (int)v9, "Can't complete SOCKS5 connection to %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%d. (%d)", v52, v53, v54, v55, v56, v57, (unsigned __int8)v58[0], (unsigned __int8)v58[1], (unsigned __int8)v58[2], (unsigned __int8)v58[3], (unsigned __int8)v58[4], (unsigned __int8)v58[5], (unsigned __int8)v58[6], (unsigned __int8)v58[7], (unsigned __int8)v58[8], (unsigned __int8)v58[9], (unsigned __int8)v58[11] | ((unsigned __int8)v58[10] << 8), v49); break; } return 7; }
GD Web Decomp Icon

GD Web Decomp

Raw Source