-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecb_attack.py
51 lines (45 loc) · 1.21 KB
/
ecb_attack.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
import requests
from textwrap import wrap
import math
URL = "" #enter url here
s = requests.Session()
chars = list('0123456789:_abcdefghijklmnopqrstuvwxyz{}') #edit chars to guess
#edit based on how the encryption is obtained
def getCred(cred):
payload = {
'creds': cred
}
response = s.post(URL, data=payload)
for line in response.text.split("\n")[-10:]:
if "new-creds" in line:
newcred = line.strip().split(">")[1].split("<")[0]
chunks = wrap(newcred, 32)
return chunks
def getNext(n, known):
attack = n*'0'+"\n"
compare = getCred(attack)
for i in chars:
block = math.floor(len(attack+known)/16)
chunk = getCred(attack+known+i)
if compare[block] == chunk[block]:
return i
return ""
def getBlocks(n, known):
start = n * 16 - 2 - len(known)
for i in range(start, 0, -1):
print(i, known)
add = getNext(i, known)
if not add:
return 0
known += add
return known
def getMax():
i = 1
known = getBlocks(i, "")
while known:
i += 1
known_copy = known
known = getBlocks(i, known)
return known
if __name__ == "__main__":
getMax()