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
| __int64 __fastcall app_handler(__int64 a1) { v76[8] = 0LL; v76[9] = 0LL; v76[0] = 0LL; v76[1] = 0LL; v76[2] = 0LL; v76[3] = 0LL; v76[10] = 0LL; v76[11] = 0LL; v76[4] = 0LL; v76[5] = 0LL; v76[6] = 0LL; v76[7] = 0LL; v76[12] = 0LL; v76[13] = 0LL; v77 = 0; v73 = 0; v76[14] = 0LL; v76[15] = 0LL; v72 = 0LL; memset(v84, 0, sizeof(v84)); memset(v78, 0, 0x101uLL); memset(v79, 0, 0x101uLL); v75 = 0; v71 = 0LL; v74[0] = 0LL; v74[1] = 0LL; v74[2] = 0LL; v74[3] = 0LL; v2 = CGI_Find_Parameter(a1, "app"); if ( v2 ) { app = *(v2 + 8); v4 = CGI_Find_Parameter(a1, "user"); if ( v4 ) { LABEL_3: v68 = *(v4 + 8); goto LABEL_4; } } else { app = 0LL; v4 = CGI_Find_Parameter(a1, "user"); if ( v4 ) goto LABEL_3; } v68 = 0LL; LABEL_4: v5 = CGI_Find_Parameter(a1, "pwd"); if ( v5 ) { v67 = 1; strncpy(v76, *(v5 + 8), 0x81uLL); } else { v67 = 0; } v6 = CGI_Find_Parameter(a1, "remme"); if ( v6 ) { v66 = strtol(*(v6 + 8), 0LL, 10); v7 = CGI_Find_Parameter(a1, "app_token"); if ( v7 ) { LABEL_8: app_token = *(v7 + 8); goto LABEL_9; } } else { v66 = 0; v7 = CGI_Find_Parameter(a1, "app_token"); if ( v7 ) goto LABEL_8; } app_token = 0LL; LABEL_9: v9 = CGI_Find_Parameter(a1, "renew"); if ( v9 ) renew = strtol(*(v9 + 8), 0LL, 10); else renew = 0; v11 = CGI_Find_Parameter(a1, "auth"); if ( v11 ) { auth = strtol(*(v11 + 8), 0LL, 10); v12 = CGI_Find_Parameter(a1, "sid"); if ( v12 ) goto LABEL_13; } else { auth = 0; v12 = CGI_Find_Parameter(a1, "sid"); if ( v12 ) { LABEL_13: sid = *(v12 + 8); v13 = CGI_Find_Parameter(a1, "client_id"); if ( v13 ) goto LABEL_14; goto LABEL_54; } } sid = 0LL; v13 = CGI_Find_Parameter(a1, "client_id"); if ( v13 ) { LABEL_14: client_id = *(v13 + 8); v15 = CGI_Find_Parameter(a1, "client_app"); if ( v15 ) goto LABEL_15; LABEL_55: client_app = 0LL; v17 = CGI_Find_Parameter(a1, "client_agent"); if ( v17 ) goto LABEL_16; LABEL_56: client_agent = 0LL; goto LABEL_17; } LABEL_54: client_id = 0LL; v15 = CGI_Find_Parameter(a1, "client_app"); if ( !v15 ) goto LABEL_55; LABEL_15: client_app = *(v15 + 8); v17 = CGI_Find_Parameter(a1, "client_agent"); if ( !v17 ) goto LABEL_56; LABEL_16: client_agent = *(v17 + 8); LABEL_17: v19 = CGI_Find_Parameter(a1, "duration"); if ( !v19 || ((v20 = strtol(*(v19 + 8), 0LL, 10), v20 <= 0) ? (v21 = v20 == -1) : (v21 = 1), v22 = v20, !v21) ) v22 = 90; if ( !CGI_Find_Parameter(a1, "gen_client_id") || get_uuid(v79, 257, v23, v24, v25, v26, v27, v28, v64) ) { sub_411020(); if ( Get_App_Token_Support(app) ) { v48 = -1; goto LABEL_35; } v42 = 0; if ( app_token ) goto LABEL_27; if ( ((v68 != 0LL) & v67) == 0 ) goto LABEL_39; LABEL_38: if ( !User_Belongs_To_Group(v68, "administrators") || b64_Decode_Ex(v84, 512LL, v76) <= 0 ) goto LABEL_109; if ( strlen(v84) > 0x40 ) v84[65] = 0; v51 = v68; if ( sub_40D990(v68, v84, 1LL) ) { v48 = -1; sub_40EB90(app, v68, client_id, client_app, client_agent); goto LABEL_34; } if ( v66 ) { if ( !client_id ) { if ( !Get_App_Token(app, v68, v78, 257LL) ) goto LABEL_33; memset(v78, 0, 0x101uLL); if ( !Gen_App_Token(app, v68, v78, 257LL) ) goto LABEL_33; goto LABEL_109; } } else { LABEL_39: if ( !sid ) goto LABEL_63; if ( auth_get_session(sid, 1LL, &unk_43AAB8) ) goto LABEL_109; v51 = byte_43AB0A; if ( !User_Belongs_To_Group(byte_43AB0A, "administrators") ) goto LABEL_109; if ( !v66 ) goto LABEL_63; if ( !client_id ) { if ( !Get_App_Token(app, byte_43AB0A, v78, 257LL) ) goto LABEL_33; memset(v78, 0, 0x101uLL); if ( !Gen_App_Token(app, byte_43AB0A, v78, 257LL) ) goto LABEL_33; v48 = -1; goto LABEL_34; } } if ( !Get_App_Token_by_Client_ID(app, v51, client_id, v78, 257LL) ) goto LABEL_33; memset(v78, 0, 0x101uLL); v43 = v22; v44 = client_agent; v45 = client_app; v46 = client_id; v47 = v51; LABEL_32: if ( !Gen_App_Token_by_Client_ID(app, v47, v46, v45, v44, v43, v78, 257LL) ) { LABEL_33: v48 = 0; sub_40F730("app_token", 0LL, "%s", v34, v35, v36, v37, v38, v39, v40, v41, v78, v30, v31, v32, v33, v64); goto LABEL_34; } goto LABEL_109; } sub_411020(); if ( Get_App_Token_Support(app) ) { v48 = -1; goto LABEL_51; } client_id = v79; v42 = 1; if ( !app_token ) goto LABEL_38; LABEL_27: if ( !*app_token ) goto LABEL_109; if ( !renew ) { if ( !auth ) { if ( client_id ) { if ( Verify_App_Token_by_Client_ID(client_id, app_token, v74, 33LL) ) { LABEL_113: v48 = -1; sub_40EB90(app, v74, client_id, client_app, client_agent); goto LABEL_34; } } else if ( Verify_App_Token(app, app_token, v74, 33LL) ) { LABEL_116: v48 = -1; sub_40EB90(app, v74, 0LL, client_app, client_agent); goto LABEL_34; } LABEL_63: v48 = 0; goto LABEL_34; } if ( client_id ) { if ( Verify_App_Token_by_Client_ID(client_id, app_token, v74, 33LL) ) goto LABEL_50; } else if ( Verify_App_Token(app, app_token, v74, 33LL) ) { LABEL_50: v48 = -1; sub_40EB90(app, v74, client_id, client_app, client_agent); if ( !v42 ) goto LABEL_35; LABEL_51: sub_40F730("client_id", 0LL, v79, v34, v35, v36, v37, v38, v39, v40, v41, v29, v30, v31, v32, v33, v64); goto LABEL_35; } memset(v80, 0, 0x101uLL); if ( qtoken_query_by_token(app_token, &v71) || (v52 = *(v71 + 68), v52 == -1) ) v53 = -1LL; else v53 = v52 + *(v71 + 64); if ( !sub_40EA10(app, v80, 257LL) ) { v54 = client_app ? client_app : v80; if ( !auth_add_session_ex(&v72, v74, 1LL, "", client_id, v54, client_agent, v53) ) { sub_411BA0(&v72); v55 = time(0LL); Update_Token_Last_Access_Time(app_token, v55); memset(v82, 0, 0x1C8uLL); memset(v81, 0, 0x101uLL); if ( app ) { CGI_Get_Http_Info(v82); if ( !sub_40EA10(app, v81, 257LL) ) { if ( LOBYTE(v74[0]) ) v56 = v74; else v56 = "---"; v70 = v56; if ( is_https() ) v57 = 11LL; else v57 = 3LL; v58 = "---"; if ( client_id ) v58 = client_id; if ( client_app ) v59 = client_app; else v59 = v81; if ( client_agent ) v60 = client_agent; else v60 = "Agent"; SendConnToLogEngineEx4(0LL, v70, v81, &v83, "---", v57, 10LL, 0LL, v58, v59, v60, "Administration"); } memset(v82, 0, 0x101uLL); if ( !sub_40EA10(app, v82, 257LL) ) { if ( client_id ) v61 = client_id; else v61 = "---"; if ( client_app ) v62 = client_app; else v62 = v82; if ( client_agent ) v63 = client_agent; else v63 = "Agent"; v48 = 0; shm_add_http_user_with_client_info(v74, "Administration", "---", v61, v62, v63); goto LABEL_34; } } goto LABEL_63; } } LABEL_109: v48 = -1; goto LABEL_34; } if ( client_id ) { if ( !Verify_App_Token_by_Client_ID(client_id, app_token, v74, 33LL) ) { v43 = v22; v44 = client_agent; v45 = client_app; v46 = client_id; v47 = v74; goto LABEL_32; } goto LABEL_113; } if ( Verify_App_Token(app, app_token, v74, 33LL) ) goto LABEL_116; if ( !Gen_App_Token(app, v74, v78, 257LL) ) goto LABEL_33; v48 = -1; LABEL_34: if ( v42 ) goto LABEL_51; LABEL_35: v49 = sub_40F730("result", 0LL, "%d", v34, v35, v36, v37, v38, v39, v40, v41, v48, v30, v31, v32, v33, v64); sub_411060(v49); qtoken_release(v71); return v48; }
|