Advertisement
Guest User

CairoSecurityCamp ELF1 WriteUp

a guest
Nov 22nd, 2014
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.80 KB | None | 0 0
  1. [X] CairoSecurityCamp CTF 2014 WriteUp (ELF1)
  2. [X] Author : fr0g
  3. [X] Main : fr0g.security@gmail.com
  4. [X] Greet'z : SaxX, NotFound, All Hexpresso team members
  5.  
  6.  
  7. MD5SUM : 1299439f81e7d3bd5d32274dc2c44233
  8.  
  9. On passe le binaire à la commande file, on voit qu'il n'est pas stripped
  10.  
  11. $> file binary
  12. binary: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x18dc5a21c6f0313a73840f9591328a75dbc1e624, not stripped
  13.  
  14.  
  15. Première execution :
  16.  
  17. $> ./binary
  18. *********************************
  19. welcome to cracking challenge
  20. *********************************
  21. Enter you password: toto
  22. $>
  23.  
  24.  
  25. On le lance avec gdb, on break sur main, et c'est parti :)
  26.  
  27.  
  28. 0x0000000000400964 <+0>: push rbp
  29. 0x0000000000400965 <+1>: mov rbp,rsp
  30. 0x0000000000400968 <+4>: mov ecx,0x0
  31. 0x000000000040096d <+9>: mov edx,0x1
  32. 0x0000000000400972 <+14>: mov esi,0x0
  33. 0x0000000000400977 <+19>: mov edi,0x0
  34. 0x000000000040097c <+24>: mov eax,0x0
  35. 0x0000000000400981 <+29>: call 0x400590 <ptrace@plt>
  36. 0x0000000000400986 <+34>: test rax,rax
  37. 0x0000000000400989 <+37>: jns 0x400995 <main+49>
  38. 0x000000000040098b <+39>: mov edi,0x0
  39. 0x0000000000400990 <+44>: call 0x4005b0 <exit@plt>
  40. 0x0000000000400995 <+49>: mov eax,0x40077a
  41. 0x000000000040099a <+54>: mov eax,eax
  42. 0x000000000040099c <+56>: mov eax,DWORD PTR [rax]
  43. 0x000000000040099e <+58>: and eax,0xff
  44. 0x00000000004009a3 <+63>: cmp eax,0xcc
  45. 0x00000000004009a8 <+68>: jne 0x4009b4 <main+80>
  46. 0x00000000004009aa <+70>: mov edi,0x0
  47. 0x00000000004009af <+75>: call 0x4005b0 <exit@plt>
  48. 0x00000000004009b4 <+80>: mov eax,0x0
  49. 0x00000000004009b9 <+85>: call 0x400895 <xxxx>
  50. 0x00000000004009be <+90>: mov eax,0x0
  51. 0x00000000004009c3 <+95>: pop rbp
  52. 0x00000000004009c4 <+96>: ret
  53.  
  54. Dans le main, on peut voir qu'un appel à ptrace est effectué, il suffira de set $rax à 0 juste après cet appel
  55. pour bypass l'anti debug.
  56.  
  57. les fonctions du programme sont nommées :
  58.  
  59. -main() (anti debug puis appel à xxxx())
  60. -x() (affichage du premier texte du binaire "banniere")
  61. -xx() (un genre de strlen())
  62. -xxx() (pas appelée, je suis pas allé fouiller)
  63. -xxxx() (apelle x(), puis affiche le prompt suivi d'un scanf(), et apelle xxxxx())
  64. -xxxxx() (fonction qui compare le password entré au pass attendu, et affiche le flag)
  65.  
  66.  
  67. l'idéal est de break sur xxxxx() quand on a bypass le ptrace
  68.  
  69. xxxxx()
  70. ... Some stuff
  71.  
  72. 0x00000000004007c0 <+70>: mov rdi,rax
  73. 0x00000000004007c3 <+73>: call 0x400c10 <base64_decode>
  74. 0x00000000004007c8 <+78>: lea rax,[rbp-0x30]
  75. 0x00000000004007cc <+82>: mov rdx,rax
  76. 0x00000000004007cf <+85>: mov eax,0x400f40
  77. 0x00000000004007d4 <+90>: mov ecx,0x5
  78. 0x00000000004007d9 <+95>: mov rsi,rdx
  79. 0x00000000004007dc <+98>: mov rdi,rax
  80. 0x00000000004007df <+101>: repz cmps BYTE PTR ds:[rsi],BYTE PTR es:[rdi]
  81. ...
  82.  
  83. En suivant les instruction pas à pas
  84. on peut voir que le password attendu doit être en base64, si on continue un peu, on peut voir la comparaison
  85. entre une chaine donnée par le programme, et la chaine entrée par l'utilisateur passée à la fonction base64_decode()
  86.  
  87. repz cmps BYTE PTR ds:[rsi],BYTE PTR es:[rdi] // à ce moment là rdi = "samir" && rsi = base64_decode(user_entry)
  88.  
  89. on en conclus donc que "samir" en base64 est le mot de passe attendu.
  90.  
  91. on essaye :
  92.  
  93. $> echo `python -c "print 'samir'.encode('base64')"`| ./binary
  94. *********************************
  95. welcome to cracking challenge
  96. *********************************
  97. Enter you password: Flag: ping-pong you pasamir
  98.  
  99.  
  100. Et paf , le flag était "ping-pong" .
  101.  
  102. See ya o/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement