Table of Contents
IronForgeCyber
Courses
Resources
Blog
Log In


IronForgeCyber

AboutPrivacyTerms

© 2026 IronForgeCyber. All rights reserved.

  1. courses
  2. re-static-analysis
  3. crackme-02
5 min read

Crackme 2: The Locker Room

This one is stripped and built with optimization. It guards a row of lockers:

chall
$ printf '104\n1234\n' | ./challLocker number: Combination: Access denied.

One of the lockers is not a locker. Make the program print The vault is open.

Try it yourself first
The solution is below. Open the binary and work at it before reading on.

Stuck? Open one hint at a time.

Hint 1
Find main from the entry point. If the address Ghidra shows there is a label and not a function, click it and press F to create one.
Hint 2
The program loops over a table. Look at the raw bytes of .rodata and find where the records start and how long each one is.
Hint 3
Each record holds a locker number, a second number, a name, and one more byte at the very end. Only one record has that last byte set.
Hint 4
The combination you type is not compared directly with the stored number. Look at what is done to it first, and remember that XOR undoes itself.

Solution

Finding main

The binary is stripped, so we start at entry:

Ghidra
1void processEntry entry(undefined8 param_1,undefined8 param_2,undefined1 param_3)
2{
3  undefined1 auStack_8 [8];
4

The first argument to __libc_start_main is main, as always, but here Ghidra shows &LAB_004003a0, a label, where earlier binaries had a FUN_ name. Ghidra's analysis did not mark the code at that address as a function. This happens now and then, and the fix is one key: double-click the label, then press F in the Listing to create a function there. The Decompiler fills in.

Reading main

Ghidra
1      uVar2 = 0;
2      do {
3        if ((ushort)(&

Before this, two scanf calls fill auStack_10[0] with the locker number and auStack_10[1] with the combination. Then there is a loop that runs five times, and inside it everything is an offset from DAT_00401280. This is the pattern from Data & Types: a table of structs, accessed by pointer arithmetic.

Work out the layout from how each offset is used. The loop index is multiplied by 0x10, so each record is 16 bytes.

OffsetAddress of the first oneSizeHow it is used
0x00x4012802Compared with the locker number
0x20x4012822Compared with the combination, after an XOR
0x40x40128411Printed with %s
0xf0x40128f1Decides between the two messages

The name field shows up as "mallory" + lVar3, because Ghidra recognized the first record's name as a string and expressed the others as offsets from it. The last field is the one we care about. When it is zero, the program reports an empty locker. When it is not, the vault opens.

Now the two checks. The first compares the record's number with ours. The second is:

Ghidra
(ushort)((&DAT_00401280)[uVar2 * 8] ^ (ushort)auStack_10[1]) == *(ushort *)(

The record's number is XORed with the combination we typed, and the result must equal the second field. Written out: number ^ combination == stored. XOR undoes itself, so combination == stored ^ number.

Reading the Table

The table is constant data, so it is in the file:

objdump
$ objdump -s -j .rodata chall | tail -n 5 401280 68003a1f 6d616c6c 6f727900 00000000  h.:.mallory..... 401290 d900c170 7472656e 74000000 00000000  ...ptrent....... 4012a0 5601e74b 70656767 79000000 00000001  V..Kpeggy....... 4012b0 ca01d029 76696374 6f720000 00000000  ...)victor...... 4012c0 3102a566 77616c74 65720000 00000000  1..fwalter......

Five rows of 16 bytes, one per record, each with a name in the middle. Look at the last byte of each row. Four end in 00. The row for peggy ends in 01. That is the vault.

Its first four bytes are 5601 e74b. Both fields are 2-byte numbers stored little-endian, so the locker number is 0x0156 and the stored value is 0x4be7:

$ echo $((0x156)) $((0x4be7 ^ 0x156))342 19121
chall
$ printf '342\n19121\n' | ./challLocker number: Combination: The vault is open.

Nothing in the program's output ever mentions locker 342 or hints that one locker is special. The only way to learn it is from the data.

Next is Crackme 3, where the answer is not stored anywhere.

5 (*(code *)PTR___libc_start_main_00402fd8)(&LAB_004003a0,param_2,&param_3,0,0,param_1,auStack_8);
6 do {
7 /* WARNING: Do nothing block with infinite loop */
8 } while( true );
9}
DAT_00401280
)
[
uVar2
*
8
]
==
auStack_10
[
0
]
)
{
4 lVar3 = (uVar2 & 0xffffffff) * 0x10;
5 if ((ushort)((&DAT_00401280)[uVar2 * 8] ^ (ushort)auStack_10[1]) ==
6 *(ushort *)(&DAT_00401282 + lVar3)) {
7 if ((&DAT_0040128f)[lVar3] == '\0') {
8 printf("Locker %u (%s) is empty.\n",(ulong)auStack_10[0],"mallory" + lVar3);
9 return 0;
10 }
11 puts("The vault is open.");
12 return 0;
13 }
14 break;
15 }
16 uVar2 = uVar2 + 1;
17 } while (uVar2 != 5);
18 puts("Access denied.");
&
DAT_00401282
+
lVar3
)