← home

def: analyzing software, understanding its structure, functionality, behavior, etc. Important for malware analysis, software security auditing, understanding proprietary protocols, cyber forensics, etc.

Note that there exists different reverse engineering techniques for different langagues. Some languages include C/C++, Java, .NET, Assembler, etc. Some platforms inlcude DOS, MacOS X, Unix/Linux, Windows, etc.

Resources

Definitions

Making ASM

making the assembly file/executable: c->asm: gcc -S [file] c->asm w/o fluff: gcc -S -O2 -fno-asynchronous-unwind-tables [file] c->executable: gcc [file] -no-pie -o [filename]

once we have the assembly file, assemble to an executable: asm->executable: as [file].s -o [file].o

and link it: gcc [file].o -o [file]

and execute: ./[file]

Tools

GDB

Breakpoints

Apple (of app people, wtf) has a nice guide: developer.apple.com/library/archive/documentation/DeveloperTools/gdb/gdb/gdb_6.html

Note because linux has Address space layout randomization, if you want to set a specific memory address you'll prob have to disable ASLR via echo 0 | sudo tee /proc/sys/kernel/randomize_va_space

Observing Stuff

Because GDB is the goat, we can step through the program with it, check out memory addresses, etc.

C->ASM

Each structure in C has a certain "mirror" structure in assembly.

(note, this section is generally in intel assembly)

For loop

for (int i = 1, i < 10, i++){ // do something }

will have the structure: // add items to stack mov addr1, i (1) mov addr2, 10

// compare operation cmp addr2, 0xa # note how this is one more than 10 in hexadecimal

// conditional jump after the loop jg some addr after loop

// "do something"

// do the increment condition add addr1, 0x1

// jump back to compare operation jmp to compare

If you're trying to emulate some for loop in python, they have automatic hexadecimal conversion. That is, if you type "0xe" python will spit out 14:

>>> 0xe
14

So you can do something like:

for i in range(0x1, 0xa) : # do something
← home