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.

mov DWORD PTR _a$[ebp+edx*4], ecx<br />

jmp SHORT $LN2@main<br />

$LN1@main:<br />

mov eax, DWORD PTR _a$[ebp+400]<br />

push eax<br />

push OFFSET $SG2460<br />

call _printf<br />

add esp, 8<br />

xor eax, eax<br />

mov esp, ebp<br />

pop ebp<br />

ret 0<br />

_main ENDP<br />

I’m running it, and I got:<br />

a[100]=760826203<br />

It is just something, lying in the stack near <strong>to</strong> array, 400 bytes from its first element.<br />

Indeed, how it could be done differently? Compiler may incorporate some code, checking index value<br />

<strong>to</strong> be always in array’s bound, like in higher-level programming languages 39 , but this makes running code<br />

slower.<br />

OK, we read some values in stack illegally, but what if we could write something <strong>to</strong> it?<br />

Here is what we will write:<br />

#include <br />

int main()<br />

{<br />

int a[20];<br />

int i;<br />

};<br />

<strong>for</strong> (i=0; i

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

Saved successfully!

Ooh no, something went wrong!