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.

4.2 Middle level<br />

4.2.1 Task 2.1<br />

Well-known algorithm, also included in standard C library. Source code was taken from glibc 2.11.1. Compiled<br />

in GCC 4.4.1 with -Os option (code size optimization). Listing was done by IDA 4.9 disassembler from<br />

ELF-file generated by GCC and linker.<br />

For those who wants use IDA while learning, here you may find .elf and .idb files, .idb can be opened<br />

with freeware IDA 4.9:<br />

http://conus.info/RE-tasks/middle/1/<br />

f proc near<br />

var_150 = dword ptr -150h<br />

var_14C = dword ptr -14Ch<br />

var_13C = dword ptr -13Ch<br />

var_138 = dword ptr -138h<br />

var_134 = dword ptr -134h<br />

var_130 = dword ptr -130h<br />

var_128 = dword ptr -128h<br />

var_124 = dword ptr -124h<br />

var_120 = dword ptr -120h<br />

var_11C = dword ptr -11Ch<br />

var_118 = dword ptr -118h<br />

var_114 = dword ptr -114h<br />

var_110 = dword ptr -110h<br />

var_C = dword ptr -0Ch<br />

arg_0 = dword ptr 8<br />

arg_4 = dword ptr 0Ch<br />

arg_8 = dword ptr 10h<br />

arg_C = dword ptr 14h<br />

arg_10 = dword ptr 18h<br />

push ebp<br />

mov ebp, esp<br />

push edi<br />

push esi<br />

push ebx<br />

sub esp, 14Ch<br />

mov ebx, [ebp+arg_8]<br />

cmp [ebp+arg_4], 0<br />

jz loc_804877D<br />

cmp [ebp+arg_4], 4<br />

lea eax, ds:0[ebx*4]<br />

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

jbe loc_804864C<br />

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

mov ecx, ebx<br />

mov esi, [ebp+arg_0]<br />

lea edx, [ebp+var_110]<br />

neg ecx<br />

mov [ebp+var_118], 0<br />

mov [ebp+var_114], 0<br />

dec eax<br />

imul eax, ebx<br />

137

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

Saved successfully!

Ooh no, something went wrong!