ReverseEngineering basic
Assembly Language
Look for ELF
control + z = stop processing with terminal
Terminology
- nasm -f elf32 firstAsmStripped.asm
- nasm -f elf32 -g -F dwarf firstAsmStripped.asm
- ld -m elf_i386 firstAsmStripped.o -o firstAsmStripped
- kdbg firstAsmStripped &
Debugging mode
- readily -a firstAsmStripped
- MAC -> nasm -f macho64 64.asm
- MAC -> ld -macosx_version_min 10.7.0 -lSystem -o 64 64.o
Reverse Engineering
Terminology
- nasm -f elf test.asm
- f is indicating format
- ld -m elf_i386 -o test test.o
- m is how to link to create a binary file ( 32 bit, 64 bit, …)
- o is output file
- xxd test.asm
- To see hexadecimal information of object file
- Also can be used for xxd test.o
The beginning of file looks like
- What type of this file? elf? OS has to know this.
- What is this program?
- It is interpreted into hex values
- Step away from binary(we need one more step)
- objdump - M intel -d test.o(UBUNTU) == objdump -source test.o(MAC)
- ld is the last command to make it binary file but can not be run on mac(32bit)
The difference between compiler made code and handmade .asm
- assembly file
- we know how it is going
- compiler wrote file(gcc maybe)
- machine are creating code that not friendly to humans
- they create prologue & epilogue
- they adjust the stack -> you can successfully return to the original value
- What’s the stack?
Reviewing terminology
- What security protection does DEP/NX offer?
- Data Execution Prevention / Non Execution.
- What security protection does ASLR offer?
- Adress Space Layout Randomization
- Randomly loads program in the memory
- What are stack canaries and what security protection do they offer
- secret values put on stack
- 0xDEADBEEF (Stack canaries)
- If it does not match with stack when you start program
- it makes crash.
- What is SEH and what does it do?
- Structure exception handling
- Mostly windows thing. Structure contains exception
- Will go look up SEH if there is no user entry, exception handler execute that.
- What is SUID and what does it do?
- Set User I D
- Mostly Unix/Linux term
- Let you attach permission to binary
- But not actually give user root permision
- Kind of bad idea.
- What does BOF stand for? What are 2 common types of BOFs?
- Buffer overflow
- Stack and heap
- What is ROP?
- Return Oriented Programming
- Searching for gadget somehow manipulate memory or register and returns
- Method of programming
- What are ROP Gadgets?
- Assembly instructions
- Briefly describe what shellcode is
- Part of the program that does the work
- Functionality what your exploit does
- What is an egg in computer security terms? Why would you use an egg?
- Unique Identifier to mark memory somehow
- You will find BOF, but it only contains 50 bytes of memory. What would i do is replace it to egg.
- What is an egg hunter?
- Very small chunk of code to find egg in memory.