Skip to content
Adam Omar Saleh

hiCTF 2026 placeholder badge (unofficial)hiCTF 2026Reverse Engineering

Entitlement

Packed ELF / Encrypted VM / Elliptic-curve discrete log / VDF

Competition
hiCTF 2026 placeholder badge (unofficial)hiCTF 2026
Category
Reverse EngineeringInsane · estimated
Analysis status
Locally verified
Document
Original PDF

01Full technical walkthrough

Overview

The challenge is a Linux x86-64 license checker. It first requests a serial, then an activation code. The apparent license check is only part of the challenge: the binary also contains a custom bytecode VM, an elliptic-curve discrete-log problem, and a deliberately costly modular squaring stage used to decrypt the flag.

The original archive has SHA-256:

d468c69996ba1e34344d616d3f0ccf1fb2de6367a498a0dda4be67041a8feca0

1. Unpacking the ELF

After extracting Entitlement from the ZIP, file and readelf -l show a 64-bit executable with no section header table. The initial image is a small packed/self-unpacking loader, rather than the complete license-checking logic. Following the loader's memory setup and transfer of control revealed the actual dynamically linked ELF image.

I instrumented the loader's handoff and used Linux write syscalls to dump the fully mapped executable memory at virtual addresses 0x400000–0x408000. The resulting 32 KiB memory image was saved as stage2.bin. Unlike the original packed file, the extracted image has the program's validation routines and data tables in readable form. Relative file offsets below refer to this dump, with virtual address 0x400000 + offset.

The runtime serial and activation prompts are:

Solver / Reproduction
Serial >Activation code >

2. Recovering the serial (custom VM and GF(2^64))

The serial verification routine runs an encrypted bytecode program in a tiny custom VM. The bytecode is 396 bytes (99 instructions of four bytes each) at offset 0x7080 in the memory dump. Its key is calculated by hashing the bytes in stage2.bin[0x4560:0x4702]:

Solver / Reproduction
MASK = (1 << 64) - 1key = 0x80a86c0cba674b51for c in stage2[0x4560:0x4702]:    key = ((key ^ c) * 0x4ab4302c37aa6cbd) & MASK    key ^= key >> 31

The bytecode is XOR-encrypted with an evolving 64-bit xorshift state:

Solver / Reproduction
state = keystream = bytearray()for _ in range((396 + 7) // 8):    state ^= state >> 10    state ^= (state << 24) & MASK    state ^= state >> 11    state &= MASK    stream += state.to_bytes(8, 'little')​bytecode = bytes(a ^ b for a, b in zip(stage2[0x7080:0x7080+396], stream))

The instructions support register assignment, constants, XOR, shifts, branches and return. By emulating them and simplifying the resulting bitwise loops, the entire validation reduces to finite-field arithmetic.

Define x = serial XOR 0xd1705c3b2e33689b and let multiplication occur in GF(2^64) with reduction polynomial represented by 0x2b395c2099596d9f. The VM computes successive powers x², x³, x⁶, x¹², x¹³ and compares:

Solver / Reproduction
(x^13) XOR 0xba6b1f3cb925c25a == 0x30cefbec2e4bc466

Since gcd(13, 2^64 - 1) = 1, exponentiation by 13 is invertible in the multiplicative group. Thus we recover x by raising the expected field value to the inverse exponent modulo 2^64 - 1, then undo the input XOR.

The supplied solver/solve_serial.py implements field multiplication, exponentiation and inversion without external Python dependencies:

Solver / Reproduction
Serial: 8f7db18bd70e193b

Entering this serial successfully advances the binary to the second prompt.

3. Recovering the activation code (Smart's attack)

The next check is an elliptic-curve discrete logarithm. The checker uses a curve over a prime field:

Solver / Reproduction
p = 0x8c817b4a4c0f170cd5aab18cfa = 0x65561c079c3bb669feb4d54d9b = 0x3905920c79c2f7ace28164fb6​G = (0xc217d88d4bf005f2022d4e0f,     0x30999f70fb48e2b703431f4d0)​Q = (0x622d01f78ebad9c83dd402304,     0x387932a13c1ef33f165880b6)

The validation checks whether Q = kG, where k is the activation-code integer. Crucially, this is an anomalous elliptic curve: #E(F_p) = p. Its discrete logarithm is vulnerable to Smart's attack.

I lifted G and Q to points modulo p², performed scalar multiplication by p in Jacobian coordinates, and applied the p-adic map. If psi(P) denotes the map, linearity gives:

Solver / Reproduction
k = psi(Q) * inverse(psi(G), p) mod p

That directly recovers the discrete logarithm:

Solver / Reproduction
Activation code: 2977e17b118de75b3b4e921a4

I independently verified k * G == Q using elliptic-curve point multiplication. The complete pure-Python implementation is in solver/ecc.py and solver/solve_activation.py.

4. The time-lock calculation

After accepting both inputs, the program does not reveal the flag immediately. Instead, it starts a verifiable-delay-function-style loop consisting of 500,000,000 sequential modular squarings on a 2048-bit value:

Solver / Reproduction
v = x0repeat 500000000 times:    v = (v * v) mod N

N is embedded in the extracted image as a 256-byte little-endian integer at offset 0x5540. To retrieve the 256-byte initial state x0, I patched the call at 0x4015a0 just before the long computation to write its input buffer to standard output. The extracted initial state is provided as solver/x0.bin.

Rewriting the inner loop with GMP limb arithmetic and Montgomery reduction made the computation practical while preserving the exact result. The implementation uses mpn_sqr and __gmpn_redc_1, with one 32-limb Montgomery multiplication/reduction per round. Its output was cross-checked against a short run of the original binary before executing all 500 million rounds.

The full computation took approximately 553 seconds on the analysis system. solver/vdf_gmp.c reproduces it, and solver/vdf_final.bin stores the resulting 256-byte little-endian value.

To reproduce this stage on Linux with GMP installed:

Solver / Reproduction
cd solvergcc -O3 -march=native vdf_gmp.c -lgmp -o vdf_gmp./vdf_gmp

5. Decrypting the flag

The checker uses the successful serial, activation scalar, and VDF output to derive a SHA-256 key stream, which is XORed with a 64-byte encrypted flag buffer at stage2.bin[0x5200:0x5240].

The exact extraction is:

Solver / Reproduction
from hashlib import sha256​serial = int('8f7db18bd70e193b', 16).to_bytes(8, 'little')activation = int('2977e17b118de75b3b4e921a4', 16).to_bytes(16, 'little')vdf = open('vdf_final.bin', 'rb').read()   # 256 bytes, little-endianstage2 = open('stage2.bin', 'rb').read()​h = sha256(serial + activation + vdf).digest()mask = b''.join(sha256(h + bytes([i])).digest()[:8] for i in range(8))plaintext = bytes(a ^ b for a, b in zip(stage2[0x5200:0x5240], mask))​assert sum(plaintext) == 0x133dassert plaintext.startswith(b'hiCTF{')print(plaintext.rstrip(b'\x00').decode())

The checksum succeeds (0x133d), the output starts with hiCTF{, and the decoded plaintext is:

Solver / Reproduction
hiCTF{>o<_C0ngrats_Her3_1s_Y0ur_HI4_Subscript1on_^_^}

Result

RECOVERED FLAG

hiCTF{>o<_C0ngrats_Her3_1s_Y0ur_HI4_Subscript1on_^_^}

Locally verified

Local Verification
The serial/activation equations were independently checked; the decrypted bytes began with hiCTF{ and matched the binary checksum 0x133d. No platform-submission receipt is archived.

Original document

Original PDF

The writeup as I first documented it.