1337 Local CTF: holy bytes hh — Timing Side Channel
216 words
1 minute
1337 Local CTF: holy bytes hh — Timing Side Channel
holy bytes hh
Challenge Context
The challenge provided a Python service that asks for a bit position. It converts the flag to a binary string and performs expensive work only when the selected bit is 1.
Reconnaissance
The relevant code was:
from math import gcd
with open("flag.txt", "r") as f: flag = f.read()
while 1: mask = int(input("gimme ur mask > ")) bits = ''.join(format(ord(c), '08b') for c in flag) for bit in bits[mask-1:mask]: if bit == '1': i = 1 while gcd(i, 279557) == 1: i = i + 1 else: passVulnerability / Core Idea
The branch for 1 takes measurably longer than the branch for 0. That turns the service into a bit oracle:
fast response -> selected bit is 0slow response -> selected bit is 1Exploitation
Query bit positions from 1 upward, measure round-trip time, classify each bit, and decode every 8 bits as one byte.
import socket, time
s = socket.socket()s.settimeout(30)s.connect(("159.65.235.153", 4446))
bits = ""for i in range(1, 500): s.recv(4096) start = time.perf_counter() s.send(f"{i}\n".encode()) s.recv(4096) duration = time.perf_counter() - start bits += "1" if duration >= 0.17 else "0"
flag = "".join(chr(int(bits[j:j+8], 2)) for j in range(0, len(bits)-7, 8)) if "}" in flag: print(flag) breakFlag
leet{wA7cH_ThEm_BiTs_4pp3ar_0ne_aftA_an0thA}Lesson Learned
Branch-dependent runtime is enough to leak secrets. If a secret controls whether expensive work happens, the network becomes an oracle.
Cover: Wallhaven gw55w7.
Share Article
If this article helped you, please share it with others!
1337 Local CTF: holy bytes hh — Timing Side Channel
https://achux21.github.io/posts/1337-local-ctf-holy-bytes-hh/ 1337 Local CTF: Encrypted Callback — TLS 1.3 Decryption → PowerShell Malware
1337 Local CTF: intro to zk — Broken Fiat-Shamir Binding
Related Posts Smart
1
1337 Local CTF: numbA thiri — CRT Reconstruction
CTF Recovering the flag integer from residues modulo small primes and a quotient.
2
1337 Local CTF: Baby-AES — Known Plaintext → Tiny Keyspace
CTF Recovering a 9-byte AES key by using the known flag format and a known plaintext/ciphertext pair.
3
1337 Local CTF: intro to zk — Broken Fiat-Shamir Binding
CTF Forging a Sigma protocol proof because the verifier's challenge is constant and not bound to the commitment.
4
1337 Local CTF: baby overflow — Integer Overflow
CTF Using an 8-bit integer wraparound to satisfy a numeric check.
5
1337 Local CTF: July pool 2024 — Dangling Git Commits
CTF Recovering a split flag from unreachable Git objects inside a piscine project archive.
Random Posts Random