emulator alibi: environment checks that are part of the answer
huntress ctf 2026, day 24 · mobile android · all three modes
tools used: android apk toolkit and timed-attempt pipeline.
"defeat app-owned environment checks on the same pinned emulator used by the solve oracle." the single was a puzzle of the oldest kind: data and a codec in the apk's assets that decode to the backend answer code, ANS- and sixteen uppercase hex digits. the time trial and every mastery apk were day 23's kind: a puzzle file that names the codec analysis and carries no data, because the app's own code computes the code. day 24 put emulator detection into that computation.
the key insight: the environment checks are not calls to the device. they are static functions over integers whose inputs are constants in the code, the readings of the one emulator the oracle was pinned to. there is nothing to defeat: interpreting the method that builds the ANS- string runs the checks exactly as the oracle did.
challenge shape
single 1 field the answer code of a schema v1 puzzle (codec split)
time trial 1 field the answer code of a schema v2 puzzle (codec
"analysis", no data, no key)
mastery 8 fields one code per apk, eight computed-code apks
artifact anatomy
the single's assets/huntress_puzzle.json uses the split codec, read since day 5: a list of parts, fragments of the code, and an order, a permutation that says where each part goes (part i belongs at position order[i]). joining the parts in that order gives the code.
the time-trial apk is small: a manifest, a classes.dex of about 5.5 kilobytes, a signature, and a puzzle file holding only the schema, the day, the codec name and a build id. the dex has a handful of classes in the case's package, and a static method takes a Context and returns the code as a string. its call graph, reconstructed from the bytecode (most helper names end in a short per-build hex suffix, shown here as *):
Release.code(ctx) "ANS-" + 16 hex nibbles of
BoardCheck.finBoard*(Mix.f1(Release.token())) ^ K
Release.token() SensorMap.mixSensor*(Util.scanEmu*(Util.mixSensor*(C)))
Util.scanEmu*(x) folds Probe.s1 and Probe.s3 (four ints -> int) and
EmulatorAlibi.emulatorScore (three ints -> int) into x
Mix, BoardCheck, 64-bit add, xor, multiply and rotate by constants
SensorMap, Util
the probes are the emulator checks, named like real anti-emulation tricks (an emulator score, sensor and qemu helpers). none of them reads a build property, a sensor or a file. Util.scanEmu* calls the probe functions three times with integer constants and passes the three results to EmulatorAlibi.emulatorScore; Probe.s1 searches a 12-bit counter for the value i where (i * a + b) ^ c, masked to 12 bits, equals d, and returns it (or -1 after 4,096 tries), and the score function sums its three inputs modulo 4. the results are multiplied by 64-bit constants and xored into the running value. three more helpers of the same shape (seal functions for emulator, qemu and sensor) are never called from the answer method, so only the call graph tells them apart from the live ones. a second method assembles a proof string for the app's own backend request; no question needs it.
the two check functions, in python:
def s1(a, b, c, d): # Probe.s1, 32-bit ints; the mask hides overflow
for i in range(1 << 12):
if ((i * a + b) ^ c) & 0xFFF == d:
return i
return -1
def emulator_score(x, y, z): # java's % keeps the dividend's sign
total = x + y + z
return total - 4 * int(total / 4)
extraction method
the dalvik interpreter we wrote for day 23 runs the bytecode: a register file per call, wide values in register pairs, java's 64-bit wraparound and shift semantics, and python stand-ins for the few library calls the code makes (StringBuilder, String.charAt, Long, Math). to find what to run, it lists every method in the question's package whose code loads the ANS- string, runs each, and keeps the results that have the answer's shape, methods that other methods call first.
def answer_codes(apk, package):
vm = Vm.of(app(apk), package)
found = []
for method, called in vm.answer_methods(): # called-by-others first
vm.reset()
out = vm.run(method)
if isinstance(out, str) and ANSWER.fullmatch(out) and out not in found:
found.append(out)
return found
on the time-trial apk Release.code was the only candidate, and the solve took about 19 milliseconds. a call into anything the interpreter does not model (a device service, a thread) would stop the run with an error that names it; day 24's checks needed none.
validation and answer formatting
the result must match the question's own pattern (ANS- and exactly sixteen uppercase hex digits). the string is the one the app builds, so its case and length come from the code, not from us.
failed approaches and pivots
none on day 24.
automation across modes
the mastery's eight apks were all computed-code puzzles, labelled with days of the event from 2 to 24; one of them loads a second dex from assets/payload.dex through an in-memory class loader, which the interpreter has handled since day 23. each apk took between 1 and 32 milliseconds.
lessons
- an environment check compiled into arithmetic over constants is part of the answer's computation; emulate it with the program instead of looking for a way around it.
- a reader built for one day's new idea (an answer the app computes) is worth more the next day, when the idea comes back with a twist.
solve times
public scoreboard · day 24 finish: top 3
- 0:02.6single#2 of 158 solvers
- 0:04.4time trial#2 of 153 solvers
- 0:07.1masteryfirst blood, +0.84 s
- #3team day finishof 139 teams that cleared it, in 3:47.1
- #1single orderof the day's 7, by our flag time
from the public scoreboard: 09:00 et release to our flag; the table below counts from our attempt's start.
from when we started working on the mode to its flag.
| mode | work to flag | attempts | wrong submits |
|---|---|---|---|
| single | 0.9s | 1 | 0 |
| time trial | 0.7s | 1 | 0 |
| mastery | 1.5s | 1 | 0 |
the clock
server timer of the winning attempt; used is attempt start to flag, left is what remained on the clock.
| mode | time available | time used | time left |
|---|---|---|---|
| time trial | 50.0s | 0.7s | 49.3s |
| mastery | 260.0s | 1.5s | 258.5s |
where we got stuck
- nowhere on day 24: the interpreter written for day 23's computed codes read the emulator checks as ordinary arithmetic.
flags: single, time trial, and mastery [redacted].
{generated by a clanker}