WEEK 4: DEBUGGING AND UNPACKING
1. Introduction to Debuggers (x64dbg / OllyDbg)
- Debuggers allow step-by-step execution of programs.
- View CPU instructions, memory, registers, and stack.
2. Setting Breakpoints & Stepping Through Code
- Breakpoints pause execution at specific instructions.
- Step Into (F7), Step Over (F8), Run to Cursor (F4) are common commands.
3. Function Tracing and Argument Inspection
- Follow function calls and monitor arguments passed.
- Useful for analyzing system calls and API usage.
4. Identifying Unpacking Stubs
- Packed malware typically unpacks itself in memory.
- Look for jumps to writable memory or memory allocations (VirtualAlloc).
5. Manual Unpacking of UPX-Packed Binaries
- UPX: Open-source packer; easily unpacked.
- Methods:
* Use "upx -d" if not modified.
* Debug and dump memory after unpacking stub executes.
6. Malware Behavior Tracing
- Process Hollowing: Legit process launched, then hollowed and injected with malicious code.
- DLL Injection: Injecting a DLL into another process's address space.
7. Anti-Debugging and Anti-VM Techniques
- Detecting debuggers: Using IsDebuggerPresent, timing attacks.
- VM detection: MAC address, registry checks, special drivers.
8. Hands-on Activity
- Load packed malware into x64dbg.
- Set breakpoints, identify unpacking stub.
- Dump and analyze unpacked binary using PEStudio or Ghidra.