This cheat sheet outlines tips for reversing malicious Windows executables via static and dynamic code analysis with the help of a debugger and a disassembler. To print it, use the one-page PDF version; you can also edit the Word version to customize it for you own needs.
Overview of the Code Analysis Process
Examine static properties of the Windows executable for initial assessment and triage.
Identify strings and API calls that highlight the program’s suspicious or malicious capabilities.
Perform automated and manual behavioral analysis to gather additional details.
Emulate code execution to identify characteristics and areas for further analysis.
Use a disassembler and decompiler to statically examine code related to risky strings and APIs calls.
Use a debugger for dynamic analysis to examine how risky strings and API calls are used.
If appropriate, unpack the code and its artifacts.
As your understanding of the code increases, add comments, labels; rename functions, variables.
Progress to examine the code that references or depends upon the code you’ve already analyzed.
Repeat steps 5-9 above as necessary (the order may vary) until analysis objectives are met.
Common 32-Bit Registers and Uses
EAX
Addition, multiplication, function results
ECX
Counter; used by LOOP and others
EBP
Baseline/frame pointer for referencing function arguments (EBP+offset) and local variables (EBP-offset)
ESP
Points to the current “top” of the stack; changes via PUSH, POP, and others
EIP
Instruction pointer; points to the next instruction; shellcode gets it via call/pop
EFLAGS
Contains flags that store outcomes of computations (e.g., Zero and Carry flags)
FS
F segment register; FS:[0] points to SEH chain, FS:[0x30] points to the PEB.
Common x86 Assembly Instructions
mov EAX,0xB8
Put the value 0xB8 in EAX.
push EAX
Put EAX contents on the stack.
pop EAX
Remove contents from top of the stack and put them in EAX .
lea EAX,[EBP-4]
Put the address of variable EBP-4 in EAX.
call EAX
Call the function whose address resides in the EAX register.
add esp,8
Increase ESP by 8 to shrink the stack by two 4-byte arguments.
sub esp,0x54
Shift ESP by 0x54 to make room on the stack for local variable(s).
xor EAX,EAX
Set EAX contents to zero.
test EAX,EAX
Check whether EAX contains zero, set the appropriate EFLAGS bits.
cmp EAX,0xB8
Compare EAX to 0xB8, set the appropriate EFLAGS bits.
Understanding 64-Bit Registers
EAX→RAX, ECX→RCX, EBX→RBX, ESP→RSP, EIP→RIP
Additional 64-bit registers are R8-R15.
RSP is often used to access stack arguments and local variables, instead of EBP.
I transform ideas into successful outcomes, building on my 25 years of experience in cybersecurity. As the CISO at Axonius, I lead the security program to earn customers' trust. I'm also a Faculty Fellow at SANS Institute, where I author and deliver training for incident responders. The diversity of cybersecurity roles I've held over the years and the accumulated expertise, allow me to create practical solutions that drive business growth.