Analysis

Recover flag from remote CTF binary

Analysis:
Inspected remote process, dumped live .bss function-pointer table, extracted per-byte checks and permuted positions.
Conclusion:
Flag recovered: aNI9kUMbv1sQAMQGoopiXcXoZbvg8TdN4

Tools: skill, skill:binary-diff, list_files, run_sandbox, write_file, inspect_binary, dump_data

Run it yourself

Help me solve this CTF challenge. Identify the challenge type, analyze the binary, and work toward the flag. 10.129.76.221

Dr.Binary

I'll start by loading the CTF skill and checking what's in the workspace.

list_files

The binary-diff skill isn't relevant here — the workspace is empty and the target is a remote host (10.129.76.221). Let me do initial recon to identify the challenge type.

run_sandbox

Ping isn't available but nmap is. Let me scan the target.

run_sandbox

All top 1000 TCP ports are filtered. The host is up, so let me scan the full port range plus common UDP services.

run_sandbox

All 65535 TCP ports are filtered. Let me try UDP.

run_sandbox

TCP is fully filtered and UDP is ambiguous. Let me verify host liveness with ARP and ICMP-based discovery.

run_sandbox

Our sandbox is on 172.20.0.0/16 while the target is 10.129.76.221. Let me check routability.

run_sandbox

The remote host is unreachable from this sandbox (traffic dies at the gateway — 10.129.x.x isn't routed to us). Let me check whether the challenge files were staged somewhere in the sandbox filesystem.

run_sandbox

No challenge files are staged. Let me verify whether the sandbox has any internet egress at all, to isolate the problem.

run_sandbox

Status: target unreachable from this environment — here's the evidence

What I tried:

CheckResult
ICMP / ARP discoveryNo reply (host "seems down" to all probe types)
TCP scan, top 1000 portsAll filtered (no response)
Full TCP scan, all 65535 portsAll filtered
UDP top 200All open|filtered (no response)
traceroute 10.129.76.221Dies after hop 1 (172.20.0.1) — our local gateway drops it
Direct nc to ports 22/80/443Connection timed out

Isolating the cause: the sandbox does have internet egress (https://1.1.1.1/ → 301, example.com → 200), but our network is 172.20.0.11/16 on a Docker bridge. The target 10.129.76.221 sits in the 10.129.0.0/16 range used by HackTheBox lab machines, which is only routable over the user's VPN tunnel. This cloud sandbox has no route into that VPN network, so no packet we send will ever get there — it's not a firewall puzzle on the target, it's an unreachable network.

Conclusion: I can't fingerprint the service or interact with the box from here, and no challenge binary exists in the workspace (/, /tmp, /root, /opt, /srv, /home are all clean — only stock tooling like firmware-mod-kit, unblob, wine, xplico).

How to proceed — pick whichever is easiest

  1. Upload the challenge file(s) to this workspace — the binary/zip the challenge provides (e.g., the downloadable .exe/.zip from the challenge page). Once it's here I'll immediately:
    • identify the challenge type (pwn/reversing/forensics/crypto) from the file,
    • run the ghidra-analysis / taint / known-vuln pipeline as appropriate,
    • work toward the flag locally.
  2. Give me a URL — if the file is hosted anywhere reachable (it doesn't need to be the box itself; internet egress works), I'll fetch it.
  3. Paste your own recon — since you're on the VPN, run nmap -sV -sC -p- 10.129.76.221 and share the output; I can then tell you the challenge type and what to pull down for me.
  4. If you can, share the box's hostname — occasionally lab hosts are reachable via a relay; I can test it the moment you provide it.

Which challenge is it (name/category on the platform)? With the binary in hand I can start immediately — remote interactivity isn't strictly required for most rev/pwn/forensics challenges, since the flag is usually derivable from the file itself or from a local emulation (qiling/qemu are available here).

The lead developer at SecureBank Corp is back, and he's doubling down. After the last "incident," he claims he's patched the vault and created the ultimate, unhackable Ethereum contract. He’s so confident, he’s explicitly taunting the security team to try and break it.

He says, "I've added the checks, I've added the balances. There is no way you can withdraw more than you own."

Your mission: Wipe the smile off his face. Drain the vault down to 0 and force the contract to surrender the flag. Contract: here The eth chain is at:Eth node address: xebec.cylabacademy.net:30009

Dr.Binary

A blockchain CTF — let me locate the contract file in the workspace and verify the RPC endpoint is reachable.

list_files
run_sandbox

RPC is live — chain ID 0x7a69 (31337, a Hardhat/Anvil-style local chain). The contract file didn't come through, so I'll discover the deployed contracts on-chain. Let me check available tooling first.

run_sandbox
run_sandbox

web3 v8 installed. Now let me enumerate the chain — recent blocks, contract creations, and funded accounts.

write_file
run_sandbox

Connection refused from Python, though curl worked a minute ago. Let me re-test connectivity directly.

run_sandbox

The node was up a minute ago (chain ID query succeeded) and is now refusing connections — the instance may be restarting. Let me poll for it to come back.

run_sandbox
[stopped by the user]
You stopped this response.

If we can crack the password checker on this remote host, we will be able to infiltrate deeper into this criminal organization. The catch is it only functions properly on the host on which we found it. We have access to a periphery node on their network:

ssh -p 11461 ctf-player@xebec.cylabacademy.net

Using password 4f5344cd

Dr.Binary

A password-checker challenge with SSH access to a periphery node. Let me set up SSH access first.

run_sandbox
write_file
run_sandbox

SSH access confirmed — home dir contains a binary ad7e550b. Let me inspect it.

run_sandbox

A stripped musl-linked PIE flag checker. Let me run it with a dummy argument and copy it locally for static analysis.

run_sandbox
run_sandbox

The binary prints an animated banner that gets truncated. Let me capture full output and also scp the binary back for local analysis.

write_file
write_file
run_sandbox

Full output captured: progress bar + "Incorrect". The scp didn't land — let me check and retry.

run_sandbox
run_sandbox

Binary copied locally. Let me triage it with strings and a quick inspect, then decompile.

run_sandbox
inspect_binary

Tiny .text (2.7KB) with prctl imported — likely anti-debug. Let me decompile it.

dump_data
run_sandbox
run_sandbox

Interesting — ~55 tiny 7-line functions in a row (likely per-character checks) plus a main at 0x101982. Let me read main and a couple of the small functions.

run_sandbox

Structure is clear: main runs 33 per-character checker functions (one per flag position, selected via a permutation table at DAT_00104020), each tiny function compares against a single ASCII char. The flag is 33 chars. Let me extract the permutation array and the function-pointer table from .data, and each function's compared byte.

run_sandbox

Confirmed: perm[] at 0x4020 and each checker does cmpb $imm. The function-pointer table lives at 0x4120 in .bss — populated by RELATIVE relocations. Let me extract everything and reconstruct the flag.

write_file
run_sandbox

The 65 checkers map to a-zA-Z0-9_{} in order. But the function-pointer table at 0x4120 isn't populated by relocations — let me see how main actually indexes it (raw asm + init functions).

run_sandbox

No init populates it — let me read main's raw assembly to see the real addressing.

run_sandbox
run_sandbox

The call target comes from .bss at 0x4120 — which should be zero-filled. Yet the remote binary runs fine. Let me check the program headers and raw file bytes — the RW LOAD segment may map file content over that region.

run_sandbox

The RW LOAD maps file bytes only up to vaddr 0x40a4 — the table region (0x4120) is .bss, zero at load, so a crash is expected… yet the remote printed "Incorrect". Let me verify the remote binary's hash and run it with timing/exit-code capture.

run_sandbox

Same hash remotely, ran the full 34s, exit 1 — so the calls DO return (no SIGSEGV), contradicting my "zero .bss" model. Let me settle it empirically: fetch the matching musl loader and run the binary locally.

run_sandbox
run_sandbox
run_sandbox

404 — let me find the right musl package version from the Alpine index.

run_sandbox
run_sandbox

Locally it segfaults (exit 139) — consistent with a zeroed .bss table — yet remotely it completes. Same binary, different runtime memory. The hint "only functions properly on the host on which we found it" now makes sense. Let me dump the live process memory on the remote host to see what's actually at the table (vaddr base+0x4120) while it runs.

write_file
write_file
run_sandbox

Breakthrough — the remote process memory shows the .bss table is populated with 33 relocated pointers to checker functions (entry 33 = NULL). Let me cross-check the relocation tables and the raw file bytes at the corresponding file offset.

run_sandbox

Only 9 .rela.dyn entries — no relocations for the table, yet live memory has relocated pointers. The mechanism is quirky (likely the file-backed tail page + loader behavior on that specific host), but I have the ground truth: 33 live function pointers. Let me decode them precisely and reconstruct the expected string.

write_file
run_sandbox

Candidate reconstructed: aNI9kUMbv1sQAMQGoopiXcXoZbvg8TdN4. Let me verify against the remote oracle (takes ~34s due to the animation).

write_file
run_sandbox

Connection refused — the instance may be flapping. Retrying with backoff.

run_sandbox

My retry condition was flawed (the spawn line itself contains "RC="). The host is still refusing connections. Let me wait longer and retry with a proper check.

run_sandbox

Still down. While waiting, let me close the loop on how the table gets populated — checking the full dynamic segment for packed relocations (DT_RELR), which musl ≥1.2.4 processes but readelf -r doesn't show as classic RELA entries.

run_sandbox

No DT_RELR — the file genuinely contains no relocations for that table. The pointers exist only in live memory on that host: something in that environment (host-specific loader/kernel behavior — hence "it only functions properly on the host on which we found it") fills the table at exec time. My extraction is the ground truth. Let me simulate the checker logic locally to validate the candidate end-to-end.

write_file
run_sandbox

My simulation flags position 0 on my own candidate — likely a transcription slip in the hand-pasted hex. Let me parse the dump file directly instead of hand-copying.

write_file
run_sandbox

Direct parse confirms: aNI9kUMbv1sQAMQGoopiXcXoZbvg8TdN4 passes the extracted checker logic (my sim.py just had a paste typo). Now the definitive test — the real binary on the real host. Retrying SSH.

run_sandbox
run_sandbox

Host is up (22/80 open) but the challenge containers (11461, 30009) are down. Let me peek at the web portal — it may let me restart the instance.

run_sandbox
run_sandbox

Port 80 resets — the portal isn't usable either. Let me run a long poll in the background for the SSH service, then finalize.

write_file
run_sandbox

The lab's challenge services (SSH :11461 and the earlier ETH RPC :30009) have been down for the last ~10 minutes of polling — likely an instance restart on the platform side. The analysis is complete though; here's the full picture.


Challenge type

Reverse engineering — password/flag checker with host-dependent runtime patching (not a pwn: the goal is to recover the accepted string).

The binary

ad7e550b — stripped x86-64 PIE, musl-linked, 14 KB, sha256 212003011d2f…a108.

Reversed logic (main @ 0x1982):

for (i = 0; i < 33; i++) {
    sleep(1);
    k    = perm[i];                    // int32 array @ 0x4020 (.data)
    fn   = *(void**)(0x4120 + k*8);    // function table (in .bss!)
    if (!fn(argv[1][i])) { print_asterisks(33-i); puts("Incorrect"); return 1; }
    putchar('*');
}
sleep(1);
puts(argv[1][33] == '\0' ? "\nCorrect" : "\nIncorrect");   // exactly 33 chars

The 65 checker functions (0x11d5 + n*0x1d) each do a single cmpb $imm — extracting all immediates gives the alphabet a-z A-Z 0-9 _ { } in function order. The ====v / **** banner plus 1 s/char sleeps is deliberate camouflage: a failure at any position produces the identical 33-asterisk output over 34 s, so the failing position is never visible.

Why it "only functions properly on the host we found it on"

The function table at 0x4120 sits in .bss — the file contains no data and no relocations for it (only 9 .rela.dyn entries, all elsewhere; no DT_RELR). Consequently:

  • Anywhere else the table stays zero → call *0 → SIGSEGV. I reproduced this locally with the genuine musl 1.2.5-r4 loader: prints the bar, then exit 139.
  • On the challenge host, dumping the live process via /proc/<pid>/mem mid-animation showed the table populated with 33 base-relocated pointers to checker functions (entry 33 = NULL). The host environment patches/initializes that memory at exec time — the "periphery node" trick.

Solution

Dumping that live table and composing it with the perm[] array (flag[i] = checker_char(table[perm[i]])) yields the only accepted string:

aNI9kUMbv1sQAMQGoopiXcXoZbvg8TdN4

Verified in simulation against the extracted table + perm + checker immediates (all 33 positions pass; table-order string and A*33 correctly fail as controls).

One step pending

The definitive on-host confirmation was cut short — port 11461 started refusing connections right before the final run (same flapping that took down the ETH node earlier). Everything is staged; the moment the instance is back:

./verify.exp    # runs: ./ad7e550b aNI9kUMbv1sQAMQGoopiXcXoZbvg8TdN4  →  expect "\nCorrect"

Artifacts in the workspace: explore.py, solve.py, solve3.py, sim.py, memdump.txt (live table dump), verify.exp, poll.sh, and the Ghidra decompilation under ghidra_data/ad7e550b/. Want me to keep polling and confirm as soon as the box returns, or is the platform showing the instance as stopped on your side (restart button)?