CSCAMP 2014 PE100 (n°2) WriteUp

Download | Vote Up (0) | Vote Down (0)

[X] CairoSecurityCamp CTF 2014 PE-2(100) WriteUp
[X] Author : fr0g (Hexpressso 2014)
[X] Greetz : SaxX, NotFound, all HWC && Hexpresso members

A la première execution, on voit que le programme nous demande un password,

C:\Users\fr0g\Desktop\binary-pe.exe
enter the key : toto

C:\Users\fr0g\Desktop\binary-pe.exe

Dans une analyse avec Olly, on va aller trouver la string "enter the key: " dans les StrDataRef, en suivant l'utilisation
de cette chaine dans le code, on tombe évidemment sur le prompt demandant le password à l'utilisateur

CPU Disasm
Address Hex dump Command Comments
0040140B |. C74424 04 714 .MOV DWORD PTR SS:[LOCAL.9],OFFSET 00474 ; ASCII "enter the key: "
00401413 |. C70424 802F47 .MOV DWORD PTR SS:[LOCAL.10],OFFSET 0047
0040141A |. E8 25480600 .CALL 00465C44

Quelques lignes plus bas, nous pouvons voir ceci :

004014A6 8B45 08 .MOV EAX,DWORD PTR SS:[EBP+8] // contient le password de l'utilisateur en int
004014A9 3B45 0C CMP EAX,DWORD PTR SS:[EBP+0C]
004014AC 75 34 JNE SHORT 004014E2
004014AE |. C74424 04 814 MOV DWORD PTR SS:[LOCAL.9],OFFSET 00474 ; ASCII "Flag: "
004014B6 |. C70424 802F47 MOV DWORD PTR SS:[LOCAL.10],OFFSET 0047
004014BD |. E8 82470600 CALL 00465C44 // c'est ici que le flag va s'afficher

Lançons le debug en posant un breakpoint sur le cmp juste avant

(004014A9 3B45 0C CMP EAX,DWORD PTR SS:[EBP+0C])

Nous pouvons nous rendre compte qu'en rentrant une chaine de caractère comme password,
DWORD PTR SS:[EBP+8] contient 0, si on entre un nombre, il contiendra ce nombre.

une fois notre breakpoint atteint, on clique droit sur DWORD PTR SS:[EBP+0C] (follow in dump, memory address),
et on tombe sur le bon password (entre crochets dans l'exemple):

CPU Dump
Address Hex dump
0028FF04 [37 FB 13 00]

donc,: 37 FB 13 00, en respectant l'endiannes, ça nous donne 0x13fb37, 1309495 en décimal

C:\Users\fr0g\Desktop\binary-pe.exe
enter the key : 1309495
Flag: 1309495

C:\Users\fr0g\Desktop\binary-pe.exe

Done .

fr0g


Be the first to give feedback !

Please login to comment !