$ cat writeup.md…
$ cat writeup.md…
hackthebox
Task: ELF binary with anti-decompilation protection using ud2 instructions. Solution: Bypass ud2+SIGILL technique by static analysis of disassembly, extract password chunks from .rodata section.
"After struggling to secure our secret strings for a long time, we finally figured out the solution to our problem: Make decompilation harder. It should now be impossible to figure out how our programs work!"
The behindthescenes binary is an ELF 64-bit file that uses an anti-decompilation technique to protect the password verification logic.
$ file behindthescenes behindthescenes: ELF 64-bit LSB pie executable, x86-64, dynamically linked, not stripped $ strings behindthescenes ./challenge <password> > HTB{%s}
The binary takes a password as an argument and outputs the flag in the format HTB{password}.
The key protection mechanism uses the ud2 instruction (undefined instruction, opcode 0f 0b):
main, a signal handler for SIGILL is registered (segill_sigaction)ud2 instructions that trigger an "illegal instruction" exception; Typical pattern in the code: mov rdi, [rbp-0x10] ud2 ; <- decompiler thinks this crashes add rdi, 0x3 ; <- this code is not analyzed
The logic extracted from the disassembler (objdump -d):
argc == 2 (argument required)== 12 charactersstrncmp:| Offset | Length | String address | Value |
|---|---|---|---|
| 0 | 3 | 0x201b | "Itz" |
| 3 | 3 | 0x201f | "_0n" |
| 6 | 3 | 0x2023 | "Ly_" |
| 9 | 3 | 0x2027 | "UD2" |
$ objdump -s -j .rodata behindthescenes 2010 3c706173 73776f72 643e0049 747a005f <password>.Itz._ 2020 306e004c 795f0055 4432003e 20485442 0n.Ly_.UD2.> HTB
Strings confirmed:
Itz @ 0x201b_0n @ 0x201f (displayed as 0n due to null-terminator)Ly_ @ 0x2023UD2 @ 0x2027Concatenating the password parts:
Itz + _0n + Ly_ + UD2 = Itz_0nLy_UD2
Verification:
$ ./behindthescenes Itz_0nLy_UD2 > HTB{Itz_0nLy_UD2}
Use this technique (ud2 anti-decompilation) when:
ud2 instructions (opcode 0f 0b)ud2 with nop nop (90 90) and re-run analysisfile — file type identificationstrings — string searchobjdump -d — disassemblyobjdump -s -j .rodata — data section dumpxxd — hex dump for verification$ cat /etc/motd
Liked this one?
Pro unlocks every writeup, every flag, and API access. $9/mo.
$ cat pricing.md$ grep --similar