Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2571b59

Browse files
committed
fasdf
1 parent a475a2c commit 2571b59

File tree

3 files changed

+0
-52
lines changed

3 files changed

+0
-52
lines changed
Binary file not shown.

‎2024/googlectf-2024/rev-rustyschool/lol.py

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -67,55 +67,3 @@ def process_block(block: bytes, *, rounds=12) -> bytes:
6767
data += b"\x01"
6868
with open("random.bin.reimpl", "wb") as fp:
6969
fp.write(process_block(data, rounds=12))
70-
71-
def solve_derive(solve_for, m):
72-
73-
R.<x> = PolynomialRing(GF(2))
74-
irreducible_poly = x^16 + x^5 + x^3 + x + 1
75-
F = GF(2^16, modulus=irreducible_poly, name='a')
76-
77-
F_solve_for = [F.from_integer(x) for x in solve_for]
78-
79-
G.<a0, a1, a2, a3, a4, a5> = F[]
80-
if m == 0:
81-
my_id = Ideal(
82-
a0 * a1 + a4 - F_solve_for[0],
83-
a1 * a2 + a5 - F_solve_for[1],
84-
a2 * a3 + a0 - F_solve_for[2],
85-
a3 * a4 + a1 - F_solve_for[3],
86-
a4 * a5 + a2 - F_solve_for[4],
87-
a5 * a0 + a3 - F_solve_for[5],
88-
)
89-
elif m == 1:
90-
my_id = Ideal(
91-
a2 * a3 + a5 - F_solve_for[0],
92-
a3 * a4 + a0 - F_solve_for[1],
93-
a4 * a5 + a1 - F_solve_for[2],
94-
a5 * a0 + a2 - F_solve_for[3],
95-
a0 * a1 + a3 - F_solve_for[4],
96-
a1 * a2 + a4 - F_solve_for[5],
97-
)
98-
assert my_id.dimension() == 0
99-
my_variety = my_id.variety()
100-
fuckshit = [[
101-
variety[a0].integer_representation(),
102-
variety[a1].integer_representation(),
103-
variety[a2].integer_representation(),
104-
variety[a3].integer_representation(),
105-
variety[a4].integer_representation(),
106-
variety[a5].integer_representation()
107-
] for variety in my_variety]
108-
return fuckshit
109-
110-
possible_solution = solve_derive([u16(rv1[i * 2 : i * 2 + 2], m=1) for i in range(6)])
111-
possible_solution = [b"".join(p16(x) for x in possible_solution)]
112-
possible_rv0s = [derive(x, m=0) for x in possible_solution]
113-
114-
b2, cb1, bs, cb2, rv1 = data[:12],data[12:24],data[24:36],data[36:48],data[48:60]
115-
b1 = xor(hashlib.sha1(rv1 + b2).digest()[:12], cb2)
116-
b0 = xor(hashlib.md5(rv0 + b2).digest()[:12], cb1)
117-
i = [int.from_bytes(x, "little") for x in [b0,b1,b2]]
118-
i3 = ((((bs - pow(i[2], i[1], P) % P) * pow(i[0],-1,P)) % P) - i[1]) % P
119-
b3 = i3.to_bytes(12,'little')
120-
b = b0 + b1 + b2 + b3
121-
print(b.hex())

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /