23.03.2013 Views

Quick introduction to reverse engineering for beginners

Quick introduction to reverse engineering for beginners

Quick introduction to reverse engineering for beginners

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

push edx<br />

xor edi, edi<br />

call _isdigit<br />

add esp, 4<br />

test eax, eax<br />

je SHORT $LN2@f<br />

$LL3@f:<br />

mov ecx, DWORD PTR [esi]<br />

mov edx, DWORD PTR [esi+4]<br />

add esi, 4<br />

lea eax, DWORD PTR [edi+edi*4]<br />

push edx<br />

lea edi, DWORD PTR [ecx+eax*2-48]<br />

call _isdigit<br />

add esp, 4<br />

test eax, eax<br />

jne SHORT $LL3@f<br />

$LN2@f:<br />

cmp bl, 45 ; 0000002dH<br />

jne SHORT $LN14@f<br />

neg edi<br />

$LN14@f:<br />

mov eax, edi<br />

pop edi<br />

pop esi<br />

pop ebx<br />

ret 0<br />

_f ENDP<br />

_TEXT ENDS<br />

Same code compiled in GCC 4.4.1. This task is sligthly harder because GCC compiled isspace() and<br />

isdigit() functions like inline-functions and inserted their bodies right in<strong>to</strong> code.<br />

_f proc near<br />

var_10 = dword ptr -10h<br />

var_9 = byte ptr -9<br />

input = dword ptr 8<br />

loc_804840C:<br />

loc_8048410:<br />

push ebp<br />

mov ebp, esp<br />

sub esp, 18h<br />

jmp short loc_8048410<br />

add [ebp+input], 4<br />

call ___ctype_b_loc<br />

mov edx, [eax]<br />

mov eax, [ebp+input]<br />

mov eax, [eax]<br />

add eax, eax<br />

lea eax, [edx+eax]<br />

movzx eax, word ptr [eax]<br />

movzx eax, ax<br />

126

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!