13.x — Chapter 13 summary and quiz
Quick review#
- Reverse engineering works out how a program works without its source code. Only do it on things you're allowed to.
- A program file has sections: code in
.text, text and constants in.rodata/.rdata. - Registers are the CPU's tiny fast variables.
eax/raxholds return values. On Linux, arguments arrive inrdi,rsi,rdx... ifbecomescmp/test+ a conditional jump. A jump backwards is usually a loop.- Struct members are offsets like
[rdi+8]. Virtual calls go through a vtable. - Tools:
strings, Ghidra (static), x64dbg / gdb (dynamic). - Practise on crackmes and CTFs, inside a virtual machine.
Pick an answer. You find out right away if it is right.
In mov eax, edi (Intel syntax), where does the value go?
In Intel syntax, the left side is the destination. Read it as eax = edi.
A function returns an int. Which register usually holds the answer on x86-64?
Return values come back in eax (or rax for 64-bit values), on both Linux and Windows.
Which of these is fine to reverse engineer?
Crackmes are made to be reversed. The others break licences, laws, or other people's trust.
What does this assembly function do? Write it as a C++ function.
mystery(int): lea eax, [rdi+rdi*2] retIt returns its argument times 3 (x + x*2):
int mystery(int x){ return x * 3;}Compilers love lea for small multiplications because it's fast.
You see this inside a function. What C++ does it probably come from?
mov eax, DWORD PTR [rdi+4] add eax, DWORD PTR [rdi+8] retrdi is a pointer or reference to a struct. It returns the member at offset 4 plus the member at offset 8. For example:
struct Box{ int a; // offset 0 int b; // offset 4 int c; // offset 8}; int sumBC(const Box& box){ return box.b + box.c;}Your level 1 crackme was cracked with strings in one second. Name two ways the level 2 version makes that harder.
- The password is stored scrambled (XOR-ed), so it doesn't appear as readable text.
- The check is in its own function with a loop, so you have to read the code (in Ghidra or a debugger) to understand how to unscramble it.
Tip: press ← / → to move between lessons, / to search.