Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [X] CairoSecurityCamp CTF 2014 WriteUp (ELF1)
- [X] Author : fr0g
- [X] Main : fr0g.security@gmail.com
- [X] Greet'z : SaxX, NotFound, All Hexpresso team members
- MD5SUM : 1299439f81e7d3bd5d32274dc2c44233
- On passe le binaire à la commande file, on voit qu'il n'est pas stripped
- $> file binary
- 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
- Première execution :
- $> ./binary
- *********************************
- welcome to cracking challenge
- *********************************
- Enter you password: toto
- $>
- On le lance avec gdb, on break sur main, et c'est parti :)
- 0x0000000000400964 <+0>: push rbp
- 0x0000000000400965 <+1>: mov rbp,rsp
- 0x0000000000400968 <+4>: mov ecx,0x0
- 0x000000000040096d <+9>: mov edx,0x1
- 0x0000000000400972 <+14>: mov esi,0x0
- 0x0000000000400977 <+19>: mov edi,0x0
- 0x000000000040097c <+24>: mov eax,0x0
- 0x0000000000400981 <+29>: call 0x400590 <ptrace@plt>
- 0x0000000000400986 <+34>: test rax,rax
- 0x0000000000400989 <+37>: jns 0x400995 <main+49>
- 0x000000000040098b <+39>: mov edi,0x0
- 0x0000000000400990 <+44>: call 0x4005b0 <exit@plt>
- 0x0000000000400995 <+49>: mov eax,0x40077a
- 0x000000000040099a <+54>: mov eax,eax
- 0x000000000040099c <+56>: mov eax,DWORD PTR [rax]
- 0x000000000040099e <+58>: and eax,0xff
- 0x00000000004009a3 <+63>: cmp eax,0xcc
- 0x00000000004009a8 <+68>: jne 0x4009b4 <main+80>
- 0x00000000004009aa <+70>: mov edi,0x0
- 0x00000000004009af <+75>: call 0x4005b0 <exit@plt>
- 0x00000000004009b4 <+80>: mov eax,0x0
- 0x00000000004009b9 <+85>: call 0x400895 <xxxx>
- 0x00000000004009be <+90>: mov eax,0x0
- 0x00000000004009c3 <+95>: pop rbp
- 0x00000000004009c4 <+96>: ret
- Dans le main, on peut voir qu'un appel à ptrace est effectué, il suffira de set $rax à 0 juste après cet appel
- pour bypass l'anti debug.
- les fonctions du programme sont nommées :
- -main() (anti debug puis appel à xxxx())
- -x() (affichage du premier texte du binaire "banniere")
- -xx() (un genre de strlen())
- -xxx() (pas appelée, je suis pas allé fouiller)
- -xxxx() (apelle x(), puis affiche le prompt suivi d'un scanf(), et apelle xxxxx())
- -xxxxx() (fonction qui compare le password entré au pass attendu, et affiche le flag)
- l'idéal est de break sur xxxxx() quand on a bypass le ptrace
- xxxxx()
- ... Some stuff
- 0x00000000004007c0 <+70>: mov rdi,rax
- 0x00000000004007c3 <+73>: call 0x400c10 <base64_decode>
- 0x00000000004007c8 <+78>: lea rax,[rbp-0x30]
- 0x00000000004007cc <+82>: mov rdx,rax
- 0x00000000004007cf <+85>: mov eax,0x400f40
- 0x00000000004007d4 <+90>: mov ecx,0x5
- 0x00000000004007d9 <+95>: mov rsi,rdx
- 0x00000000004007dc <+98>: mov rdi,rax
- 0x00000000004007df <+101>: repz cmps BYTE PTR ds:[rsi],BYTE PTR es:[rdi]
- ...
- En suivant les instruction pas à pas
- on peut voir que le password attendu doit être en base64, si on continue un peu, on peut voir la comparaison
- entre une chaine donnée par le programme, et la chaine entrée par l'utilisateur passée à la fonction base64_decode()
- repz cmps BYTE PTR ds:[rsi],BYTE PTR es:[rdi] // à ce moment là rdi = "samir" && rsi = base64_decode(user_entry)
- on en conclus donc que "samir" en base64 est le mot de passe attendu.
- on essaye :
- $> echo `python -c "print 'samir'.encode('base64')"`| ./binary
- *********************************
- welcome to cracking challenge
- *********************************
- Enter you password: Flag: ping-pong you pasamir
- Et paf , le flag était "ping-pong" .
- See ya o/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement