-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsol.py
44 lines (32 loc) · 1.09 KB
/
sol.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
from pwn import *
import subprocess
wordlists = ['10-million-password-list-top-1000000.txt', '500-worst-passwords.txt', 'probable-v2-top12000.txt', 'xato-net-10-million-passwords-1000000.txt']
r = remote('ctfchallenges.ritsec.club', 8080)
print r.recvline()
print r.recvline()
text = r.recvline()
print text
while True:
hash = r.recvline()
print hash
with open('hash', 'w') as file:
file.write(hash)
cracked = False
for wordlist in wordlists:
if wordlist not in text:
continue
print 'Using wordlist {}'.format(wordlist)
result = subprocess.check_output(['john', '--format=NT-opencl' if len(hash) == 32 else '--format=sha512crypt-opencl', '--wordlist={}'.format(wordlist), 'hash'])
print result
result = subprocess.check_output(['john', '--format=NT-opencl' if len(hash) == 32 else '--format=sha512crypt-opencl', '--show', 'hash'])
print result
if '1 password hash cracked' in result:
password = result.splitlines()[0][2:]
print 'PASSWORD: {}'.format(password)
r.sendline(password)
print r.recvline()
cracked = True
break
if not cracked:
print 'FAIL'
break