-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHashIdentifier.py
178 lines (172 loc) · 7.22 KB
/
HashIdentifier.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
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
#!/usr/bin/python3
############################################################################
#
# Hash Identifier [ Main Program ]
# © 2020 ABDULKADİR GÜNGÖR All Rights Reserved
# Contact email address: [email protected]
#
# Developper: Abdulkadir GÜNGÖR ([email protected])
# Date: 09/2020
# All Rights Reserved (Tüm Hakları Saklıdır)
#
############################################################################
import os
from lib.cryptography.hash.Hash import detectHash
from lib.hexlib.ReadBinaryFile import readBytes as rbytes
# Ekranı Temizlemek için
def screenClear():
print("\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n") # Konsol dışı kullanımda ekranı temizlemek için
# clear screen
# ********************
# Windows
if os.name=='nt':
os.system('cls')
# Linux or MAC
elif os.name=='posix':
os.system('clear')
# ********************
print("")
# Giriş Menüsü
def menu0() -> int:
while True:
screenClear()
print()
print('\t#####################################################')
print('\t#/*************************************************\#')
print('\t#**||~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~||**#')
print('\t#**|| ||**#')
print('\t#**|| Hash Identifier V1.1 ||**#')
print('\t#**|| 09/2020 ||**#')
print('\t#**|| ||**#')
print('\t#**|| Developer: Abdulkadir GÜNGÖR ||**#')
print('\t#**|| ([email protected]) ||**#')
print('\t#**|| ||**#')
print('\t#**||~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~||**#')
print('\t#\*************************************************/#')
print('\t#####################################################')
print()
print()
print('\t MENU')
print('\t--------------------------------')
print('\t1) Copy the hash from file')
print('\t2) Input the hash (String)')
print('\t3) Input the hash (Hex)')
print()
print()
print( '\tÇıkış (Exit) <<e>>' )
tmp=input('\tSeçim (Selection) : ')
if tmp.strip().lower() == 'e' :
exit(0)
elif tmp.strip().isdigit():
slc = int(tmp.strip())
if 0< slc <4:
return slc
def menu1(slc:int):
while True:
if 0< slc <4:
if slc == 1:
while True:
screenClear()
print()
print('\tDosya utf-8 göre kodlanmalıdır.')
print('\tFile must be encoded according to utf-8')
print()
tmp_file = input('\tFile name : ').strip()
if tmp_file != '':
try:
file_bytes = rbytes(filename=tmp_file)
file_str = file_bytes.decode(encoding='utf-8', errors='strict')
result_list = detectHash( hashStr=file_str.strip() )
showresult(result_list, hash=file_str.strip() )
except:
print('\tHata meydana geldi.(Error has occured)')
print()
print()
print('\tÇıkış (Exit) <<e>>, Geri (Back) <<b>>')
tmp = input('\tDevam (Enter) : ').strip()
if tmp.lower() == 'e':
exit(0)
if tmp.lower() == 'b':
slc = -1
break
if slc == 2:
while True:
screenClear()
print()
hash_str = input('\tHash : ').strip()
if hash_str != '':
result_list = detectHash(hashStr=hash_str)
showresult(result_list, hash=hash_str)
print()
print()
print('\tÇıkış (Exit) <<e>>, Geri (Back) <<b>>')
tmp = input('\tDevam (Enter) : ').strip()
if tmp.lower() == 'e':
exit(0)
if tmp.lower() == 'b':
slc = -1
break
if slc == 3:
while True:
screenClear()
print()
print('\tKarakter dönüşümü utf-8 göre yapılacaktır.')
print('\tCharacter conversion is going to be done according to utf-8.')
print()
print('\tHash (Hex) : 33 64 30 38 ...(Example)')
hash_str_hex = input('\tHash (Hex) : ').strip()
try:
hash_str = ((bytes.fromhex( hash_str_hex )).decode(encoding='utf-8', errors='strict')).strip()
result_list = detectHash(hashStr=hash_str)
showresult(result_list, hash=hash_str)
except:
print('\tHata meydana geldi.(Error has occured)')
print()
print()
print('\tÇıkış (Exit) <<e>>, Geri (Back) <<b>>')
tmp = input('\tDevam (Enter) : ').strip()
if tmp.lower() == 'e':
exit(0)
if tmp.lower() == 'b':
slc = -1
break
else:
break
def showresult(res:list, hash:str):
if res != None:
result_total = len(res)
screenClear()
print()
print( '\tHash (Str) : "{}"'.format(hash) )
print( '\tHash Length : {}'.format(len(hash)) )
print( '\tIsDigit : {:<5} \t IsAlpha : {:<5} \t IsAlphaNumeric : {:<5}'.format( str(hash.isdigit()) , str(hash.isalpha()) , str(hash.isalnum()) ) )
print( '\tIsLower : {:<5} \t IsUpper : {:<5} \t IsPrintable : {:<5}'.format(str(hash.islower()), str(hash.isupper()), str(hash.isprintable()) ) )
print()
if result_total == 0:
print('\tBulunamadı! (Not found!)')
elif result_total == 1:
print('\tMuhtemel Sonuç (Possible Hash)')
print('\t[+] '+res[0].name )
elif result_total == 2:
print('\tMuhtemel Sonuçlar (Possible Hashes)')
print('\t[+] '+res[0].name )
print('\t[+] '+res[1].name )
elif result_total > 2:
print('\tMuhtemel Sonuçlar (Possible Hashes)')
print('\t[+] '+res[0].name )
print('\t[+] '+res[1].name )
print()
print('\tDiğer Muhtemel Sonuçlar (Other Possible Hashes)')
for jj in range(2,result_total):
print('\t[+] ' + res[jj].name)
###
###
###### Ana Fonksiyon (Main Function)
def main():
while True:
menu1( menu0() )
######
###
###
# Program Start
main()