Compare commits
3 Commits
babygame03
...
endianness
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a3d85283ee | ||
|
|
365d9a82b1 | ||
|
|
b8a45eb92c |
BIN
endianness_v2/challengefile
Normal file
BIN
endianness_v2/challengefile
Normal file
Binary file not shown.
0
endianness_v2/original.jpg
Normal file
0
endianness_v2/original.jpg
Normal file
15
endianness_v2/sol.py
Executable file
15
endianness_v2/sol.py
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
from pwn import *
|
||||||
|
|
||||||
|
with open("challengefile", "rb") as f:
|
||||||
|
file = f.read()
|
||||||
|
|
||||||
|
log.info(f"length: {len(file)}")
|
||||||
|
|
||||||
|
reorder = b""
|
||||||
|
|
||||||
|
for i in range(len(file)//4):
|
||||||
|
reorder += file[i+3:i+4] + file[i+2:i+3] + file[i+1:i+2] + file[i:i+1]
|
||||||
|
|
||||||
|
log.hexdump(reorder)
|
||||||
|
|
||||||
1769611
flag_printer/encoded.txt
Normal file
1769611
flag_printer/encoded.txt
Normal file
File diff suppressed because it is too large
Load Diff
28
flag_printer/flag_printer.py
Executable file
28
flag_printer/flag_printer.py
Executable file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import galois
|
||||||
|
import numpy as np
|
||||||
|
MOD = 7514777789
|
||||||
|
|
||||||
|
points = []
|
||||||
|
|
||||||
|
for line in open('encoded.txt', 'r').read().strip().split('\n'):
|
||||||
|
x, y = line.split(' ')
|
||||||
|
points.append((int(x), int(y)))
|
||||||
|
|
||||||
|
GF = galois.GF(MOD)
|
||||||
|
print(GF.properties)
|
||||||
|
|
||||||
|
matrix = []
|
||||||
|
solution = []
|
||||||
|
for point in points:
|
||||||
|
x, y = point
|
||||||
|
solution.append(GF(y % MOD))
|
||||||
|
|
||||||
|
row = []
|
||||||
|
for i in range(3):
|
||||||
|
row.append(GF((x ** i) % MOD))
|
||||||
|
|
||||||
|
matrix.append(GF(row))
|
||||||
|
|
||||||
|
print('solving')
|
||||||
|
open('output.bmp', 'wb').write(bytearray(np.linalg.lstsq(GF(matrix), GF(solution)).tolist()[:-1]))
|
||||||
0
flag_printer/output.bmp
Normal file
0
flag_printer/output.bmp
Normal file
31
flag_printer/sol.py
Executable file
31
flag_printer/sol.py
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
from sage.all import *
|
||||||
|
MOD = 7514777789
|
||||||
|
|
||||||
|
ring=GF(MOD)
|
||||||
|
|
||||||
|
points = []
|
||||||
|
for line in open('encoded.txt', 'r').read().strip().split('\n'):
|
||||||
|
x, y = line.split(' ')
|
||||||
|
points.append((int(x), int(y)))
|
||||||
|
|
||||||
|
print("building matrices")
|
||||||
|
|
||||||
|
solution = []
|
||||||
|
M = []
|
||||||
|
for point in points:
|
||||||
|
x, y = point
|
||||||
|
solution.append(ring(y % MOD))
|
||||||
|
|
||||||
|
row = []
|
||||||
|
for i in range(3):
|
||||||
|
row.append(pow(x, i, MOD))
|
||||||
|
M.append(row)
|
||||||
|
|
||||||
|
print("converting matrices")
|
||||||
|
|
||||||
|
solution = vector(solution)
|
||||||
|
M = Matrix(M, base_ring=GF(MOD))
|
||||||
|
|
||||||
|
print('solving')
|
||||||
|
open('output.bmp', 'wb').write(bytearray(M.solve_right(solution).tolist()[:-1]))
|
||||||
1
poweranalysis_part_1/out
Normal file
1
poweranalysis_part_1/out
Normal file
File diff suppressed because one or more lines are too long
32
poweranalysis_part_1/sol.py
Executable file
32
poweranalysis_part_1/sol.py
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
from pwn import *
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
address = "saturn.picoctf.net"
|
||||||
|
port = 63821
|
||||||
|
|
||||||
|
def fetch_data(message):
|
||||||
|
conn = remote(address, port, level="warn")
|
||||||
|
conn.recvuntil(b"hex: ")
|
||||||
|
conn.sendline(message)
|
||||||
|
conn.recvuntil(b"[")
|
||||||
|
list_string = conn.recvuntil(b"]", drop=True)
|
||||||
|
conn.close()
|
||||||
|
return [int(s.strip()) for s in list_string.split(b',')]
|
||||||
|
|
||||||
|
data_array = []
|
||||||
|
P = log.progress("fetching timing data")
|
||||||
|
for i in range(16):
|
||||||
|
P.status(f"{i+1}/16")
|
||||||
|
data_array.append(fetch_data(b"00112233445566778899aabbccddeeff"))
|
||||||
|
P.success("16/16 all data fetched")
|
||||||
|
|
||||||
|
data = [0]*len(data_array[0])
|
||||||
|
for i in range(len(data_array)):
|
||||||
|
slice = data_array[i]
|
||||||
|
for j, n in enumerate(slice):
|
||||||
|
data[j] += n
|
||||||
|
|
||||||
|
plt.plot(data)
|
||||||
|
plt.show()
|
||||||
|
|
||||||
Reference in New Issue
Block a user