forked from s0md3v/Hash-Buster
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.py
More file actions
125 lines (118 loc) · 4.92 KB
/
Copy pathdatabase.py
File metadata and controls
125 lines (118 loc) · 4.92 KB
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
123
124
125
import requests
import re
import json
import random
import string
import time
from websocket import create_connection
class Database:
def md5decrypt(hashvalue, hashtype):
"""
md4, md5, sha1, sha256, sha384, sha512
"""
response = requests.post('https://api.md5decrypt.net/', json={
"action": "lookup",
"hashes": [
hashvalue
]
}, headers={
'Authorization': 'Bearer md5d_live_e4453e32_hGr9mR0aETTHqWra6eaz2Q_B6SOYnVvCkLVz1NeRxo0'
}, timeout=15)
if response.status_code == 200:
res = response.json()['results'][0]
# The API auto-detects the hash type; keep only a match whose
# detected type equals the requested one so md5 and ntlm (both
# 32 chars) don't cross over.
if hashtype and res.get('type') and res.get('type') != hashtype:
return False
return res.get('plaintext') or False
else:
return False
def gromweb(hashvalue, hashtype):
"""
md5, sha1
"""
if hashtype == 'md5':
mode = 'md5'
else:
mode = 'hash'
response = requests.get(f'https://{hashtype}.gromweb.com/?{mode}={hashvalue}', headers={'User-Agent': 'Mozilla/5.0'}, timeout=15)
if response.text.find('successfully reversed into the string') > 0:
plain = re.findall(r'<a class="String" href=".+">(.*?)<\/a>', response.text)[0]
return plain
else:
return False
def md5hashing(hashvalue, hashtype):
"""
md5hashing.net via its Meteor DDP-over-SockJS websocket.
Supported: md2, md4, md5, sha1, sha224, sha256, sha384, sha512,
ripemd128/160/256/320, whirlpool, gost, tiger, and more.
"""
deadline = time.monotonic() + 20 # md5hashing.net can be slow to answer
server = random.randint(100, 999)
session = ''.join(random.choices(string.ascii_lowercase + string.digits, k=8))
url = f'wss://md5hashing.net/sockjs/{server}/{session}/websocket'
try:
ws = create_connection(url, timeout=20,
origin='https://md5hashing.net',
header=['User-Agent: Mozilla/5.0'])
except Exception:
return False
try:
ws.send(json.dumps(['{"msg":"connect","version":"1","support":["1","pre2","pre1"]}']))
ws.send(json.dumps([json.dumps({
'msg': 'method', 'method': 'hash.get',
'params': [hashtype, hashvalue], 'id': '1',
})]))
while True:
remaining = deadline - time.monotonic()
if remaining <= 0:
return False
ws.settimeout(remaining)
frame = ws.recv()
if not frame or frame[0] == 'c': # SockJS close / stream end
break
if frame[0] != 'a': # 'o' open / 'h' heartbeat
continue
for raw in json.loads(frame[1:]):
data = json.loads(raw)
if data.get('msg') == 'result' and data.get('id') == '1':
return (data.get('result') or {}).get('value') or False
if data.get('msg') == 'error':
return False
except Exception:
return False
finally:
ws.close()
return False
def crackcrypt(hashvalue, hashtype):
"""
md5, sha1, sha256, sha512
"""
response = requests.post('https://crackcrypt.com/api/v1/lookup',
json={'hash': hashvalue, 'alg': hashtype}, timeout=15)
if response.status_code == 200:
data = response.json()
if data.get('found'):
return data.get('plaintext')
return False
def weakpass(hashvalue, hashtype):
"""
weakpass.com precomputed lookup. The API auto-detects the hash type and
reports it; we only accept a match whose detected type equals the
requested one, so md5 and ntlm (both 32 chars) don't cross over.
Supported: md5, ntlm, sha1, sha256.
"""
# The API only matches lowercase hex; NTLM hashes are often uppercase.
response = requests.get(f'https://weakpass.com/api/v1/search/{hashvalue.lower()}.json',
timeout=15)
if response.status_code == 200:
data = response.json()
# The API may return a single object or a list of matches.
if isinstance(data, list):
data = data[0] if data else {}
if isinstance(data, dict) and data:
if hashtype and data.get('type') and data.get('type') != hashtype:
return False
return data.get('pass') or False
return False