commit
93974b52a3
@ -0,0 +1,9 @@
|
|||||||
|
*.zip
|
||||||
|
*.tar.gz
|
||||||
|
*.tar
|
||||||
|
*.bin
|
||||||
|
*.exe
|
||||||
|
*.jpg
|
||||||
|
*.enc
|
||||||
|
*.png
|
||||||
|
*.gif
|
@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
import pwn
|
||||||
|
import re
|
||||||
|
import time
|
||||||
|
|
||||||
|
r = pwn.remote('0c2450d17014ac4e.247ctf.com', 50319)
|
||||||
|
|
||||||
|
while not r.can_recv(0):
|
||||||
|
time.sleep(0.5)
|
||||||
|
|
||||||
|
# can be substituted by True to speed up the process (:
|
||||||
|
while r.can_recv(0):
|
||||||
|
answ = r.recvline().decode('utf-8')
|
||||||
|
ns = re.findall("\d{1,4}", answ)
|
||||||
|
if len(ns) == 2:
|
||||||
|
sum = int(ns[0]) + int(ns[1])
|
||||||
|
ans = bytes(str(sum) + '\r\n', 'utf-8')
|
||||||
|
r.send(ans)
|
||||||
|
time.sleep(0.05)
|
||||||
|
else:
|
||||||
|
print(answ)
|
@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/python
|
||||||
|
# JPEG (JFIF) has the following header: FF D8 FF E0 00 10 4A 46 49 46 00 01
|
||||||
|
correct_header = [0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01]
|
||||||
|
# The file we got has this header: (Inspected using xxd / emacs hexl-mode)
|
||||||
|
# false_header = [0xb9, 0x14, 0x06, 0x45, 0x71, 0xe0, 0xb5, 0xf7, 0x37, 0x07, 0xcb, 0x85]
|
||||||
|
|
||||||
|
# A: Correct header, B: Wrong header, X: de/encryption key
|
||||||
|
# Get the XOR key to decrypt the file (A ^ X = B => X = A ^ B)
|
||||||
|
xor = []
|
||||||
|
with open("my_magic_bytes.jpg.enc", "rb") as f:
|
||||||
|
for i in range(len(correct_header)):
|
||||||
|
xor.append(correct_header[i] ^ int(f.read(1).hex(), 16))
|
||||||
|
|
||||||
|
# read binary data from file, write xored binary data to file
|
||||||
|
i = 0
|
||||||
|
with open("my_magic_bytes.jpg.enc", "rb") as f, open("mep.jpg", "wb") as o:
|
||||||
|
while (cb := f.read(1)):
|
||||||
|
xored = int(cb.hex(), 16) ^ xor[i]
|
||||||
|
o.write(bytes([xored]))
|
||||||
|
i = (i + 1) % len(xor)
|
||||||
|
|
||||||
|
# FLAG: 247CTF{ca4e3b7f913ca7ca8f33fb0504f2947f}
|
Loading…
Reference in new issue