-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathP-Decode.py
122 lines (90 loc) · 3.09 KB
/
P-Decode.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import itertools
import sys
import time
import svg
from hashlib import sha1
from binascii import unhexlify
from binascii import hexlify
if sys.version_info >= (3, 0):
sha = sha1
else:
import _sha
sha = _sha.new
'''
android pattern cracker v0.5
Coded by MGF15
file in android -> /data/system/gesture.key
'''
logo = '''
|~) |~\ _ _ _ _| _
|~ ~~|_/}_(_(_)(_|}_ v0.5\n
[ {41}ndr0id Pa77ern Cr4ck t00l. ]
'''
now = time.time()
x_list = ["\x00", "\x01", "\x02", "\x03", "\x04",
"\x05", "\x06", "\x07", "\x08"]
def crack(hash):
print (logo)
print ('[*] Pattern SHA1 Hash : %s\n' % hash.upper())
# make it as fast as possible
# pattern -> 1234 -> 01020304 -> \x01\x02\x03\x04 then sha1 hash
for i in range(4, 10):
permutations = itertools.permutations(x_list, i)
perm_list = map(''.join, permutations)
for j in perm_list:
sha_hash = sha(j.encode('utf-8')).hexdigest()
if hash == sha_hash:
p = hexlify(j.encode('utf-8')).decode('utf-8')
pt = ''.join([p[o] for o in range(1, len(p), 2)])
print ('[+] Pattern Length \t: %s\n' % len(pt))
print ('[+] Pattern \t\t: %s\n' % pt)
patt = svg.draw(pt)
sv = open('%s.svg' % pt, 'wb')
sv.write(patt.encode('utf-8'))
sv.close()
print ('[+] Pattern SVG\t\t: %s.svg\n' % pt)
print ('[*] Time \t\t: %s sec' % round(time.time() - now, 2))
exit()
print ('[-] Pattern not found !')
if __name__ == "__main__":
if len(sys.argv) < 3:
print(logo)
print ('p-decode.py [-p hash ] or [-f gesture.key ] or [-g pattern ]')
elif sys.argv[1] == '-f':
try:
file = open(sys.argv[2], 'rb').read()
except:
print(logo)
print ("[-] File not found or it's unreadable\n")
exit()
hash = hexlify(file) # file.encode('hex')
if len(file) == 0 or len(file) > 30:
print(logo)
print ("[-] empty file or it's too large")
exit()
crack(hash.decode('utf-8'))
elif sys.argv[1] == '-p':
hash = sys.argv[2]
hash = hash.lower() if hash.isupper() else hash
crack(hash)
elif sys.argv[1] == '-g':
print (logo)
pat = sys.argv[2]
try:
gt = ''.join([chr(int(i)) for i in pat])
patt = svg.draw(pat)
sv = open('%s.svg' % pat, 'wb')
sv.write(patt.encode('utf-8'))
sv.close()
print ('[+] Pattern SVG\t\t: %s.svg\n' % pat)
output = open('gesture.key', 'wb')
output.write(sha(gt.encode('utf-8')).digest())
output.close()
print ('[+] Pattern file\t: gesture.key')
except:
print('[-] Pattern must be valid number from 0-8 see info.svg\n')
print(
'[!] if you want to make pattern like letter M '
'the pattern will be "6304258"')
else:
exit()