A reverse-engineering exercise: analyzing a compiled C binary using objdump,
understanding its checksum-based password validation, and writing a keygen
that generates valid passwords.
101-crackme— the compiled binary to crack101-keygen.c— generates random valid passwords for101-crackme
The binary checks command-line input against a hidden algorithm:
long checksum(char *s)
{
long sum = 0;
while (*s != '\0')
{
sum += *s;
s++;
}
return (sum);
}It sums the ASCII values of every character in the input and compares the
result to 0xad4 (2772). If they match, it prints Tada! Congrats.
This was reverse-engineered using:
stringsto locate key string literalsobjdump -d -Mintelto disassemblemainandchecksum- Tracing register usage, stack frames, and the x86-64 calling convention
Compile the keygen:
gcc -Wall -pedantic -Werror -Wextra -std=gnu89 101-keygen.c -o 101-keygenGenerate a valid password and crack the binary:
./101-crackme "$(./101-keygen)"Expected output on success:
Tada! Congrats
Full breakdown of the reverse-engineering process: [https://m0ng00s3-blog.hashnode.dev/solving-a-simple-crackme]
- x86-64 assembly analysis
- Reverse engineering with
objdumpandstrings - C programming (low-level memory and pointer manipulation)
- Understanding stack frames and calling conventions