Behind the Scenes
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.
$ ls tags/ techniques/
$ cat /etc/rate-limit
Rate limit reached (20 reads/hour per IP). Showing preview only — full content returns at the next hour roll-over.
Behind the Scenes — HackTheBox
Description
"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.
Analysis
Initial Analysis
$ 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}.
Anti-Decompilation: ud2 + SIGILL
The key protection mechanism uses the ud2 instruction (undefined instruction, opcode 0f 0b):
- Handler registration: At the start of
main, a signal handler forSIGILLis registered (segill_sigaction) - Scattered ud2: The code contains scattered
ud2instructions that trigger an "illegal instruction" exception - Handler skips: The signal handler intercepts SIGILL and increments the instruction pointer by 2 bytes (the size of ud2)
- Decompiler breaks: Static analyzers (IDA, Ghidra) don't understand that ud2 will be skipped and incorrectly build the CFG
; Typical pattern in the code: mov rdi, [rbp-0x10] ud2 ; <- decompiler thinks this crashes add rdi, 0x3 ; <- this code is not analyzed
Password Verification Logic
The logic extracted from the disassembler (objdump -d):
- Check
argc == 2(argument required) - Check password length
== 12characters - Compare password in chunks using
strncmp:
...
$ grep --similar
Similar writeups
- [reverse][Pro]Reverse Me— taipanbyte
- [reverse][free]Rega's Town— HackTheBox
- [pwn][free]Getting Started— hackthebox
- [pwn][Pro]Вход не для всех (Entry is not for everyone)— hackerlab
- [reverse][Pro]s2.out— rev-kids20.forkbomb.ru