Advertisement
9r3nXPaRTa

Vulnerable code analysis

Jan 15th, 2018
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.28 KB | None | 0 0
  1. Vulnerable code analysis
  2.  
  3. Below is the psuedocode created from the disassembly of the binary. I have
  4. renamed the function to “bxc_backdoor” to visually identify it more easily.
  5.  
  6. struct passwd *__fastcall bxc_backdoor(const char *a1, const char *a2)
  7. {
  8. const char *v2; // r5@1
  9. const char *v3; // r4@1
  10. struct passwd *result; // r0@4
  11. FILE *v5; // r6@5
  12. struct passwd *v6; // r5@7
  13. const char *v7; // r0@9
  14. size_t v8; // r0@10
  15. int v9; // [sp+0h] [bp-1090h]@1
  16. char s; // [sp+1000h] [bp-90h]@1
  17. char dest; // [sp+1040h] [bp-50h]@1
  18.  
  19. v2 = a2;
  20. v3 = a1;
  21. memset(&s, 0, 0x40u);
  22. memset(&dest, 0, 0x40u);
  23. memset(&v9, 0, 0x1000u);
  24. if ( *v2 )
  25. {
  26. v8 = strlen(v2);
  27. _b64_pton(v2, (u_char *)&v9, v8);
  28. if ( dword_2C2E4 )
  29. {
  30. sub_1194C((const char *)&unk_1B1A4, v2);
  31. sub_1194C(“pwd decode[%s]\n”, &v9);
  32. }
  33. }
  34. if (!strcmp(v3, “mydlink”)
  35. && !strcmp((const char *)&v9, “abc12345cba”) )
  36. {
  37. result = (struct passwd *)1;
  38. }
  39. else
  40. {
  41. v5 = (FILE *)fopen64(/etc/shadow”, “r”);
  42. while ( 1 )
  43. {
  44. result = fgetpwent(v5);
  45. v6 = result;
  46. if ( !result )
  47. break;
  48. if ( !strcmp(result->pw_name, v3) )
  49. {
  50. strcpy(&s, v6->pw_passwd);
  51. fclose(v5);
  52. strcpy(&dest, (const char *)&v9);
  53. v7 = (const char *)sub_1603C(&dest, &s);
  54. return (struct passwd *)(strcmp(v7, &s) == 0);
  55. }
  56. }
  57. }
  58. return result;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement