Linux-Binary-Exploitation

C Compilation Process & ASM Tutorial Made By Myself For Binary Exploitation (Reverse Engineering)

How CPU works

(32-bit (IA-32) - 64-bit (x86-64))
  1. CPU-Registers
  2. Arithmetic Instructions (Intel syntax)
  3. Examples of Control-Flow Instructions(if-while-for)
  4. Little-Endian Format
  5. Function prologue and epilogue
  6. Memory Layout of an ELF
  7. Useful Tools For Static Binary Analysis
  8. Stack Buffer Overflow
  9. Binary-Protection-Flags
  10. Static-Binary-Analyze-Tools

Program Build Flow

Program-Build-Flow

Useful Compile Commands

Compile Assembly using NASM
----------------------------
nasm -f elf32 <file.asm> -o <file.o> && ld -m elf_i386 <file.o> -o <file>


Compile C to 64bit ELF using gcc
--------------------------------
gcc <file.c> -o <file>


Compile C to 32bit ELF using gcc
--------------------------------
sudo apt install libc6-dev-i386
gcc <file.c> -m32 -o <file>


Compile C to 32bit (all protection disabled) ELF using gcc
-------------------------------------------
sudo bash -c 'echo 0 > /proc/sys/kernel/randomize_va_space'
gcc -fno-stack-protector -z execstack -fno-pie -m32 -O0 <file.c> -o <file>