forked from KUSH-COD3R/Go-Hash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgohash.py
More file actions
276 lines (214 loc) · 9.45 KB
/
Copy pathgohash.py
File metadata and controls
276 lines (214 loc) · 9.45 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
#!/usr/bin/env python3
"""
Go-Hash - Hash Identifier
Modified by KUSH-COD3R
"""
import requests
import json
import sys
import os
import time
import subprocess
import platform
from datetime import datetime
def check_internet():
try:
param = '-n' if platform.system().lower() == 'windows' else '-c'
subprocess.check_call(['ping', param, '1', 'www.google.com'],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=5)
return True
except:
return False
COLORS = {
'Bl': '\033[30m',
'Re': '\033[1;31m',
'Gr': '\033[1;32m',
'Ye': '\033[1;33m',
'Blu': '\033[1;34m',
'Mage': '\033[1;35m',
'Cy': '\033[1;36m',
'Wh': '\033[1;37m',
'reset': '\033[0m'
}
def c(text, color):
return f"{COLORS.get(color, '')}{text}{COLORS['reset']}"
HISTORY_FILE = 'hash_history.txt'
def save_history(hash_input, algorithms):
try:
with open(HISTORY_FILE, 'a', encoding='utf-8') as f:
timestamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
f.write(f"[{timestamp}] Hash: {hash_input} | Algorithm: {algorithms}\n")
except Exception as e:
print(f" {c('Warning: Could not save history:', 'Ye')} {e}")
def view_history():
if not os.path.exists(HISTORY_FILE):
print(f" {c('No history found!', 'Ye')}")
return
try:
with open(HISTORY_FILE, 'r', encoding='utf-8') as f:
lines = f.readlines()
if not lines:
print(f" {c('No history found!', 'Ye')}")
return
print(f"\n {c('='*60, 'Wh')}")
print(f" {c('HASH HISTORY', 'Ye')}")
print(f" {c('='*60, 'Wh')}")
for line in lines[-20:]:
print(f" {c(line.strip(), 'Wh')}")
print(f" {c('='*60, 'Wh')}")
except Exception as e:
print(f" {c('Error reading history:', 'Re')} {e}")
def clear_history():
if os.path.exists(HISTORY_FILE):
os.remove(HISTORY_FILE)
print(f" {c('History cleared!', 'Gr')}")
else:
print(f" {c('No history to clear!', 'Ye')}")
def save_to_file(hash_input, algorithms):
filename = f"hash_result_{int(time.time())}.txt"
try:
with open(filename, 'w', encoding='utf-8') as f:
f.write(f"Hash Identifier Result\n")
f.write(f"{'='*40}\n")
f.write(f"Hash: {hash_input}\n")
f.write(f"Algorithm: {algorithms}\n")
f.write(f"Date: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n")
print(f" {c('Result saved to:', 'Gr')} {c(filename, 'Ye')}")
return True
except Exception as e:
print(f" {c('Error saving file:', 'Re')} {e}")
return False
def batch_hash_check(hashes):
results = []
print(f"\n {c('Processing', 'Ye')} {c(str(len(hashes)), 'Gr')} {c('hashes...', 'Ye')}\n")
api_url = 'https://hashes.com/en/api/identifier'
for i, hash_input in enumerate(hashes, 1):
try:
response = requests.get(api_url, params={'hash': hash_input}, timeout=10)
data = response.json()
if data.get('success'):
algorithms = data.get('algorithms', [])
algoritm_hash = ', '.join(algorithms) if algorithms else 'Unknown'
results.append((hash_input, algoritm_hash, 'Success'))
print(f" {c('[', 'Gr')}{c(str(i), 'Wh')}{c(']', 'Gr')} {c(hash_input, 'Wh')} {c('->', 'Ye')} {c(algoritm_hash, 'Gr')}")
else:
error_msg = data.get('message', 'Unknown')
results.append((hash_input, error_msg, 'Failed'))
print(f" {c('[', 'Re')}{c(str(i), 'Wh')}{c(']', 'Re')} {c(hash_input, 'Wh')} {c('->', 'Ye')} {c(error_msg, 'Re')}")
time.sleep(0.5)
except Exception as e:
results.append((hash_input, str(e), 'Error'))
print(f" {c('[', 'Re')}{c(str(i), 'Wh')}{c(']', 'Re')} {c(hash_input, 'Wh')} {c('->', 'Ye')} {c('Error', 'Re')}")
return results
def banner():
print(f"""
{c(' ██████╗ ██████╗ ██╗ ██╗ █████╗ ███████╗██╗ ██╗', 'Gr')}
{c(' ██╔════╝ ██╔═══██╗ ██║ ██║██╔══██╗██╔════╝██║ ██║', 'Gr')}
{c(' ██║ ███╗██║ ██║█████╗███████║███████║███████╗███████║', 'Gr')}
{c(' ██║ ██║██║ ██║╚════╝██╔══██║██╔══██║╚════██║██╔══██║', 'Gr')}
{c(' ╚██████╔╝╚██████╔╝ ██║ ██║██║ ██║███████║██║ ██║', 'Gr')}
{c(' ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝', 'Gr')}
{c(' <<------ CODE BY HUNX ------>>', 'Wh')}
{c(' < Hash identified >', 'Wh')}
""")
def main_menu():
print(f"""
{c('[1]', 'Gr')} {c('Identify Single Hash', 'Wh')}
{c('[2]', 'Gr')} {c('Batch Hash Check', 'Wh')}
{c('[3]', 'Gr')} {c('View History', 'Wh')}
{c('[4]', 'Gr')} {c('Clear History', 'Wh')}
{c('[5]', 'Gr')} {c('Exit', 'Wh')}
""")
def identify_hash():
api_url = 'https://hashes.com/en/api/identifier'
print(f"\n {c('[+]', 'Gr')} {c('Enter Your Hash :', 'Gr')}", end=' ')
hash_input = input()
if not hash_input.strip():
print(f" {c('Error: Hash cannot be empty!', 'Re')}")
return
try:
response = requests.get(api_url, params={'hash': hash_input}, timeout=10)
response.raise_for_status()
data = response.json()
if data.get('success'):
algorithms = data.get('algorithms', [])
algoritm_hash = ', '.join(algorithms) if algorithms else 'Unknown'
time.sleep(2)
print(f'\n {c("="*20, "Wh")} {c("Show Algorithm Hash", "Ye")} {c("="*20, "Wh")}')
print(f'\n {c("[+]", "Gr")} {c("Hash :", "Gr")} {hash_input}')
print(f' {c("[+]", "Gr")} {c("Algorithm :", "Gr")} {c(algoritm_hash, "Ye")}')
print(f'\n {c("="*56, "Wh")}')
save_history(hash_input, algoritm_hash)
save_opt = input(f"\n {c('Save result to file?', 'Wh')} {c('Y/N', 'Gr')} {c(':', 'Wh')} ").lower()
if save_opt == 'y':
save_to_file(hash_input, algoritm_hash)
else:
error_msg = data.get('message', 'Unknown error')
print(f' {c("[!]", "Gr")} {c("Hash :", "Gr")} {c(error_msg, "Re")}')
except requests.exceptions.RequestException as e:
print(f' {c("Error:", "Re")} {c(str(e), "Re")}')
except json.JSONDecodeError:
print(f' {c("Error: Invalid response from server", "Re")}')
except Exception as e:
print(f' {c("Error:", "Re")} {c(str(e), "Re")}')
def batch_mode():
print(f"\n {c('Enter hashes (one per line).', 'Wh')}")
print(f" {c('Press', 'Wh')} {c('Enter', 'Gr')} {c('twice to finish:', 'Wh')}")
hashes = []
while True:
h = input(" > ")
if h.strip():
hashes.append(h.strip())
else:
break
if not hashes:
print(f" {c('No hashes entered!', 'Ye')}")
return
results = batch_hash_check(hashes)
success_count = sum(1 for r in results if r[2] == 'Success')
print(f"\n {c('Results:', 'Ye')} {c(str(success_count), 'Gr')}/{c(str(len(results)), 'Wh')} {c('successful', 'Wh')}")
save_opt = input(f"\n {c('Save all results to file?', 'Wh')} {c('Y/N', 'Gr')} {c(':', 'Wh')} ").lower()
if save_opt == 'y':
filename = f"batch_results_{int(time.time())}.txt"
try:
with open(filename, 'w', encoding='utf-8') as f:
f.write(f"Batch Hash Check Results\n")
f.write(f"{'='*50}\n")
f.write(f"Date: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n")
f.write(f"{'='*50}\n\n")
for hash_input, algo, status in results:
f.write(f"Hash: {hash_input}\n")
f.write(f"Algorithm: {algo}\n")
f.write(f"Status: {status}\n")
f.write(f"{'-'*50}\n")
print(f" {c('Results saved to:', 'Gr')} {c(filename, 'Ye')}")
except Exception as e:
print(f" {c('Error saving file:', 'Re')} {e}")
def main():
if not check_internet():
print(c("No internet connection! Please check your network.", "Re"))
sys.exit(1)
banner()
while True:
main_menu()
choice = input(f" {c('Select option:', 'Wh')} {c('[1-5]', 'Gr')} ").strip()
if choice == '1':
identify_hash()
elif choice == '2':
batch_mode()
elif choice == '3':
view_history()
elif choice == '4':
clear_history()
elif choice == '5':
print(c(" Exiting...", "Ye"))
sys.exit(0)
else:
print(c(" Invalid option!", "Re"))
print()
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print(f"\n{c(' Program stopped...', 'Wh')}")
sys.exit(0)