The last crackme uses most of what the Harder Targets section covered. It wants a password:
echo password | ./challPassword: Access denied.The check is in there, but not as code you can read in the usual way. Find the password.
Stuck? Open one hint at a time.
strings on it and look for a name you recognize from Anti-Analysis.main from the entry point, and identify the library calls from their arguments.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.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.file reports no section header, Ghidra finds a handful of functions, and:
strings chall | grep -c UPX5It is packed with UPX, so it unpacks with 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, strippedThe 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.
main1void processEntry entry(undefined8 param_1,undefined4 param_2,undefined1 param_3)
2{
3 FUN_01002379(FUN_01002009,param_2,¶m_3,FUN_010021ccOne 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:
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.
Then comes this, trimmed to its skeleton:
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.
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:
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.
| Opcode | Operand | Meaning |
|---|---|---|
0x10 | An index | Push that character of the input |
0x20 | A value | Push that value |
0x30 | None | Pop two values, push their XOR |
0x31 | None | Pop two values, push their sum |
0x32 | None | Pop two values, push the first minus the second |
0x40 | A value | Pop a value; fail if it does not equal this |
0xff | None | Stop |
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 0x3dIn 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 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:
1data = open("unpacked", "rb").read()
2code = datapython3 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.
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.