1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381
| int __fastcall authenticationcgi_main(int a1, _DWORD *a2) { char *request_method; // $s1 int v4; // $s5 char *v5; // $s4 int v6; // $s1 unsigned int v7; // $s0 int v8; // $a3 int v9; // $a2 unsigned int v10; // $v0 int *v11; // $s0 unsigned int v12; // $hi char v13; // $a0 int v14; // $s0 ssize_t v15; // $v1 int v16; // $s1 unsigned int v17; // $s0 char *v18; // $v0 char *v19; // $s0 int v20; // $s0 int v21; // $v0 const char **v22; // $s2 int i; // $s1 const char *v24; // $s0 char *v25; // $v0 const char *v26; // $a1 const char *v27; // $a2 int v28; // $v0 int v29; // $s0 _DWORD *v30; // $s3 _DWORD *v31; // $s4 _DWORD *v32; // $s2 int v33; // $s1 const char *v34; // $s0 char *string; // $v0 char *v36; // $v0 struct sysinfo *v37; // $s1 size_t v38; // $v0 size_t v39; // $s2 int v40; // $s0 int v41; // $v0 struct sysinfo *v42; // $s1 size_t v43; // $v0 size_t v44; // $s2 int v45; // $s0 int v46; // $v0 char *v47; // $v0 const char *v48; // $s4 int v49; // $s3 unsigned int v50; // $s0 char *v52; // [sp+10h] [-F58h] int v53; // [sp+20h] [-F48h] BYREF char v54[16]; // [sp+24h] [-F44h] BYREF struct sysinfo v55; // [sp+34h] [-F34h] BYREF char v56[128]; // [sp+74h] [-EF4h] BYREF char v57[128]; // [sp+F4h] [-E74h] BYREF int v58[33]; // [sp+174h] [-DF4h] BYREF char v59[128]; // [sp+1F8h] [-D70h] BYREF unsigned int v60; // [sp+278h] [-CF0h] int v61[58]; // [sp+27Ch] [-CECh] BYREF unsigned int v62; // [sp+364h] [-C04h] BYREF int v63; // [sp+368h] [-C00h] char v64[160]; // [sp+3ACh] [-BBCh] BYREF char v65[256]; // [sp+44Ch] [-B1Ch] BYREF int v66[67]; // [sp+54Ch] [-A1Ch] BYREF int v67[97]; // [sp+658h] [-910h] BYREF char v68[256]; // [sp+7DCh] [-78Ch] BYREF char v69[132]; // [sp+8DCh] [-68Ch] BYREF char v70[512]; // [sp+960h] [-608h] BYREF char v71[1024]; // [sp+B60h] [-408h] BYREF char *haystack; // [sp+F60h] [-8h] char *dest; // [sp+F64h] [-4h]
request_method = getenv("REQUEST_METHOD"); memset(v61, 0, sizeof(v61)); memset(v67, 0, sizeof(v67)); memset(v58, 0, sizeof(v58)); v4 = sub_40A370((const char *)*a2); if ( !request_method ) goto LABEL_95; if ( v4 == 1 || v4 == 3 ) // 如果调用logout.cgi { v5 = getenv("REMOTE_ADDR"); if ( sub_40A424((int)v68) < 0 ) goto LABEL_16; v6 = sub_40A82C(&v62, v69, v4); if ( v6 < 0 ) goto LABEL_16; if ( v63 < 0 ) goto LABEL_16; v7 = v62; sysinfo(&v55); if ( v7 < v55.uptime ) goto LABEL_16; if ( strcmp(v5, v64) ) goto LABEL_16; sysinfo(&v55); v62 = v55.uptime + 600; sub_40A69C(&v62, v6, 1, v4); if ( v63 < 0 ) goto LABEL_16; if ( sub_40A424((int)v68) < 0 ) goto LABEL_16; v8 = sub_40A82C(&v62, v69, v4); if ( v8 < 0 ) goto LABEL_16; if ( v4 == 1 ) sprintf(v65, "%s/%d", "/var/session", v8); else sprintf(v65, "%s/webfa%d", "/var/session", v8); if ( unlink(v65) >= 0 ) v9 = 10; else LABEL_16: v9 = 11; goto LABEL_96; } if ( !strcmp(request_method, "GET") ) // if GET { v10 = time(0); v11 = v58; srand(v10); do // produce random string { v12 = rand() % 0x3E; v13 = v12 + '0'; if ( v12 >= 0xA && (v13 = v12 + 0x37, v12 - 10 >= 0x1A) ) { if ( v12 - 0x24 >= 0x1A ) *(_BYTE *)v11 = '0'; else *(_BYTE *)v11 = v12 + 0x3D; } else { *(_BYTE *)v11 = v13; } v11 = (int *)((char *)v11 + 1); } while ( v11 != (int *)((char *)&v58[2] + 2) ); BYTE2(v58[2]) = 0; v14 = open("/proc/sys/kernel/random/uuid", 0, v12 - 10 < 0x1A); v15 = read(v14, &v58[16], 0x40u); if ( v15 >= 37 ) v15 = 36; *((_BYTE *)&v58[16] + v15) = 0; close(v14); sysinfo(&v55); v58[32] = v55.uptime + 600; v16 = 1; do { if ( sub_40A960(v59, v16, 0) < 0 ) goto LABEL_32; v17 = v60; sysinfo(&v55); ++v16; if ( v17 < v55.uptime ) { --v16; LABEL_32: sysinfo(&v55); v58[32] = v55.uptime + 600; sub_40A960(v58, v16, 1); v9 = 0; goto LABEL_96; } } while ( v16 != 129 ); v9 = 1; goto LABEL_96; } if ( strcmp(request_method, "POST") ) { LABEL_95: v9 = 4; goto LABEL_96; } memset(v67, 0, sizeof(v67)); v19 = getenv("CONTENT_TYPE"); v18 = getenv("CONTENT_LENGTH"); if ( !v19 || !v18 || (v20 = atoi(v18), v21 = fileno(stdin), read(v21, v71, v20) < 0)// input 也会出现溢出,只要控制length>1024 || (v71[v20] = 0, sub_40A424((int)v67) < 0) ) { LABEL_51: v9 = 5; goto LABEL_96; } haystack = v71; dest = (char *)v67; v22 = (const char **)off_43308C; for ( i = 0; i != 2; ++i ) // id=&password= { v24 = *v22; v25 = strstr(haystack, *v22); v26 = &v25[strlen(v24)]; // v25+len(v24) v27 = v26; while ( 1 ) // 读取id=之后&之前的内容 { v28 = *v27; if ( v28 == '&' ) break; ++v27; if ( !v28 ) { --v27; break; } } v29 = v27 - v26; // id的大小 if ( i ) // 如果是password { if ( i != 1 ) goto LABEL_51; strncpy((char *)&v67[32], v26, v27 - v26);// v67+0x80 没控制password大小 *((_BYTE *)&v67[32] + v29) = 0; } else // 如果是id { strncpy(dest, v26, v27 - v26); *((_BYTE *)v67 + v29) = 0; } ++v22; } memset(v58, 0, sizeof(v58)); if ( sub_40AACC(v58, &v67[64]) < 0 ) // 检查cookie,因此cookie必须存在 { v9 = 6; goto LABEL_96; } if ( v4 ) { if ( v4 != 2 ) goto LABEL_85; if ( !fopen("/var/run/storage_account_root", "r") ) { v9 = 12; goto LABEL_96; } memset(v66, 0, sizeof(v66)); v66[1] = (int)v67; if ( check_id_password(v66, v56) >= 0 ) { sprintf(v70, "%s%s", (const char *)v67, (const char *)&v58[16]); v42 = (struct sysinfo *)v54; v44 = strlen(v70); v43 = strlen(v56); v52 = v54; ((void (__fastcall *)(char *, size_t, char *, size_t))hmac_md5)(v70, v44, v56, v43); v45 = 0; do { v46 = sprintf(&v57[v45], "%02x", LOBYTE(v42->uptime)); v42 = (struct sysinfo *)((char *)v42 + 1); v45 += v46; } while ( v42 != &v55 ); if ( !strcmp(v57, (const char *)&v67[32]) ) { v67[96] = 0; goto LABEL_85; } } LABEL_84: v9 = 3; goto LABEL_96; } memset(v66, 0, sizeof(v66)); v66[1] = (int)v67; v66[0] = -1; v53 = 0; v30 = sobj_new(); v31 = sobj_new(); v32 = sobj_new(); v33 = xs_fopen("/var/passwd", "r"); if ( v33 ) { if ( !v30 ) goto LABEL_65; if ( v31 && v32 ) { while ( 1 ) { sobj_xstream_eatwhite(v33); if ( sobj_xstream_read(v33, v30, 0, &v53) <= 0 ) break; sobj_xstream_eatwhite(v33); if ( sobj_xstream_read(v33, v31, 0, &v53) <= 0 ) break; sobj_xstream_eatwhite(v33); if ( sobj_xstream_read(v33, v32, 0, &v53) <= 0 ) break; v34 = (const char *)v66[1]; // id string = sobj_get_string((int)v30); if ( !strcmp(v34, string) ) { v66[2] = sobj_strdup(v31); v36 = sobj_get_string((int)v32); v66[0] = atoi(v36); break; } sobj_free(v30); sobj_free(v31); sobj_free(v32); } } } else if ( !v30 ) { goto LABEL_65; } sobj_del(v30); LABEL_65: if ( v31 ) sobj_del(v31); if ( v32 ) sobj_del(v32); if ( v33 ) xs_close(v33); if ( v66[0] < 0 ) goto LABEL_84; sprintf(v70, "%s%s", (const char *)v67, (const char *)&v58[16]); v37 = (struct sysinfo *)v54; v39 = strlen(v70); v38 = strlen((const char *)v66[2]); v52 = v54; ((void (__fastcall *)(char *, size_t, int, size_t))hmac_md5)(v70, v39, v66[2], v38); v40 = 0; do { v41 = sprintf(&v56[v40], "%02X", LOBYTE(v37->uptime)); v37 = (struct sysinfo *)((char *)v37 + 1); v40 += v41; } while ( v37 != &v55 ); if ( strcmp(v56, (const char *)&v67[32]) ) goto LABEL_84; v67[96] = v66[0]; LABEL_85: memset(v66, 0, sizeof(v66)); v66[1] = (int)v67; if ( check_id_password(v66, v57) >= 0 // v66[3]=storage_id;v57=storage_passwd && (strcpy((char *)v67, (const char *)&v66[3]), v47 = getenv("REMOTE_ADDR"), (v48 = v47) != 0)// remote_addr 必须存在 && (v49 = 1, *v47) ) { memset(v61, 0, sizeof(v61)); while ( sub_40A69C(v61, v49, 0, v4) >= 0 ) { v50 = v61[0]; sysinfo(&v55); ++v49; if ( v50 < v55.uptime ) { --v49; break; } if ( v49 == 129 ) goto LABEL_100; } memset(v61, 0, sizeof(v61)); strncpy((char *)&v61[2], (const char *)&v67[64], 0x40u); strncpy((char *)&v61[22], (const char *)v67, 0x80u); strncpy((char *)&v61[18], v48, 0x10u); sysinfo(&v55); v61[0] = v55.uptime + 600; v61[1] = v67[96]; sub_40A69C(v61, v49, 1, v4); sub_40ABE4(&v61[2]); v9 = 2; } else { LABEL_100: v9 = 8; } LABEL_96: error_print((char *)v67, (int)v58, v9); return 0; }
|