-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapex.py
68 lines (60 loc) · 1.25 KB
/
apex.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from pwn import *
import base64
import string
# nc chall.bsidesalgiers.com 5002
r = remote('chall.bsidesalgiers.com', 5002)
pt = ""
blocksize = 16
def enc(s):
r.sendline(s)
r.recvuntil(': ')
data = r.recvline().decode().strip()
dec = base64.b64decode(data).hex()
return dec
if __name__ == '__main__':
pl = 'A'*15
key = ''
""" TEST
r.recvuntil(': ')
got = enc(pl)
c1 = got[:32]
print(got)
print(c1)
for i in range(ord('!'),ord('~')+1):
# r.recvuntil(': ')
got = enc(pl + chr(i))
c2 = got[:32]
print(i)
if c1==c2:
print(chr(i), i)
break
"""
""" THE ATTACK
https://amritabi0s.wordpress.com/2017/09/18/csaw-quals-2017-babycrypt-writeup/
"""
alphs = string.printable
for k in range(10):
b = ""
for i in range(1,17):
pl = "A"*(16-i)
# r.recvuntil(': ')
r.recv()
g1 = enc(pl)
g1 = g1[:32+k*32]
print("String sent: ",pl)
# for j in range(ord('!'),ord('~')+1):
for j in alphs:
# print(j)
g2 = enc(pl+pt+b+j)
g2 = g2[:32+k*32]
if g1 == g2 and ord(j)!=10 and ord(j)!=0:
print(ord(j), j)
b += j
if j=="}":
print(pt+j,end="")
exit()
break
# print("LAGGED!!!")
pt += b
print(pt)
# shellmates{I_though_AES_w4s_m1l1tary_gr4de_encryp7ion_1n_al1_m0des}