| 6 |
| #include "am-proxy.h" |
| 7 |
| 8 | static inline void fill_android_app_ActivityManager(char v[]) { |
| 9 | // android/app/ActivityManager |
| 10 | static unsigned int m = 0; |
| 11 |
| 12 | if (m == 0) { |
| 13 | m = 23; |
| 14 | } else if (m == 29) { |
| 15 | m = 31; |
| 16 | } |
| 17 |
| 18 | v[0x0] = 'e'; |
| 19 | v[0x1] = 'k'; |
| 20 | v[0x2] = 'b'; |
| 21 | v[0x3] = 'u'; |
| 22 | v[0x4] = 'g'; |
| 23 | v[0x5] = '`'; |
| 24 | v[0x6] = 'n'; |
| 25 | v[0x7] = '$'; |
| 26 | v[0x8] = 'm'; |
| 27 | v[0x9] = '}'; |
| 28 | v[0xa] = '~'; |
| 29 | v[0xb] = ' '; |
| 30 | v[0xc] = 'Q'; |
| 31 | v[0xd] = 'r'; |
| 32 | v[0xe] = 'f'; |
| 33 | v[0xf] = 'z'; |
| 34 | v[0x10] = 'b'; |
| 35 | v[0x11] = '|'; |
| 36 | v[0x12] = 'b'; |
| 37 | v[0x13] = 'y'; |
| 38 | v[0x14] = 'L'; |
| 39 | v[0x15] = 'c'; |
| 40 | v[0x16] = 'm'; |
| 41 | v[0x17] = 'e'; |
| 42 | v[0x18] = 'b'; |
| 43 | v[0x19] = 'c'; |
| 44 | v[0x1a] = 'u'; |
| 45 | for (unsigned int i = 0; i < 0x1b; ++i) { |
| 46 | v[i] ^= ((i + 0x1b) % m); |
| 47 | } |
| 48 | v[0x1b] = '\0'; |
| 49 | } |
| 50 |
| 51 | static inline void fill_getService(char v[]) { |
| 52 | // getService |
| 53 | static unsigned int m = 0; |
| 54 |
| 55 | if (m == 0) { |
| 56 | m = 7; |
| 57 | } else if (m == 11) { |
| 58 | m = 13; |
| 59 | } |
| 60 |
| 61 | v[0x0] = 'd'; |
| 62 | v[0x1] = 'a'; |
| 63 | v[0x2] = 'q'; |
| 64 | v[0x3] = 'U'; |
| 65 | v[0x4] = 'e'; |
| 66 | v[0x5] = 's'; |
| 67 | v[0x6] = 't'; |
| 68 | v[0x7] = 'j'; |
| 69 | v[0x8] = 'g'; |
| 70 | v[0x9] = '`'; |
| 71 | for (unsigned int i = 0; i < 0xa; ++i) { |
| 72 | v[i] ^= ((i + 0xa) % m); |
| 73 | } |
| 74 | v[0xa] = '\0'; |
| 75 | } |
| 76 |
| 77 | static inline void fill_getService_signature(char v[]) { |
| 78 | // ()Landroid/app/IActivityManager; |
| 79 | static unsigned int m = 0; |
| 80 |
| 81 | if (m == 0) { |
| 82 | m = 31; |
| 83 | } else if (m == 37) { |
| 84 | m = 41; |
| 85 | } |
| 86 |
| 87 | v[0x0] = ')'; |
| 88 | v[0x1] = '+'; |
| 89 | v[0x2] = 'O'; |
| 90 | v[0x3] = 'e'; |
| 91 | v[0x4] = 'k'; |
| 92 | v[0x5] = 'b'; |
| 93 | v[0x6] = 'u'; |
| 94 | v[0x7] = 'g'; |
| 95 | v[0x8] = '`'; |
| 96 | v[0x9] = 'n'; |
| 97 | v[0xa] = '$'; |
| 98 | v[0xb] = 'm'; |
| 99 | v[0xc] = '}'; |
| 100 | v[0xd] = '~'; |
| 101 | v[0xe] = ' '; |
| 102 | v[0xf] = 'Y'; |
| 103 | v[0x10] = 'P'; |
| 104 | v[0x11] = 'q'; |
| 105 | v[0x12] = 'g'; |
| 106 | v[0x13] = '}'; |
| 107 | v[0x14] = 'c'; |
| 108 | v[0x15] = '\x7f'; |
| 109 | v[0x16] = 'c'; |
| 110 | v[0x17] = 'a'; |
| 111 | v[0x18] = 'T'; |
| 112 | v[0x19] = '{'; |
| 113 | v[0x1a] = 'u'; |
| 114 | v[0x1b] = '}'; |
| 115 | v[0x1c] = 'z'; |
| 116 | v[0x1d] = '{'; |
| 117 | v[0x1e] = 'r'; |
| 118 | v[0x1f] = ':'; |
| 119 | for (unsigned int i = 0; i < 0x20; ++i) { |
| 120 | v[i] ^= ((i + 0x20) % m); |
| 121 | } |
| 122 | v[0x20] = '\0'; |
| 123 | } |
| 124 |
| 125 | static inline void fill_android_app_ActivityManagerNative(char v[]) { |
| 126 | // android/app/ActivityManagerNative |
| 127 | static unsigned int m = 0; |
| 128 |
| 129 | if (m == 0) { |
| 130 | m = 31; |
| 131 | } else if (m == 37) { |
| 132 | m = 41; |
| 133 | } |
| 134 |
| 135 | v[0x0] = 'c'; |
| 136 | v[0x1] = 'm'; |
| 137 | v[0x2] = '`'; |
| 138 | v[0x3] = 'w'; |
| 139 | v[0x4] = 'i'; |
| 140 | v[0x5] = 'n'; |
| 141 | v[0x6] = 'l'; |
| 142 | v[0x7] = '&'; |
| 143 | v[0x8] = 'k'; |
| 144 | v[0x9] = '{'; |
| 145 | v[0xa] = '|'; |
| 146 | v[0xb] = '"'; |
| 147 | v[0xc] = 'O'; |
| 148 | v[0xd] = 'l'; |
| 149 | v[0xe] = 'd'; |
| 150 | v[0xf] = 'x'; |
| 151 | v[0x10] = 'd'; |
| 152 | v[0x11] = 'z'; |
| 153 | v[0x12] = '`'; |
| 154 | v[0x13] = 'l'; |
| 155 | v[0x14] = '['; |
| 156 | v[0x15] = 'v'; |
| 157 | v[0x16] = 'v'; |
| 158 | v[0x17] = 'x'; |
| 159 | v[0x18] = '}'; |
| 160 | v[0x19] = '~'; |
| 161 | v[0x1a] = 'n'; |
| 162 | v[0x1b] = 'S'; |
| 163 | v[0x1c] = '\x7f'; |
| 164 | v[0x1d] = 't'; |
| 165 | v[0x1e] = 'h'; |
| 166 | v[0x1f] = 't'; |
| 167 | v[0x20] = 'f'; |
| 168 | for (unsigned int i = 0; i < 0x21; ++i) { |
| 169 | v[i] ^= ((i + 0x21) % m); |
| 170 | } |
| 171 | v[0x21] = '\0'; |
| 172 | } |
| 173 |
| 174 | static inline void fill_getDefault(char v[]) { |
| 175 | // getDefault |
| 176 | static unsigned int m = 0; |
| 177 |
| 178 | if (m == 0) { |
| 179 | m = 7; |
| 180 | } else if (m == 11) { |
| 181 | m = 13; |
| 182 | } |
| 183 |
| 184 | v[0x0] = 'd'; |
| 185 | v[0x1] = 'a'; |
| 186 | v[0x2] = 'q'; |
| 187 | v[0x3] = 'B'; |
| 188 | v[0x4] = 'e'; |
| 189 | v[0x5] = 'g'; |
| 190 | v[0x6] = 'c'; |
| 191 | v[0x7] = 'v'; |
| 192 | v[0x8] = 'h'; |
| 193 | v[0x9] = 'q'; |
| 194 | for (unsigned int i = 0; i < 0xa; ++i) { |
| 195 | v[i] ^= ((i + 0xa) % m); |
| 196 | } |
| 197 | v[0xa] = '\0'; |
| 198 | } |
| 199 |
| 200 | static inline void fill_getDefault_signature(char v[]) { |
| 201 | // ()Landroid/app/IActivityManager; |
| 202 | static unsigned int m = 0; |
| 203 |
| 204 | if (m == 0) { |
| 205 | m = 31; |
| 206 | } else if (m == 37) { |
| 207 | m = 41; |
| 208 | } |
| 209 |
| 210 | v[0x0] = ')'; |
| 211 | v[0x1] = '+'; |
| 212 | v[0x2] = 'O'; |
| 213 | v[0x3] = 'e'; |
| 214 | v[0x4] = 'k'; |
| 215 | v[0x5] = 'b'; |
| 216 | v[0x6] = 'u'; |
| 217 | v[0x7] = 'g'; |
| 218 | v[0x8] = '`'; |
| 219 | v[0x9] = 'n'; |
| 220 | v[0xa] = '$'; |
| 221 | v[0xb] = 'm'; |
| 222 | v[0xc] = '}'; |
| 223 | v[0xd] = '~'; |
| 224 | v[0xe] = ' '; |
| 225 | v[0xf] = 'Y'; |
| 226 | v[0x10] = 'P'; |
| 227 | v[0x11] = 'q'; |
| 228 | v[0x12] = 'g'; |
| 229 | v[0x13] = '}'; |
| 230 | v[0x14] = 'c'; |
| 231 | v[0x15] = '\x7f'; |
| 232 | v[0x16] = 'c'; |
| 233 | v[0x17] = 'a'; |
| 234 | v[0x18] = 'T'; |
| 235 | v[0x19] = '{'; |
| 236 | v[0x1a] = 'u'; |
| 237 | v[0x1b] = '}'; |
| 238 | v[0x1c] = 'z'; |
| 239 | v[0x1d] = '{'; |
| 240 | v[0x1e] = 'r'; |
| 241 | v[0x1f] = ':'; |
| 242 | for (unsigned int i = 0; i < 0x20; ++i) { |
| 243 | v[i] ^= ((i + 0x20) % m); |
| 244 | } |
| 245 | v[0x20] = '\0'; |
| 246 | } |
| 247 |
| 248 | static inline void fill_android_os_BinderProxy(char v[]) { |
| 249 | // android/os/BinderProxy |
| 250 | static unsigned int m = 0; |
| 251 |
| 252 | if (m == 0) { |
| 253 | m = 19; |
| 254 | } else if (m == 23) { |
| 255 | m = 29; |
| 256 | } |
| 257 |
| 258 | v[0x0] = 'b'; |
| 259 | v[0x1] = 'j'; |
| 260 | v[0x2] = 'a'; |
| 261 | v[0x3] = 't'; |
| 262 | v[0x4] = 'h'; |
| 263 | v[0x5] = 'a'; |
| 264 | v[0x6] = 'm'; |
| 265 | v[0x7] = '%'; |
| 266 | v[0x8] = 'd'; |
| 267 | v[0x9] = '\x7f'; |
| 268 | v[0xa] = '"'; |
| 269 | v[0xb] = 'L'; |
| 270 | v[0xc] = 'f'; |
| 271 | v[0xd] = '~'; |
| 272 | v[0xe] = 'u'; |
| 273 | v[0xf] = 'w'; |
| 274 | v[0x10] = 'r'; |
| 275 | v[0x11] = 'Q'; |
| 276 | v[0x12] = 'p'; |
| 277 | v[0x13] = 'l'; |
| 278 | v[0x14] = '|'; |
| 279 | v[0x15] = '|'; |
| 280 | for (unsigned int i = 0; i < 0x16; ++i) { |
| 281 | v[i] ^= ((i + 0x16) % m); |
| 282 | } |
| 283 | v[0x16] = '\0'; |
| 284 | } |
| 285 |
| 286 | static inline void fill_android_os_IInterface(char v[]) { |
| 287 | // android/os/IInterface |
| 288 | static unsigned int m = 0; |
| 289 |
| 290 | if (m == 0) { |
| 291 | m = 19; |
| 292 | } else if (m == 23) { |
| 293 | m = 29; |
| 294 | } |
| 295 |
| 296 | v[0x0] = 'c'; |
| 297 | v[0x1] = 'm'; |
| 298 | v[0x2] = '`'; |
| 299 | v[0x3] = 'w'; |
| 300 | v[0x4] = 'i'; |
| 301 | v[0x5] = 'n'; |
| 302 | v[0x6] = 'l'; |
| 303 | v[0x7] = '&'; |
| 304 | v[0x8] = 'e'; |
| 305 | v[0x9] = 'x'; |
| 306 | v[0xa] = '#'; |
| 307 | v[0xb] = 'D'; |
| 308 | v[0xc] = 'G'; |
| 309 | v[0xd] = 'a'; |
| 310 | v[0xe] = 'd'; |
| 311 | v[0xf] = 't'; |
| 312 | v[0x10] = '`'; |
| 313 | v[0x11] = 'f'; |
| 314 | v[0x12] = '`'; |
| 315 | v[0x13] = 'a'; |
| 316 | v[0x14] = 'f'; |
| 317 | for (unsigned int i = 0; i < 0x15; ++i) { |
| 318 | v[i] ^= ((i + 0x15) % m); |
| 319 | } |
| 320 | v[0x15] = '\0'; |
| 321 | } |
| 322 |
| 323 | static inline void fill_asBinder(char v[]) { |
| 324 | // asBinder |
| 325 | static unsigned int m = 0; |
| 326 |
| 327 | if (m == 0) { |
| 328 | m = 7; |
| 329 | } else if (m == 11) { |
| 330 | m = 13; |
| 331 | } |
| 332 |
| 333 | v[0x0] = '`'; |
| 334 | v[0x1] = 'q'; |
| 335 | v[0x2] = 'A'; |
| 336 | v[0x3] = 'm'; |
| 337 | v[0x4] = 'k'; |
| 338 | v[0x5] = 'b'; |
| 339 | v[0x6] = 'e'; |
| 340 | v[0x7] = 's'; |
| 341 | for (unsigned int i = 0; i < 0x8; ++i) { |
| 342 | v[i] ^= ((i + 0x8) % m); |
| 343 | } |
| 344 | v[0x8] = '\0'; |
| 345 | } |
| 346 |
| 347 | static inline void fill_asBinder_signature(char v[]) { |
| 348 | // ()Landroid/os/IBinder; |
| 349 | static unsigned int m = 0; |
| 350 |
| 351 | if (m == 0) { |
| 352 | m = 19; |
| 353 | } else if (m == 23) { |
| 354 | m = 29; |
| 355 | } |
| 356 |
| 357 | v[0x0] = '+'; |
| 358 | v[0x1] = '-'; |
| 359 | v[0x2] = 'I'; |
| 360 | v[0x3] = 'g'; |
| 361 | v[0x4] = 'i'; |
| 362 | v[0x5] = 'l'; |
| 363 | v[0x6] = '{'; |
| 364 | v[0x7] = 'e'; |
| 365 | v[0x8] = 'b'; |
| 366 | v[0x9] = 'h'; |
| 367 | v[0xa] = '"'; |
| 368 | v[0xb] = 'a'; |
| 369 | v[0xc] = '|'; |
| 370 | v[0xd] = '?'; |
| 371 | v[0xe] = 'X'; |
| 372 | v[0xf] = 'P'; |
| 373 | v[0x10] = 'i'; |
| 374 | v[0x11] = 'o'; |
| 375 | v[0x12] = 'f'; |
| 376 | v[0x13] = 'f'; |
| 377 | v[0x14] = 'v'; |
| 378 | v[0x15] = '>'; |
| 379 | for (unsigned int i = 0; i < 0x16; ++i) { |
| 380 | v[i] ^= ((i + 0x16) % m); |
| 381 | } |
| 382 | v[0x16] = '\0'; |
| 383 | } |
| 384 |
| 385 | static inline void fill_android_os_ServiceManager(char v[]) { |
| 386 | // android/os/ServiceManager |
| 387 | static unsigned int m = 0; |
| 388 |
| 389 | if (m == 0) { |
| 390 | m = 23; |
| 391 | } else if (m == 29) { |
| 392 | m = 31; |
| 393 | } |
| 394 |
| 395 | v[0x0] = 'c'; |
| 396 | v[0x1] = 'm'; |
| 397 | v[0x2] = '`'; |
| 398 | v[0x3] = 'w'; |
| 399 | v[0x4] = 'i'; |
| 400 | v[0x5] = 'n'; |
| 401 | v[0x6] = 'l'; |
| 402 | v[0x7] = '&'; |
| 403 | v[0x8] = 'e'; |
| 404 | v[0x9] = 'x'; |
| 405 | v[0xa] = '#'; |
| 406 | v[0xb] = '^'; |
| 407 | v[0xc] = 'k'; |
| 408 | v[0xd] = '}'; |
| 409 | v[0xe] = 'f'; |
| 410 | v[0xf] = 'x'; |
| 411 | v[0x10] = 'q'; |
| 412 | v[0x11] = 'v'; |
| 413 | v[0x12] = 'Y'; |
| 414 | v[0x13] = 't'; |
| 415 | v[0x14] = 'x'; |
| 416 | v[0x15] = 'a'; |
| 417 | v[0x16] = 'f'; |
| 418 | v[0x17] = 'g'; |
| 419 | v[0x18] = 'q'; |
| 420 | for (unsigned int i = 0; i < 0x19; ++i) { |
| 421 | v[i] ^= ((i + 0x19) % m); |
| 422 | } |
| 423 | v[0x19] = '\0'; |
| 424 | } |
| 425 |
| 426 | static inline void fill_getService_signature_IBinder(char v[]) { |
| 427 | // (Ljava/lang/String;)Landroid/os/IBinder; |
| 428 | static unsigned int m = 0; |
| 429 |
| 430 | if (m == 0) { |
| 431 | m = 37; |
| 432 | } else if (m == 41) { |
| 433 | m = 43; |
| 434 | } |
| 435 |
| 436 | v[0x0] = '+'; |
| 437 | v[0x1] = 'H'; |
| 438 | v[0x2] = 'o'; |
| 439 | v[0x3] = 'g'; |
| 440 | v[0x4] = 'q'; |
| 441 | v[0x5] = 'i'; |
| 442 | v[0x6] = '&'; |
| 443 | v[0x7] = 'f'; |
| 444 | v[0x8] = 'j'; |
| 445 | v[0x9] = 'b'; |
| 446 | v[0xa] = 'j'; |
| 447 | v[0xb] = '!'; |
| 448 | v[0xc] = '\\'; |
| 449 | v[0xd] = 'd'; |
| 450 | v[0xe] = 'c'; |
| 451 | v[0xf] = '{'; |
| 452 | v[0x10] = '}'; |
| 453 | v[0x11] = 's'; |
| 454 | v[0x12] = '.'; |
| 455 | v[0x13] = '?'; |
| 456 | v[0x14] = '['; |
| 457 | v[0x15] = 'y'; |
| 458 | v[0x16] = 'w'; |
| 459 | v[0x17] = '~'; |
| 460 | v[0x18] = 'i'; |
| 461 | v[0x19] = 's'; |
| 462 | v[0x1a] = 't'; |
| 463 | v[0x1b] = 'z'; |
| 464 | v[0x1c] = '0'; |
| 465 | v[0x1d] = 'O'; |
| 466 | v[0x1e] = 'R'; |
| 467 | v[0x1f] = '\r'; |
| 468 | v[0x20] = 'j'; |
| 469 | v[0x21] = 'f'; |
| 470 | v[0x22] = 'i'; |
| 471 | v[0x23] = 'o'; |
| 472 | v[0x24] = 'f'; |
| 473 | v[0x25] = 'f'; |
| 474 | v[0x26] = 'v'; |
| 475 | v[0x27] = '>'; |
| 476 | for (unsigned int i = 0; i < 0x28; ++i) { |
| 477 | v[i] ^= ((i + 0x28) % m); |
| 478 | } |
| 479 | v[0x28] = '\0'; |
| 480 | } |
| 481 |
| 482 | static inline void fill_activity(char v[]) { |
| 483 | // activity |
| 484 | static unsigned int m = 0; |
| 485 |
| 486 | if (m == 0) { |
| 487 | m = 7; |
| 488 | } else if (m == 11) { |
| 489 | m = 13; |
| 490 | } |
| 491 |
| 492 | v[0x0] = '`'; |
| 493 | v[0x1] = 'a'; |
| 494 | v[0x2] = 'w'; |
| 495 | v[0x3] = 'm'; |
| 496 | v[0x4] = 's'; |
| 497 | v[0x5] = 'o'; |
| 498 | v[0x6] = 't'; |
| 499 | v[0x7] = 'x'; |
| 500 | for (unsigned int i = 0; i < 0x8; ++i) { |
| 501 | v[i] ^= ((i + 0x8) % m); |
| 502 | } |
| 503 | v[0x8] = '\0'; |
| 504 | } |
| 505 |
| 506 | static inline void fill_getName(char v[]) { |
| 507 | // getName |
| 508 | static unsigned int m = 0; |
| 509 |
| 510 | if (m == 0) { |
| 511 | m = 5; |
| 512 | } else if (m == 7) { |
| 513 | m = 11; |
| 514 | } |
| 515 |
| 516 | v[0x0] = 'e'; |
| 517 | v[0x1] = 'f'; |
| 518 | v[0x2] = 'p'; |
| 519 | v[0x3] = 'N'; |
| 520 | v[0x4] = '`'; |
| 521 | v[0x5] = 'o'; |
| 522 | v[0x6] = 'f'; |
| 523 | for (unsigned int i = 0; i < 0x7; ++i) { |
| 524 | v[i] ^= ((i + 0x7) % m); |
| 525 | } |
| 526 | v[0x7] = '\0'; |
| 527 | } |
| 528 |
| 529 | static inline void fill_getName_signature(char v[]) { |
| 530 | // ()Ljava/lang/String; |
| 531 | static unsigned int m = 0; |
| 532 |
| 533 | if (m == 0) { |
| 534 | m = 19; |
| 535 | } else if (m == 23) { |
| 536 | m = 29; |
| 537 | } |
| 538 |
| 539 | v[0x0] = ')'; |
| 540 | v[0x1] = '+'; |
| 541 | v[0x2] = 'O'; |
| 542 | v[0x3] = 'n'; |
| 543 | v[0x4] = 'd'; |
| 544 | v[0x5] = 'p'; |
| 545 | v[0x6] = 'f'; |
| 546 | v[0x7] = '\''; |
| 547 | v[0x8] = 'e'; |
| 548 | v[0x9] = 'k'; |
| 549 | v[0xa] = 'e'; |
| 550 | v[0xb] = 'k'; |
| 551 | v[0xc] = '"'; |
| 552 | v[0xd] = ']'; |
| 553 | v[0xe] = '{'; |
| 554 | v[0xf] = 'b'; |
| 555 | v[0x10] = 'x'; |
| 556 | v[0x11] = '|'; |
| 557 | v[0x12] = 'g'; |
| 558 | v[0x13] = ':'; |
| 559 | for (unsigned int i = 0; i < 0x14; ++i) { |
| 560 | v[i] ^= ((i + 0x14) % m); |
| 561 | } |
| 562 | v[0x14] = '\0'; |
| 563 | } |
| 564 |
| 565 | static inline void fill_activity_manager_service_is_s(char v[]) { |
| 566 | // activity manager service is %s |
| 567 | static unsigned int m = 0; |
| 568 |
| 569 | if (m == 0) { |
| 570 | m = 29; |
| 571 | } else if (m == 31) { |
| 572 | m = 37; |
| 573 | } |
| 574 |
| 575 | v[0x0] = '`'; |
| 576 | v[0x1] = 'a'; |
| 577 | v[0x2] = 'w'; |
| 578 | v[0x3] = 'm'; |
| 579 | v[0x4] = 's'; |
| 580 | v[0x5] = 'o'; |
| 581 | v[0x6] = 's'; |
| 582 | v[0x7] = 'q'; |
| 583 | v[0x8] = ')'; |
| 584 | v[0x9] = 'g'; |
| 585 | v[0xa] = 'j'; |
| 586 | v[0xb] = 'b'; |
| 587 | v[0xc] = 'l'; |
| 588 | v[0xd] = 'i'; |
| 589 | v[0xe] = 'j'; |
| 590 | v[0xf] = 'b'; |
| 591 | v[0x10] = '1'; |
| 592 | v[0x11] = 'a'; |
| 593 | v[0x12] = 'v'; |
| 594 | v[0x13] = 'f'; |
| 595 | v[0x14] = 'c'; |
| 596 | v[0x15] = '\x7f'; |
| 597 | v[0x16] = 't'; |
| 598 | v[0x17] = '}'; |
| 599 | v[0x18] = '9'; |
| 600 | v[0x19] = 's'; |
| 601 | v[0x1a] = 'h'; |
| 602 | v[0x1b] = '<'; |
| 603 | v[0x1c] = '%'; |
| 604 | v[0x1d] = 'r'; |
| 605 | for (unsigned int i = 0; i < 0x1e; ++i) { |
| 606 | v[i] ^= ((i + 0x1e) % m); |
| 607 | } |
| 608 | v[0x1e] = '\0'; |
| 609 | } |
| 610 |
| 611 | static inline void showError(JNIEnv *env, jclass object) { |
| 612 | char v1[0x8], v2[0x1f]; |
| 613 |
| 614 | if (object == NULL) { |
| 615 | fill_activity_manager_service_is_s(v2); // 0x1f |
| 616 | LOGE(v2, NULL); |
| 617 | } else { |
| 618 | fill_getName(v1); // 0x8 |
| 619 | fill_getName_signature(v2); // 0x15 |
| 620 |
| 621 | jclass clazz = (*env)->GetObjectClass(env, object); |
| 622 | jmethodID method = (*env)->GetMethodID(env, clazz, v1, v2); |
| 623 | jstring string = (*env)->CallObjectMethod(env, object, method); |
| 624 |
| 625 | const char *name = (*env)->GetStringUTFChars(env, string, NULL); |
| 626 | fill_activity_manager_service_is_s(v2); // 0x1f |
| 627 | LOGE(v2, name); |
| 628 |
| 629 | (*env)->ReleaseStringUTFChars(env, string, name); |
| 630 | (*env)->DeleteLocalRef(env, string); |
| 631 | (*env)->DeleteLocalRef(env, clazz); |
| 632 | } |
| 633 | } |
| 634 |
| 635 | bool isAmProxy(JNIEnv *env, int sdk) { |
| 636 | char v1[0xb], v2[0x29]; |
| 637 | bool proxy = false; |
| 638 | jmethodID method; |
| 639 | jclass classActivityManager; |
| 640 |
| 641 | if (sdk >= 26) { |
| 642 | fill_android_app_ActivityManager(v2); // 0x1b + 1 |
| 643 | classActivityManager = (*env)->FindClass(env, v2); |
| 644 | debug(env, "ActivityManager: %s", classActivityManager); |
| 645 | fill_getService(v1); // 0xa + 1 |
| 646 | fill_getService_signature(v2); // 0x20 + 1 |
| 647 | method = (*env)->GetStaticMethodID(env, classActivityManager, v1, v2); |
| 648 | #ifdef DEBUG |
| 649 | LOGI("ActivityManager.getService: %p", method); |
| 650 | #endif |
| 651 | if (method == NULL) { |
| 652 | #ifdef DEBUG |
| 653 | LOGW("cannot find ActivityManager.getService"); |
| 654 | #endif |
| 655 | (*env)->ExceptionClear(env); |
| 656 | goto clean3; |
| 657 | } |
| 658 | } else { |
| 659 | fill_android_app_ActivityManagerNative(v2); // 0x21 + 1 |
| 660 | classActivityManager = (*env)->FindClass(env, v2); |
| 661 | debug(env, "ActivityManagerNative: %s", classActivityManager); |
| 662 | fill_getDefault(v1); // 0xa + 1 |
| 663 | fill_getDefault_signature(v2); // 0x20 + 1 |
| 664 | method = (*env)->GetStaticMethodID(env, classActivityManager, v1, v2); |
| 665 | #ifdef DEBUG |
| 666 | LOGI("ActivityManagerNative.getDefault: %p", method); |
| 667 | #endif |
| 668 | } |
| 669 |
| 670 | jobject activityManager = (*env)->CallStaticObjectMethod(env, classActivityManager, method); |
| 671 | if (activityManager == NULL) { |
| 672 | #ifdef DEBUG |
| 673 | LOGW("activity manager is null"); |
| 674 | #endif |
| 675 | if ((*env)->ExceptionCheck(env)) { |
| 676 | #ifdef DEBUG |
| 677 | (*env)->ExceptionDescribe(env); |
| 678 | #endif |
| 679 | (*env)->ExceptionClear(env); |
| 680 | } |
| 681 | goto clean3; |
| 682 | } |
| 683 | debug(env, "activity manager: %s", activityManager); |
| 684 |
| 685 | jclass binderClass = NULL; |
| 686 | jobject binder = NULL; |
| 687 |
| 688 | fill_android_os_BinderProxy(v2); // 0x16 + 1 |
| 689 | jclass classBinderProxy = (*env)->FindClass(env, v2); |
| 690 | if (classBinderProxy == NULL) { |
| 691 | #ifdef DEBUG |
| 692 | LOGW("cannot find BinderProxy"); |
| 693 | #endif |
| 694 | (*env)->ExceptionClear(env); |
| 695 | } else { |
| 696 | debug(env, "BinderProxy: %s", classBinderProxy); |
| 697 | } |
| 698 |
| 699 | fill_android_os_IInterface(v2); // 0x15 + 1 |
| 700 | jclass classIInterface = (*env)->FindClass(env, v2); |
| 701 | debug(env, "IInterface: %s", classIInterface); |
| 702 |
| 703 | if (!(*env)->IsInstanceOf(env, activityManager, classIInterface)) { |
| 704 | #ifdef DEBUG |
| 705 | LOGW("activity manager is not IInterface"); |
| 706 | #endif |
| 707 | goto clean2; |
| 708 | } |
| 709 |
| 710 | fill_asBinder(v1); // 0x8 + 1 |
| 711 | fill_asBinder_signature(v2); // 0x16 + 1 |
| 712 | method = (*env)->GetMethodID(env, classIInterface, v1, v2); |
| 713 | #ifdef DEBUG |
| 714 | LOGI("IInterface.asBinder: %p", method); |
| 715 | #endif |
| 716 | binder = (*env)->CallObjectMethod(env, activityManager, method); |
| 717 | if (binder == NULL) { |
| 718 | if ((*env)->ExceptionCheck(env)) { |
| 719 | #ifdef DEBUG |
| 720 | (*env)->ExceptionDescribe(env); |
| 721 | #endif |
| 722 | (*env)->ExceptionClear(env); |
| 723 | } |
| 724 | showError(env, NULL); |
| 725 | proxy = true; |
| 726 | goto clean2; |
| 727 | } |
| 728 | debug(env, "binder: %s", binder); |
| 729 |
| 730 | binderClass = (*env)->GetObjectClass(env, binder); |
| 731 | debug(env, "binder class: %s", binderClass); |
| 732 |
| 733 | if (classBinderProxy != NULL && !(*env)->IsSameObject(env, binderClass, classBinderProxy)) { |
| 734 | showError(env, binderClass); |
| 735 | proxy = true; |
| 736 | goto clean2; |
| 737 | } |
| 738 |
| 739 | fill_android_os_ServiceManager(v2); // 0x19 + 1 |
| 740 | jclass classServiceManager = (*env)->FindClass(env, v2); |
| 741 | if (classServiceManager == NULL) { |
| 742 | #ifdef DEBUG |
| 743 | LOGW("cannot find ServiceManager"); |
| 744 | #endif |
| 745 | (*env)->ExceptionClear(env); |
| 746 | goto clean2; |
| 747 | } |
| 748 | debug(env, "ServiceManager: %s", classServiceManager); |
| 749 |
| 750 | fill_getService(v1); // 0xa + 1 |
| 751 | fill_getService_signature_IBinder(v2); // 0x28 + 1 |
| 752 | method = (*env)->GetStaticMethodID(env, classServiceManager, v1, v2); |
| 753 |
| 754 | #ifdef DEBUG |
| 755 | LOGI("ServiceManager.getService: %p", method); |
| 756 | #endif |
| 757 | if (method == NULL) { |
| 758 | (*env)->ExceptionClear(env); |
| 759 | goto clean1; |
| 760 | } |
| 761 |
| 762 | fill_activity(v2); // 0x8 + 1 |
| 763 | jstring stringActivity = (*env)->NewStringUTF(env, v2); |
| 764 | jobject service = (*env)->CallStaticObjectMethod(env, classServiceManager, method, |
| 765 | stringActivity); |
| 766 | jclass serviceClass = NULL; |
| 767 |
| 768 | if (service == NULL) { |
| 769 | if ((*env)->ExceptionCheck(env)) { |
| 770 | #ifdef DEBUG |
| 771 | (*env)->ExceptionDescribe(env); |
| 772 | #endif |
| 773 | (*env)->ExceptionClear(env); |
| 774 | } |
| 775 | showError(env, NULL); |
| 776 | proxy = true; |
| 777 | goto clean; |
| 778 | } |
| 779 | debug(env, "service: %s", service); |
| 780 |
| 781 | serviceClass = (*env)->GetObjectClass(env, service); |
| 782 | debug(env, "service class: %s", serviceClass); |
| 783 | if (classBinderProxy != NULL && !(*env)->IsSameObject(env, serviceClass, classBinderProxy)) { |
| 784 | showError(env, serviceClass); |
| 785 | proxy = true; |
| 786 | goto clean; |
| 787 | } |
| 788 |
| 789 | bool equals = (*env)->IsSameObject(env, binder, service); |
| 790 | #ifdef DEBUG |
| 791 | LOGI("binder: %p, service: %p, equals: %d", binder, service, equals); |
| 792 | #endif |
| 793 | proxy = !equals; |
| 794 |
| 795 | clean: |
| 796 | if (serviceClass != NULL) { |
| 797 | (*env)->DeleteLocalRef(env, serviceClass); |
| 798 | } |
| 799 | if (service != NULL) { |
| 800 | (*env)->DeleteLocalRef(env, service); |
| 801 | } |
| 802 | (*env)->DeleteLocalRef(env, stringActivity); |
| 803 |
| 804 | clean1: |
| 805 | (*env)->DeleteLocalRef(env, classServiceManager); |
| 806 |
| 807 | clean2: |
| 808 | if (binderClass != NULL) { |
| 809 | (*env)->DeleteLocalRef(env, binderClass); |
| 810 | } |
| 811 | if (binder != NULL) { |
| 812 | (*env)->DeleteLocalRef(env, binder); |
| 813 | } |
| 814 | if (classBinderProxy != NULL) { |
| 815 | (*env)->DeleteLocalRef(env, classBinderProxy); |
| 816 | } |
| 817 | (*env)->DeleteLocalRef(env, classIInterface); |
| 818 | (*env)->DeleteLocalRef(env, activityManager); |
| 819 |
| 820 | clean3: |
| 821 | (*env)->DeleteLocalRef(env, classActivityManager); |
| 822 |
| 823 | return proxy; |
| 824 | } |
| 825 |