1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| from pwn import *
def fill(dim,pos1,pos2,start1,start2): global r pos = 0 a = "" if dim < 2: return if pos1>=start1+dim/2: if pos2>=start2+dim/2: pos = 4 else: pos = 3 else: if pos2>=start2+dim/2: pos = 2 else: pos = 1 if pos == 1: a += "("+str(start1+dim//2-1)+","+str(start2+dim//2)+"),("+str(start1+dim//2)+","+str(start2+dim//2)+"),("+str(start1+dim//2)+","+str(start2+dim//2-1)+")" print(a) r.sendline(a) fill(dim//2,pos1,pos2,start1,start2) fill(dim//2,start1+dim//2-1,start2+dim//2,start1,start2+dim//2) fill(dim//2,start1+dim//2,start2+dim//2-1,start1+dim//2,start2) fill(dim//2,start1+dim//2,start2+dim//2,start1+dim//2,start2+dim//2) elif pos == 2: a += "("+str(start1+dim//2-1)+","+str(start2+dim//2-1)+"),("+str(start1+dim//2)+","+str(start2+dim//2-1)+"),("+str(start1+dim//2)+","+str(start2+dim//2)+")" print(a) r.sendline(a) fill(dim//2,start1+dim//2-1,start2+dim//2-1,start1,start2) fill(dim//2,pos1,pos2,start1,start2+dim//2) fill(dim//2,start1+dim//2,start2+dim//2-1,start1+dim//2,start2) fill(dim//2,start1+dim//2,start2+dim//2,start1+dim//2,start2+dim//2) elif pos == 3: a += "("+str(start1+dim//2-1)+","+str(start2+dim//2-1)+"),("+str(start1+dim//2-1)+","+str(start2+dim//2)+"),("+str(start1+dim//2)+","+str(start2+dim//2)+")" print(a) r.sendline(a) fill(dim//2,start1+dim//2-1,start2+dim//2-1,start1,start2) fill(dim//2,start1+dim//2-1,start2+dim//2,start1,start2+dim//2) fill(dim//2,pos1,pos2,start1+dim//2,start2) fill(dim//2,start1+dim//2,start2+dim//2,start1+dim//2,start2+dim//2) else: a += "("+str(start1+dim//2-1)+","+str(start2+dim//2)+"),("+str(start1+dim//2-1)+","+str(start2+dim//2-1)+"),("+str(start1+dim//2)+","+str(start2+dim//2-1)+")" print(a) r.sendline(a) fill(dim//2,start1+dim//2-1,start2+dim//2-1,start1,start2) fill(dim//2,start1+dim//2-1,start2+dim//2,start1,start2+dim//2) fill(dim//2,start1+dim//2,start2+dim//2-1,start1+dim//2,start2) fill(dim//2,pos1,pos2,start1+dim//2,start2+dim//2) r = remote('misc.chal.csaw.io',9000) r.recvuntil("block: ") s = r.recvline() pos = str(s).split(",") pos[0] = int(pos[0][3:]) pos[1] = int(pos[1].lstrip()[:2].rstrip(')') fill(64,pos[0],pos[1],0,0) print(s,pos) print(r.recvline())
|