Challenge Description:
test ur poker addiction
i took it more as aspam chall
so first thing that it required u to beat the computer so i did what it takes
server takes one char per tick: p = play, s = slap (doubles only, no sandwich shit). status: line tells me each play, slap, false slap, and face card challenge.
naive bot (scan recv, fire s on double) lost 96/99 slap races. fuck timing. probe showed why: tick = 62ms, rtt ≈ 62ms. auto slap fires +141ms after a double but i still lost with 0ms cpu work tbh weird af. spam test cleared it up: 100 s in one packet only burned 1 card. so the server reads one char per tick and extra bytes just chill in the kernel buffer.
fix: send ps together each turn. server reads p (plays my card, maybe doubles, schedules auto slap at +141ms). next tick (+62ms) reads my queued s slap. wins before the auto slap fires. ngl same trick wins bot-made doubles too cuz the s from the prior ps is already buffered.
solve.py
import socket
import time
import select
HOST = "instancer.dalctf2026.com"
PORT = 44878
s = socket.create_connection((HOST, PORT), timeout=10)
s.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
s.setblocking(False)
buf = b''
def pump_until(pat, t):
global buf
end = time.time() + t
while time.time() < end:
r, _, _ = select.select([s], [], [], max(0, end - time.time()))
if r:
try:
c = s.recv(8192)
except:
continue
if not c:
break
buf += c
if pat and pat in c:
return True
pump_until(b'Press 1', 2.0)
s.sendall(b'2')
pump_until(b'Computer plays', 2.0)
last_play_t = 0
start = time.time()
while time.time() - start < 240:
r, _, _ = select.select([s], [], [], 0.02)
if r:
try:
data = s.recv(16384)
except:
continue
if not data:
break
buf += data
tail = buf[-1500:]
if (b"Player's turn" in tail or b"remaining to answer" in tail or b"played a face card. " in tail) and time.time() - last_play_t > 0.06:
s.sendall(b'ps') # the exploit
last_play_t = time.time()
if b'flag{' in buf.lower() or b'dalctf{' in buf.lower():
break
if b'Mission Failed' in buf[-300:] or b'Round Won' in buf[-300:]:
time.sleep(0.5)
s.sendall(b'
')
time.sleep(0.5)
end2 = time.time() + 1.5
while time.time() < end2:
r, _, _ = select.select([s], [], [], 0.1)
if r:
try:
c = s.recv(8192)
except:
continue
if not c:
break
buf += c
if b'1. Learning Mode' in buf[-2000:]:
s.sendall(b'2')
time.sleep(0.3)
pump_until(b'Computer plays', 2.0)
heres some math shit i calculated :
per ps: $d$ = probability of double, $g$ = avg cards gained per slap win, $c$ = 1 card lost per false slap.
$$E[Δ] = d \cdot g - (1 - d) \cdot c$$
from logs: $d \approx 0.10$, $g \approx 5$ so $E[Δ] \approx -0.40$. looks like shit alone but it drops the bot slap gain to ~0 which flips the whole game btw.
per game win rate went from $p_1 = 1/17 \approx 0.06$ to $p_2 \approx 10/35 \approx 0.29$ chance of 3 wins in a row across $n$ games:
$$P_{\text{flag}}(n) = 1 - (1 - p_2^3)^{(n - 2)}$$
$p_1 = 0.06$, $n = 35 \rightarrow P \approx 0.7\%$
$p_2 = 0.29$, $n = 35 \rightarrow P \approx 56\%$
sooo i tested the script 12 times and traaaa
terminal
Top card:
_____
|4 |
| ^ ^ |
| |
| ^ ^ |
|____h|
Status: Computer plays 4s.
Egyptian Rat Screw
Computer: 0 card(s) | Player: 52 card(s)
Pile: 0 card(s)
Turn: Player
Challenge: None
Controls: p = play, s = slap, c = counts
Top card:
_____
| |
| |
| |
| |
|_____|
Status: Player wins the pile.
>
Egyptian Rat Screw
Computer: 0 card(s) | Player: 52 card(s)
Pile: 0 card(s)
Turn: Player
Challenge: None
Controls: p = play, s = slap, c = counts
Top card:
_____
| |
| |
| |
| |
|_____|
Status: Player's turn.
>
>>>SENT b'ps'<<<
Egyptian Rat Screw
Computer: 0 card(s) | Player: 51 card(s)
Pile: 1 card(s)
Turn: Player
Challenge: None
Controls: p = play, s = slap, c = counts
Top card:
_____
|4 |
| & & |
| |
| & & |
|____h|
Status: False slap. Player burns a card to the pile. Play continues.
>
Egyptian Rat Screw
Computer: 0 card(s) | Player: 50 card(s)
Pile: 2 card(s)
Turn: Player
Challenge: None
Controls: p = play, s = slap, c = counts
Top card:
_____
|5 |
| ^ ^ |
| ^ |
| ^ ^ |
|____S|
Status: Player plays 5s.
>
Egyptian Rat Screw
Computer: 0 card(s) | Player: 50 card(s)
Pile: 2 card(s)
Turn: Computer
Challenge: None
Controls: p = play, s = slap, c = counts
Top card:
_____
|5 |
| ^ ^ |
| ^ |
| ^ ^ |
|____S|
Status: Computer's turn.
Egyptian Rat Screw
Computer: 0 card(s) | Player: 50 card(s)
Pile: 2 card(s)
Turn: Game over
Challenge: None
Controls: p = play, s = slap, c = counts
Top card:
_____
|5 |
| ^ ^ |
| ^ |
| ^ ^ |
|____S|
Status: Player wins!
Mission Complete!
You beat the computer 3 times. Here's your flag:
dalctf{0k4y_f1n3_y0u_w1n}
Flag
dalctf{0k4y_f1n3_y0u_w1n}