Preparing for crackme analysis in Ghidra
Before running the disassembler, spend thirty seconds in the command line. Three utilities can save you from minutes to hours. For more information, see our in-depth analysis of binary vulnerability analysis .
file crackmewill show the file type: ELF 64-bit, PE 32-bit, and processor architecture. This determines which processor module Ghidra will use during import.
strings crackme | grep -i "pass\|correct\|wrong\|try"It will extract all readable lines and filter them by key markers. Based on my experience solving problems on crackmes.one, a surprising number of entry-level crackme problems can be solved with this single command. The password is in plaintext right in the binary. Seriously.
ltrace ./crackme test 2>&1 | grep strcmpwill intercept calls to library functions in real time. If the program uses strcmpto compare the input with the hardcoded password, ltracewill show both arguments: strcmp("test", "real_password")When the compiler inlines strcmp — ltraceHe won't see it. But the check only takes seconds, so there's no point in skipping it.
To work, you need JDK 21+ and Ghidra 11.x - downloadable as a ZIP archive from GitHub ( github.com/NationalSecurityAgency/ghidra/releases), without an installer. Launch: ghidraRunon Linux, ghidraRun.batOn Windows. Minimum 8 GB of RAM—Ghidra runs on top of the JVM and consumes 2–4 GB during automatic analysis. Analyze unfamiliar binaries only in an isolated virtual machine with the network disabled. Even crackme and crackmes.one may contain unexpected payloads—it's better to be safe than sorry.
Import a binary: File → New Project → Non-Shared Project → File → Import File. Ghidra will automatically detect the format (ELF, PE, Mach-O) and architecture. Double-clicking the file will open CodeBrowser, the main working window. When asked "Analyze now?", accept the default options. In a few seconds, automatic analysis will determine function boundaries, build cross-references (XREF), extract text strings, and identify library calls. After that, you're ready to work.
Searching for password verification in Ghidra via strings and XREFs
The key technique for statically analyzing an executable file when working with crackme is to work from strings to code, not the other way around. Text markers ("Wrong password," "Try Again!", "Correct!", "Access Granted") are stored in the binary's data section and are not removed during standard compilation. Even in stripped binaries, where function names are removed ( Stripped Payloads, T1027.008 according to MITRE ATT&CK ), string literals remain intact.
Defined Strings and the transition to the validation function
In CodeBrowser: Window → Defined Strings. This will open a table with all the text strings in the binary. Look for the characteristic markers: "Try Again," "Correct," "Good," "Bad," "Access Denied." Found the string you need? Right-click → References → Show References to Address. Ghidra will display all the addresses from which this string is called—cross-references (XREF). Double-clicking on a link will take you directly to the function that prints the message. This is the password verification function—or the function that calls the verification.
If XREF shows multiple addresses, start with the one closest to the beginning of the function. If the string is used only once, the task is much simpler.
The same principle works in IDA Free (Shift+F12 for lines, X for XREF) and in radare2 version 5.9.8 (commands izfor terms, axt @addr(for cross-referencing). But Ghidra does this for free and comes with a decompiler—IDA Free doesn't have one.
Decompiling a Binary File: Reading Ghidra's Pseudocode
The right panel of CodeBrowser is the Ghidra decompiler. It converts machine code back into pseudocode similar to C. It's not identical to the original, and there are artifacts, but crackme is more than enough for analysis. The main advantage over reading assembly code is that you can see if, for, while, function calls and arithmetic in familiar syntax.
The first thing that catches your eye is the illegible names: local_28, iVar1, DAT_00104020, FUN_00401234Ghidra has no idea what the author named the variables. Renaming is a key skill in working with a decompiler. Right-click on the variable → Rename Variable (or press L). We saw that local_28passed as an argument in strcmp? Rename to user_inputGlobal DAT_00104020contains the text "Enter password:"? Name it prompt_msg. Type undefined8for the return value main— reassign to intvia Retype Variable.
After 5-10 renamings, the pseudocode from the set iVar And DAT_becomes readable. It's as if a layer of noise has been peeled off the page, revealing the program's logic underneath.
Inside the objective function, look for three blocks: receiving input ( scanf, fgets, getsor WinAPI GetDlgItemTextA), input transformation (bitwise operations, subfunction calls, loops) and comparison with a reference ( strcmp, memcmp, byte-by-byte comparison in a loop or conditional jump after cmpin assembler). If between receiving input and comparing there is a call to an unknown function ( FUN_00401234) — double-click on it to make the decompiler show its code. Often, it's in these nested functions that the transformation algorithm is hidden.
Analysis of the serial number verification algorithm
The simplest crackme uses strcmpwith a hardcoded password - these are solved by a command stringsand don't require a keygen. Reverse engineering begins in earnest when the password isn't stored in plaintext: the input is transformed, and the result is compared with the expected value. This is where crackme disassembly shifts from "find a string" to "understand the algorithm."
XOR transformation is the main pattern of crackme
Byte-by-byte XOR with a constant array is the most common verification algorithm in entry-level and intermediate-level crackme. A typical scheme (clearly illustrated by FatMike's CrackMe#1 from crackmes.one): each input character is XORed with an element of a constant array, and the result is compared to a reference array. If it matches, it's "Correct!"; if it doesn't, it's "Try Again!"
Here's what the password comparison function looks like in the Ghidra decompiler after renaming the variables:
// Пример для демонстрации концепции — типичный вывод декомпилятора
void check_serial(char *user_input) {
byte xor_key[] = {0x5f, 0x4a, 0x7d, 0x2b, 0x38, 0x6e};
byte expected[] = {0x3a, 0x2f, 0x1c, 0x4e, 0x5b, 0x0d};
for (int i = 0; i < 6; i++) {
if ((user_input ^ xor_key) != expected) {
puts("Try Again!"); return;
}
}
puts("Key is Correct!");
}
Before the renaming, this same function looks like a wall of uVar2 = bVar1 ^ *(byte *)(iVar3 + iVar4)— this is precisely the point at which most beginners close Ghidra. And they're wrong. Rename four variables, and the logic becomes clear: the input is XORed with the key, and the result is checked against the reference.
How to spot an XOR pattern in unreadable pseudocode: look for the operator ^inside the loop ( for, while, do...while). If in the same cycle there is a comparison ( !=, ==) with conditional return or break— this is a check function with an XOR transformation. Another marker: arrays byte or charfixed-length, initialized with hex values. Ghidra sometimes doesn't recognize them as arrays and displays a series of separate global variables ( DAT_00409480, DAT_00409481, DAT_00409482...). To fix: select the first item in the Listing, press T and set the type byte[N], where N is the array length. After this, the decompiler will begin to correctly display indexed access.
In more complex cracks, a checksum is added to the XOR. The characteristic marker of CRC32 is a constant 0xedb88320(CRC32 polynomial) in one of the called subfunctions. In FatMike's CrackMe#1, the XOR result is checked not byte-by-byte, but via a CRC32 hash: if (crc32(xor_output) == 0x5a6aa47d)with additional checking of the input length ( input_length == 0x16, that is, 22 characters). This crackme is more complex—the keygen must find the input that yields the required CRC32, which requires brute-force testing. But the basic approach remains the same: find the function through the strings, read the pseudocode, and understand the transformation.
There's also an arithmetic variant: each input character is multiplied by a constant, added to the previous result, and the final sum is compared to a standard. Look for operators here. *, +, %in a loop. The recovery principle is the same: write down the formula, apply the inverse operation.
Before running the disassembler, spend thirty seconds in the command line. Three utilities can save you from minutes to hours. For more information, see our in-depth analysis of binary vulnerability analysis .
file crackmewill show the file type: ELF 64-bit, PE 32-bit, and processor architecture. This determines which processor module Ghidra will use during import.
strings crackme | grep -i "pass\|correct\|wrong\|try"It will extract all readable lines and filter them by key markers. Based on my experience solving problems on crackmes.one, a surprising number of entry-level crackme problems can be solved with this single command. The password is in plaintext right in the binary. Seriously.
ltrace ./crackme test 2>&1 | grep strcmpwill intercept calls to library functions in real time. If the program uses strcmpto compare the input with the hardcoded password, ltracewill show both arguments: strcmp("test", "real_password")When the compiler inlines strcmp — ltraceHe won't see it. But the check only takes seconds, so there's no point in skipping it.
To work, you need JDK 21+ and Ghidra 11.x - downloadable as a ZIP archive from GitHub ( github.com/NationalSecurityAgency/ghidra/releases), without an installer. Launch: ghidraRunon Linux, ghidraRun.batOn Windows. Minimum 8 GB of RAM—Ghidra runs on top of the JVM and consumes 2–4 GB during automatic analysis. Analyze unfamiliar binaries only in an isolated virtual machine with the network disabled. Even crackme and crackmes.one may contain unexpected payloads—it's better to be safe than sorry.
Import a binary: File → New Project → Non-Shared Project → File → Import File. Ghidra will automatically detect the format (ELF, PE, Mach-O) and architecture. Double-clicking the file will open CodeBrowser, the main working window. When asked "Analyze now?", accept the default options. In a few seconds, automatic analysis will determine function boundaries, build cross-references (XREF), extract text strings, and identify library calls. After that, you're ready to work.
Searching for password verification in Ghidra via strings and XREFs
The key technique for statically analyzing an executable file when working with crackme is to work from strings to code, not the other way around. Text markers ("Wrong password," "Try Again!", "Correct!", "Access Granted") are stored in the binary's data section and are not removed during standard compilation. Even in stripped binaries, where function names are removed ( Stripped Payloads, T1027.008 according to MITRE ATT&CK ), string literals remain intact.
Defined Strings and the transition to the validation function
In CodeBrowser: Window → Defined Strings. This will open a table with all the text strings in the binary. Look for the characteristic markers: "Try Again," "Correct," "Good," "Bad," "Access Denied." Found the string you need? Right-click → References → Show References to Address. Ghidra will display all the addresses from which this string is called—cross-references (XREF). Double-clicking on a link will take you directly to the function that prints the message. This is the password verification function—or the function that calls the verification.
If XREF shows multiple addresses, start with the one closest to the beginning of the function. If the string is used only once, the task is much simpler.
The same principle works in IDA Free (Shift+F12 for lines, X for XREF) and in radare2 version 5.9.8 (commands izfor terms, axt @addr(for cross-referencing). But Ghidra does this for free and comes with a decompiler—IDA Free doesn't have one.
Decompiling a Binary File: Reading Ghidra's Pseudocode
The right panel of CodeBrowser is the Ghidra decompiler. It converts machine code back into pseudocode similar to C. It's not identical to the original, and there are artifacts, but crackme is more than enough for analysis. The main advantage over reading assembly code is that you can see if, for, while, function calls and arithmetic in familiar syntax.
The first thing that catches your eye is the illegible names: local_28, iVar1, DAT_00104020, FUN_00401234Ghidra has no idea what the author named the variables. Renaming is a key skill in working with a decompiler. Right-click on the variable → Rename Variable (or press L). We saw that local_28passed as an argument in strcmp? Rename to user_inputGlobal DAT_00104020contains the text "Enter password:"? Name it prompt_msg. Type undefined8for the return value main— reassign to intvia Retype Variable.
After 5-10 renamings, the pseudocode from the set iVar And DAT_becomes readable. It's as if a layer of noise has been peeled off the page, revealing the program's logic underneath.
Inside the objective function, look for three blocks: receiving input ( scanf, fgets, getsor WinAPI GetDlgItemTextA), input transformation (bitwise operations, subfunction calls, loops) and comparison with a reference ( strcmp, memcmp, byte-by-byte comparison in a loop or conditional jump after cmpin assembler). If between receiving input and comparing there is a call to an unknown function ( FUN_00401234) — double-click on it to make the decompiler show its code. Often, it's in these nested functions that the transformation algorithm is hidden.
Analysis of the serial number verification algorithm
The simplest crackme uses strcmpwith a hardcoded password - these are solved by a command stringsand don't require a keygen. Reverse engineering begins in earnest when the password isn't stored in plaintext: the input is transformed, and the result is compared with the expected value. This is where crackme disassembly shifts from "find a string" to "understand the algorithm."
XOR transformation is the main pattern of crackme
Byte-by-byte XOR with a constant array is the most common verification algorithm in entry-level and intermediate-level crackme. A typical scheme (clearly illustrated by FatMike's CrackMe#1 from crackmes.one): each input character is XORed with an element of a constant array, and the result is compared to a reference array. If it matches, it's "Correct!"; if it doesn't, it's "Try Again!"
Here's what the password comparison function looks like in the Ghidra decompiler after renaming the variables:
// Пример для демонстрации концепции — типичный вывод декомпилятора
void check_serial(char *user_input) {
byte xor_key[] = {0x5f, 0x4a, 0x7d, 0x2b, 0x38, 0x6e};
byte expected[] = {0x3a, 0x2f, 0x1c, 0x4e, 0x5b, 0x0d};
for (int i = 0; i < 6; i++) {
if ((user_input ^ xor_key) != expected) {
puts("Try Again!"); return;
}
}
puts("Key is Correct!");
}
Before the renaming, this same function looks like a wall of uVar2 = bVar1 ^ *(byte *)(iVar3 + iVar4)— this is precisely the point at which most beginners close Ghidra. And they're wrong. Rename four variables, and the logic becomes clear: the input is XORed with the key, and the result is checked against the reference.
How to spot an XOR pattern in unreadable pseudocode: look for the operator ^inside the loop ( for, while, do...while). If in the same cycle there is a comparison ( !=, ==) with conditional return or break— this is a check function with an XOR transformation. Another marker: arrays byte or charfixed-length, initialized with hex values. Ghidra sometimes doesn't recognize them as arrays and displays a series of separate global variables ( DAT_00409480, DAT_00409481, DAT_00409482...). To fix: select the first item in the Listing, press T and set the type byte[N], where N is the array length. After this, the decompiler will begin to correctly display indexed access.
In more complex cracks, a checksum is added to the XOR. The characteristic marker of CRC32 is a constant 0xedb88320(CRC32 polynomial) in one of the called subfunctions. In FatMike's CrackMe#1, the XOR result is checked not byte-by-byte, but via a CRC32 hash: if (crc32(xor_output) == 0x5a6aa47d)with additional checking of the input length ( input_length == 0x16, that is, 22 characters). This crackme is more complex—the keygen must find the input that yields the required CRC32, which requires brute-force testing. But the basic approach remains the same: find the function through the strings, read the pseudocode, and understand the transformation.
There's also an arithmetic variant: each input character is multiplied by a constant, added to the previous result, and the final sum is compared to a standard. Look for operators here. *, +, %in a loop. The recovery principle is the same: write down the formula, apply the inverse operation.