Skip to content

Instantly share code, notes, and snippets.

@sudhackar
Last active November 21, 2017 07:29
Show Gist options
  • Save sudhackar/57fb4c62bf12fddd0001e2d0f10914e7 to your computer and use it in GitHub Desktop.
Save sudhackar/57fb4c62bf12fddd0001e2d0f10914e7 to your computer and use it in GitHub Desktop.
[CSAW CTF Finals 2017] Rusty Road
from pwn import *
h ={"U":[[] for i in xrange(10)], "D":[[] for i in xrange(10)], "L":[[] for i in xrange(10)], "R":[[] for i in xrange(10)]}
U = open("U","rb")
D = open("D","rb")
L = open("L","rb")
R = open("R","rb")
for i in xrange(10):
for j in xrange(0x10):
h["U"][i].append(u32(U.read(4)))
for i in xrange(10):
for j in xrange(0x10):
h["D"][i].append(u32(D.read(4)))
for i in xrange(10):
for j in xrange(0x10):
h["L"][i].append(u32(L.read(4)))
for i in xrange(10):
for j in xrange(0x10):
h["R"][i].append(u32(R.read(4)))
def f(dirn, x, y):
return h[dirn][y][x]
def get_sum(s):
x, y = 0, 0
pathsum = 2
for i in s:
# print pathsum
if i == "U":
y += 1
y %= 10
elif i == "D":
if y > 0:
y -= 1
elif i == "R":
x += 1
x %= 10
elif i == "L":
if x > 0:
x -= 1
pathsum += f(i,x,y)
return pathsum
from itertools import *
for i in product("UR",repeat=18):
if get_sum(i) == 0x622c and i.count("U")==i.count("R"):
print ''.join(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment