Step-by-step recipes
Size up an unknown file
Section titled “Size up an unknown file”- Open it. Read the yellow banner first, if there is one.
- On the Overview, copy the SHA-256 and look it up if you want to know whether it is already known.
- Read What it can do. Note anything unusual for the kind of program it claims to be.
- Read Text worth a look. Web addresses, commands and registry keys are the best leads.
- Check Hidden text.
- Glance at the Sections tab. Scores near 8 on a code section mean packing.
Find where a piece of text is used
Section titled “Find where a piece of text is used”- Open the Text tab and filter for part of the text.
- Click it. The details panel lists every place that uses it.
- Click a place. You land on the instruction that loads the text.
- Read around it. The code just before decides whether this text is used; the code just after uses it.
Find where a program does something
Section titled “Find where a program does something”For example, where it connects to the network.
- Open the Imports tab and filter for a likely function, such as
connectorInternetOpen. - Click it and look at the list of uses.
- Open one. You are now in the function that makes the call.
- Switch to the Calls view to see who calls that function, and work upwards until you understand when and why it runs.
Find a password check
Section titled “Find a password check”- In the Text tab, find the message shown for a wrong password.
- Click it, then click its use. You are in the code that reports failure.
- Look just above for a
cmportestfollowed by a jump. That is the decision. - Work out what is compared. One side came from what was typed. The other is the answer, or is worked out from the input.
- If the decision is made by a call to another function, open that function and repeat.
The Study guide’s chapter 9 walks through this in full, on the practice file First sip.
Understand a function
Section titled “Understand a function”- Start in the C code view for the overall shape.
- Use the Graph view to see the branches and loops.
- Open the Calls view. The Windows functions it calls often explain it.
- Read the assembly only for the lines that matter.
- Rename the function as soon as you have a guess.
Linux programs (ELF) and CTF challenges
Section titled “Linux programs (ELF) and CTF challenges”Open the file like any other. Things that work differently from Windows programs:
- Function names. Unless the file was stripped, every function keeps its real name (
main,check_flag,win). Start with the Functions tab filtered by a word likeflag,checkorwin. mainis found even when stripped. Linux programs start in_start, which handsmainto__libc_start_main. Karak Studio reads that and namesmainfor you, so a stripped file still has an obvious place to begin.- Library calls go through small stubs (the PLT) and show under the library function’s name:
puts,printf,strcmp. About 150 common C library and Linux functions are known, with argument names and well-known numbers named:mmap(0, 0x1000, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0),ptrace(PTRACE_TRACEME, 0, 0, 0),write(STDOUT_FILENO, buf, n). - Direct system calls (
syscall,int 0x80), common in small challenges and shellcode, are shown by name:sys_write(STDOUT_FILENO, "hi", 2),sys_execve(...). - Arguments follow Linux’s rules: 64-bit programs pass them in
rdi, rsi, rdx, rcx, r8, r9; 32-bit programs push them all. - Hand-written assembly labels such as
_startandloopname the functions they start. - Addresses. A position-independent (PIE) file has no fixed address, and its numbers start at 0. Karak Studio moves it up by
0x100000(64-bit) or0x10000(32-bit), the same as Ghidra, so small numbers in the code are not mistaken for addresses. Subtract that amount to compare withobjdump,readelforgdb(gdb shows its own random address while running). - Capabilities on the Overview also cover Linux: starting programs (
execve,system), anti-debugging (ptrace), reverse shells (dup2), and reading input with no length limit (gets,scanf), the usual start of an exploitation challenge. - UPX-packed Linux programs are detected but not unpacked. On Linux, make a copy and run
upx -don it, then open the copy.upx -dunpacks without running the program.
A typical first five minutes with a CTF binary:
- Read the Protections card, which tells you which exploitation tricks are possible.
- Open
mainin the C code view and follow where your input goes (fgets,scanf,read). - Double-click the function that checks it.
- Look in the Text tab for the messages (“Correct”, “flag”, “Wrong”) and see where they are used.
- For a crackme, work out what input passes the check; for a pwn challenge, look for a buffer that can be overflowed.
Save a listing
Section titled “Save a listing”Press Save as .asm. Choose where to save. The whole program is written as one text file with function names, jump labels and comments. It is for reading and searching in an editor. It cannot be assembled back into a program.