← all posts

· 5 min read · by Eav Puthcambo

Beating the final bosses of a 12-level crackme series

The last two levels of Lack's Windows crackme series add anti-debug tricks, a jump-table VM, and a 152-part license key. All of it falls to reading the code instead of running it.

Ultimate Boss and Ultimate Real Boss, the finale of the Level crackme series by Lack on crackmes.one

The Level series is 12 Windows x64 crackmes, and each level adds exactly one new trick on top of the last. It starts with a plaintext password and climbs through XOR, keygens, a bytecode VM and a threaded hash. Then come two boss fights that combine everything: anti-debugging, a jump-table virtual machine, and finally a license made of 152 chained numbers.

Boss 1: the Ultimate License Check

THE ULTIMATE LICENSE CHECK
Enter Username: … Enter Part 1: … Enter Part 2: …

A username and two integers. A string dump shows no UI text at all, because every prompt is decrypted at runtime. It does show a very telling import list:

IsDebuggerPresent   CheckRemoteDebuggerPresent   GetThreadContext
GetTickCount64      GetProcAddress               Sleep

This binary does not want a debugger attached.

The anti-debug doesn't matter

The validator call is wrapped in a stopwatch:

call GetTickCount64        ; start
call validate
call GetTickCount64        ; end
sub  rax, rbx
cmp  rax, 0x1f4            ; more than 500 ms?
jbe  real_path             ; fast → genuine path
                           ; slow → "[!] Debugger Detected!"

If you're single-stepping, it takes more than 500 ms and you get sent to a decoy. There are also checks for an attached debugger and hardware breakpoints. All of these only catch dynamic analysis. If you read the code and compute the answer offline, none of them ever fire.

The validator is a tiny VM

The check isn't straight-line code. It's a state machine that looks up the next handler in a table on every step:

dispatch:
  movsxd rax, r10d                               ; current state
  movzx  eax, byte [r14 + rax + 0x1ec0]          ; opcode = state_table[state]
  mov    ecx, dword [r14 + rax*4 + 0x1ea4]       ; offset = jump_table[opcode]
  add    rcx, r14
  jmp    rcx

Dumping both tables straight out of the file turns the "obfuscated" control flow into a plain checklist:

State Check
0 username isn't empty
1 Part1 == sum(username bytes) × 31
3 Part2 == (Part1 XOR 0x1337) + 0x7B
4 success

So the whole license is two lines:

Part1 = sum(username_bytes) * 31
Part2 = (Part1 XOR 0x1337) + 0x7B

The hidden second condition

Getting Access Granted! is the easy part. After that, the program decrypts a final message with a key taken from your own input:

movzx r14d, byte [rsp+0x44]   ; low byte of Part2
xor   r14b, 0x3e              ; message key

Brute-forcing that one-byte key against the 15-byte encrypted message shows only one key gives real text:

key 0x46 → "Wow you did it!"     (needs Part2 & 0xFF == 0x78)

Any other valid license gets you in, but prints garbage. Since the username is mine to choose, I searched for a byte-sum whose Part2 ends in 0x78. The smallest is 246, which is ZZB (90 + 90 + 66):

$ printf 'ZZB\n7626\n3960\n' | ./UltimateBoss.exe
[+] Access Granted!
[+] Message: Wow you did it!

Boss 2: the 152-part license

The real final boss asks for a username and then 152 numbers:

…ULTIMATE 152-Part LICENSE CHECK
Enter Username: Enter Part 1: … Enter Part 152:

It reuses the same anti-debug stopwatch and the same jump-table VM shape. Recognising that made it an extension of the last level rather than a fresh reverse. Decoding the new tables:

State Check
0 username isn't empty, and exactly 152 parts
1–2 Part[0] == sum(username bytes) × 31
3–5 for every i from 1 to 151, check Part[i] against Part[i-1]
6 success

The per-part check:

lea  r9d, [rbx + 0x1337]       ; i + 0x1337
imul ecx, ebx, 0x7b            ; i * 123
xor  r9d, [rdx + r8*4 - 4]     ; XOR Part[i-1]
add  r9d, ecx                  ; + i*123
cmp  [rdx + r8*4], r9d         ; must equal Part[i]

So it's a chain:

Part[0] = sum(username_bytes) * 31
Part[i] = ((i + 0x1337) XOR Part[i-1]) + i*123      for i = 1..151

152 numbers sounds terrifying, but every part is fully decided by the one before it. The whole license collapses to one free choice: the username.

Same final twist as before: the message key comes from the low byte of the last part, Part[151]. So I need a username whose 152-step chain happens to end on 0x78:

M = 1 << 32

def chain(S):
    p = [(S * 31) % M]
    for i in range(1, 152):
        p.append((((i + 0x1337) ^ p[i - 1]) + i * 123) % M)
    return p

S = next(s for s in range(1, 100000) if chain(s)[151] & 0xFF == 0x78)   # → 41

A byte-sum of 41 is a single character: ).

One last gotcha: the parts are read with cin >> int, a signed 32-bit integer. Any computed value of 2³¹ or more has to be typed as its negative two's-complement form, or the input stream fails halfway and the check quietly dies.

$ python keygen.py | ./UltimateRealBoss.exe
[+] Access Granted!
[+] Message: Wow you did it!

A one-character username and 152 numbers, and the series is done. 🏁

📂 Full walkthroughs for all 12 levels, with tables, addresses and keygens: ctf-writeups/reverse/crackmes-one/Lack-Level-Series-Lab

Thanks for reading! Questions or corrections? Ping me on GitHub.

Read more

all posts →