A Crackme on the Course's Own Toy: Find the Check, Then Fix It
A crackme is a small program written to be reverse engineered: it asks for a key, and the exercise is to find out what it accepts. CTFs and training sites use them because they combine everything in this course in one small target. Here the crackmes are the course's own toys, written in this lesson, and the exercise doesn't stop at "found it": the second half is the developer's side, how the check should have been written, because the lesson of every crackme is the same: a secret hidden in a program you give away is not a secret.
Scope. Both binaries are compiled from the source printed below, in your sandbox. The techniques are for your own programs and authorised assessments; using them to bypass the licence checks of software you don't own is a breach of its licence and, in many countries, of anti-circumvention law (introduction).
Level 1: a hard-coded key
The session writes the toy, compiles it, and then plays the analyst who only has the binary. Four tools, four ways to the same answer.
cat > crackme1.c <<'SRC'
#include <stdio.h>
#include <string.h>
static int check_key(const char *k) { return strcmp(k, "TAD-LAB-4242") == 0; }
int main(int argc, char **argv) {
if (argc < 2) { puts("usage: crackme1 KEY"); return 2; }
if (check_key(argv[1])) { puts("access granted"); return 0; }
puts("wrong key");
return 1;
}
SRC
gcc -O1 crackme1.c -o crackme1 && strip crackme1
echo "== 1. strings: anything that looks like a key?"
strings -n 8 crackme1 | grep -E '^[A-Z0-9-]{8,}