-
Notifications
You must be signed in to change notification settings - Fork 33
/
hash_crack.py
executable file
·113 lines (101 loc) · 3.91 KB
/
hash_crack.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
import requests
from fake_useragent import UserAgent
from bs4 import BeautifulSoup
from time import sleep
import os
import sys
import argparse
hashes = 'dehashed_hashes.txt'
cracked_hashes = 'cracked_hashes.txt'
parser = argparse.ArgumentParser()
parser.add_argument('-f', action='store', dest='hashes', nargs='?', default=hashes, const=hashes,
help='Input any hash file separated by newline in format {email:hash}.')
parser.add_argument('-o', action='store', dest='cracked_hashes', nargs='?', const=cracked_hashes,
help='Stores all hashes and cracked passwords in files. [dehashed_*.txt]')
args = parser.parse_args()
def init_useragent():
return UserAgent()
def filter_file_hashes(file):
hashes_filtered = []
for hash in file:
hash = hash.strip().split('.com:')[1:][0]
raw_hash = ''.join(hash)
hashes_filtered.append(raw_hash)
# print('\n\n\nNEXT')
# for hash in file:
# hash = hash.strip().split('.com:')[1]
# raw_hash = ''.join(hash)
# print(raw_hash)
# # hashes_filtered.append(raw_hash)
return hashes_filtered
def init_hash_list():
hash_file = open(args.hashes, 'r')
file = hash_file.readlines()
hashes_raw = filter_file_hashes(file)
hash_chunks = [hashes_raw[i:i + 25] for i in range(0, len(hashes_raw), 25)]
return hash_chunks
def create_session(ua):
session = requests.session()
session.proxies = {}
session.proxies['http'] = 'socks5://127.0.0.1:9050'
session.proxies['https'] = 'socks5://127.0.0.1:9050'
headers = {"Connection": "close", "Cache-Control": "max-age=0", "Upgrade-Insecure-Requests": "1",
"Origin": "https://hashes.com", "Content-Type": "application/x-www-form-urlencoded",
"User-Agent": ua.random,
"Accept-Encoding": "gzip, deflate", "Accept-Language": "en-US,en;q=0.9"}
session.cookies.clear()
return session, headers
def make_request(session, raw_hashes, headers):
data = {"hashes": raw_hashes, "vyd": "64", "submitted": "true"}
data_raw = session.post(hashes_com_url, headers=headers, data=data)
data = data_raw.content
return data
def reset_session(raw_hashes):
switchIP()
session, headers = create_session(init_useragent())
data = make_request(session, raw_hashes, headers)
filter_web_hashes(data, raw_hashes)
def filter_web_hashes(data, raw_hashes):
soup = BeautifulSoup(data, 'html.parser')
mydivs = soup.findAll("div", {"class": "py-1"})
if 'Invalid captcha.' in data.decode('utf-8'):
print('[-] Blocked by captcha, retrying...')
reset_session(raw_hashes)
else:
for hash in mydivs:
hash = str(hash)
combo = hash.split('>')[1].split('<')[0]
all_cracked.append(combo)
print('[+] Success! Returned ' + str(len(mydivs)) + ' passwords!')
def switchIP():
print('[+] Restarting TOR...')
os.system('brew services restart tor > /dev/null')
sleep(10)
proxies = {
'http': 'socks5://localhost:9050',
'https': 'socks5://localhost:9050'}
url = 'https://api.ipify.org'
ip = requests.get(url, proxies=proxies).text
print('[+] New IP: ' + ip)
def send_hashes():
ua = init_useragent()
hash_chunks = init_hash_list()
for hash_list in hash_chunks:
switchIP()
print('[+] Sending ' + str(len(hash_list)) + ' hashes...')
session, headers = create_session(ua)
raw_hashes = "\r\n".join(hash_list)
data = make_request(session, raw_hashes, headers)
filter_web_hashes(data, raw_hashes)
def display_hashes():
print('[+] Cracked ' + str(len(all_cracked)) + ' hashes:')
file = open(cracked_hashes, 'a')
for combo in all_cracked:
file.write(combo)
file.write('\n')
print(combo)
if __name__ == '__main__':
all_cracked = []
hashes_com_url = "https://hashes.com:443/en/decrypt/hash"
send_hashes()
display_hashes()