Table of Contents
IronForgeCyber
Courses
Resources
Blog
Log In


IronForgeCyber

AboutPrivacyTerms

© 2026 IronForgeCyber. All rights reserved.

  1. courses
  2. re-static-analysis
  3. crackme-04
11 min read

Crackme 4: The Machine

The last crackme uses most of what the Harder Targets section covered. It wants a password:

chall
$ echo password | ./challPassword: Access denied.

The check is in there, but not as code you can read in the usual way. Find the password.

Try it yourself first
The solution is below. This one takes a while, and it is worth the time. Open the binary and work at it before reading on.

Stuck? Open one hint at a time.

Hint 1
Ghidra finds almost nothing in this file. Run strings on it and look for a name you recognize from Anti-Analysis.
Hint 2
Once unpacked, the binary is static and stripped. Find main from the entry point, and identify the library calls from their arguments.
Hint 3
main contains a loop that reads one byte at a time from a block of constant data and does something different depending on its value. That data is not being checked. It is being run.
Hint 4
Work out what each byte value does: 0x10, 0x20, 0x30, 0x31, 0x32, 0x40 and 0xff. Some are followed by a second byte. Then write the data out as a list of instructions.
Hint 5
Each character of the password is loaded, changed by two operations with constants, and compared with a constant. Undo the two operations in reverse order.

Solution

Unpacking

file reports no section header, Ghidra finds a handful of functions, and:

$ strings chall | grep -c UPX5

It is packed with UPX, so it unpacks with UPX:

upx
$ upx -d -o unpacked chall                       Ultimate Packer for eXecutables                          Copyright (C) 1996 - 2026UPX 5.2.1       Markus Oberhumer, Laszlo Molnar & John Reiser   Aug 27th 2026        File size         Ratio      Format      Name   --------------------   ------   -----------   -----------     20112 <-     15452   76.83%   linux/amd64   unpackedUnpacked 1 file.$ file unpackedunpacked: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped

The unpacked program is static and stripped, and only 20 KB, far smaller than the static binary in Statically-Linked Binaries. It was built with Dionysus against a small C library called musl, where that one used the much larger GNU library. The method is the same.

Finding main

Ghidra
1void processEntry entry(undefined8 param_1,undefined4 param_2,undefined1 param_3)
2{
3  FUN_01002379(FUN_01002009,param_2,&param_3,FUN_010021cc

One call with a function pointer as its first argument. The startup code differs a little between C libraries, but the first argument is still main. Rename FUN_01002009.

The top of main is five calls to unnamed library functions, which we identify from the outside as before:

Ghidra
1  FUN_01002c9e("Password: ");
2  lVar2 = FUN_01002a4c(local_48,0x20,PTR_DAT_010002b8);
3  if 

A string printed without a newline is printf. A buffer, a size and a stream is fgets. Something that returns a position where a zero is then written is the newline trim, strcspn. And a function whose result is compared with 8 right before the check is strlen. The password is 8 characters.

The Loop

Then comes this, trimmed to its skeleton:

Ghidra
1      do {
2        while( true ) {
3          bVar7 = (&

It looks like the flattened function from Anti-Analysis: one loop, and a variable compared against unrelated constants. There is a difference. In a flattened function the code sets the state variable itself. Here bVar7 is read from data, at DAT_01000240, using an index iVar6 that moves forward each time round.

This is a virtual machine. The author invented a tiny instruction set, wrote the password check in it, and stored that program as bytes in the binary. What we are looking at is the interpreter: it fetches a byte, decides which operation it stands for, performs it, and moves on. The byte is an opcode, iVar6 is the program counter, and the block at DAT_01000240 is the bytecode.

Reading the interpreter only tells us what the machine can do. The check itself is in the bytecode, so we need to do two things: learn the instruction set, then read the program.

The Instruction Set

Take each opcode in turn and ask what it does to the three pieces of state: the index iVar6, a second index kept in uVar5, and the array abStack_2a.

  • 0x10 reads the next bytecode byte, uses it as an index into our input local_48, and stores that character in abStack_2a at the position given by uVar5, which then goes up by one. The index moves forward by 2.
  • 0x20 does the same, but stores the next bytecode byte itself.
  • 0x30 takes the top two stored values, XORs them, leaves the result in place of the lower one, and moves uVar5 down by one.

An array with an index that goes up when something is stored and down when values are combined is a stack, and uVar5 is its stack pointer. So 0x10 pushes a character of the input, 0x20 pushes a constant, and 0x30 pops two values and pushes their XOR.

The rest of the loop follows the same pattern. 0x31 and 0x32 are the same shape as 0x30, with + and -. The last two are here:

Ghidra
1            if (bVar7 != 0x40) {
2              if ((bVar7 == 0xff) && (

0x40 pops a value and compares it with the next bytecode byte. If they differ, the flag bVar1, which started as true, becomes false. 0xff ends the program, and access is granted only if bVar1 is still true.

OpcodeOperandMeaning
0x10An indexPush that character of the input
0x20A valuePush that value
0x30NonePop two values, push their XOR
0x31NonePop two values, push their sum
0x32NonePop two values, push the first minus the second
0x40A valuePop a value; fail if it does not equal this
0xffNoneStop

Reading the Bytecode

In the Listing, the bytes at 0x1000240 begin:

10 00 20 5a 30 20 11 31 40 3d 10 01 20 23 31 20 7c 30 40 28 ...

Decode the first ten with the table:

10 00    push input[0]
20 5a    push 0x5a
30       xor
20 11    push 0x11
31       add
40 3d    check 0x3d

In ordinary notation: (input[0] ^ 0x5a) + 0x11 must equal 0x3d. Undo it from the end, as in Obfuscation: 0x3d - 0x11 is 0x2c, and 0x2c ^ 0x5a is 0x76, the letter v.

The next ten bytes do the same kind of thing to input[1] with different operations and constants, and so on for all eight characters. That could be done by hand. A script is quicker and makes fewer mistakes.

The Script

The script is a disassembler for the machine and a solver in one. It walks the bytecode with the table above, prints each character's check as a line, and undoes the operations in reverse. The bytecode is at 0x1000240 in memory, and this binary loads at 0x1000000, so it sits at offset 0x240 in the unpacked file:

solve.py
1data = open("unpacked", "rb").read()
2code = data
$ python3 solve.pyinput[0] xor 0x5a add 0x11 == 0x3dinput[1] add 0x23 xor 0x7c == 0x28input[2] sub 0x09 xor 0xa5 == 0xccinput[3] xor 0x33 sub 0x04 == 0x43input[4] add 0x40 add 0x02 == 0xb7input[5] xor 0xff add 0x10 == 0xdbinput[6] sub 0x30 xor 0x0f == 0x33input[7] xor 0x21 xor 0x12 == 0x12v1rtu4l!$ python3 solve.py | tail -n 1 | ./challPassword: Access granted.

The first eight lines of output are the hidden program, readable at last. The ninth is the password.

Looking Back

This one binary needed most of the course. strings and file identified the packer. The entry point led to main in a static, stripped binary, and the library calls were named from their arguments. Recognizing a loop driven by a variable came from Control Flow and Anti-Analysis. Reading constant data out of the file came from Data & Types, and undoing operations in reverse order from Obfuscation.

Virtual machines are a common way to protect real software, with hundreds of opcodes where this one has seven. The approach scales as it is: learn the instruction set from the interpreter, write a disassembler, then read the program it reveals.

That is the end of the course. The sibling course on dynamic analysis starts from the same binaries and runs them under a debugger.

,
FUN_01002668
,
0
)
;
4 return;
5}
(
lVar2
==
0
)
{
4 uVar3 = 1;
5 }
6 else {
7 lVar2 = FUN_01005843(local_48);
8 local_48[lVar2] = 0;
9 lVar2 = FUN_01005999(local_48);
10 if (lVar2 == 8) {
DAT_01000240
)
[
iVar6
]
;
4 iVar8 = iVar6 + 1;
5 iVar4 = (int)uVar5;
6 if (0x30 < bVar7) break;
7 if (bVar7 == 0x10) {
8 bVar7 = local_48[(byte)(&DAT_01000241)[iVar6]];
9LAB_010020fb:
10 uVar5 = (ulong)(iVar4 + 1);
11 abStack_2a[(long)iVar4 + 2] = bVar7;
12 iVar6 = iVar6 + 2;
13 }
14 else {
15 if (bVar7 == 0x20) {
16 bVar7 = (&DAT_01000241)[iVar6];
17 goto LAB_010020fb;
18 }
19 if (bVar7 != 0x30) goto LAB_01002146;
20 lVar2 = (long)iVar4;
21 uVar5 = lVar2 - 1;
22 abStack_2a[lVar2] = abStack_2a[lVar2] ^ abStack_2a[lVar2 + 1];
23 iVar6 = iVar8;
24 }
25 }
pcVar9
=
"Access granted."
,
bVar1
)
)
goto
LAB_0100214b
;
3 break;
4 }
5 uVar5 = (long)iVar4 - 1;
6 iVar8 = iVar6 + 2;
7 lVar2 = (long)iVar6;
8 iVar6 = iVar8;
9 if (abStack_2a[(long)iVar4 + 1] != (&DAT_01000241)[lVar2]) {
10 bVar1 = false;
11 }
[
0x240
:
]
3
4OPS = {0x30: "xor", 0x31: "add", 0x32: "sub"}
5UNDO = {
6 "xor": lambda value, k: value ^ k,
7 "add": lambda value, k: (value - k) & 0xFF,
8 "sub": lambda value, k: (value + k) & 0xFF,
9}
10
11password = {}
12pc = 0
13while code[pc] != 0xFF:
14 op = code[pc]
15 if op == 0x10:
16 index, steps = code[pc + 1], []
17 pc += 2
18 elif op == 0x20:
19 constant = code[pc + 1]
20 pc += 2
21 elif op in OPS:
22 steps.append((OPS[op], constant))
23 pc += 1
24 elif op == 0x40:
25 value = code[pc + 1]
26 text = " ".join(f"{name} {k:#04x}" for name, k in steps)
27 print(f"input[{index}] {text} == {value:#04x}")
28 for name, k in reversed(steps):
29 value = UNDO[name](value, k)
30 password[index] = chr(value)
31 pc += 2
32
33print("".join(password[i] for i in sorted(password)))