-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdhc.py
More file actions
executable file
·1481 lines (1195 loc) · 64.1 KB
/
dhc.py
File metadata and controls
executable file
·1481 lines (1195 loc) · 64.1 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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- coding: binary -*-
# Distributed Hash Cracker.
# Coded by GWF (Guerrilla Warfare)
# https://twitter.com/GuerrillaWF
# Native imports.
import re
import os
import sys
import time
import json
import getopt
import socket
import string
import random
import sqlite3
import hashlib
import itertools
import threading
from core.libs import socks #Ripped lib.
# Dependency imports
import requests
class paint():
# Console paint
N = '\033[0m' # (normal)
W = '\033[1;37m' # white
R = '\033[31m' # red
G = '\033[32m' # green
O = '\033[33m' # orange
B = '\033[34m' # blue
P = '\033[35m' # purple
C = '\033[36m' # cyan
T = '\033[93m' # tan
Y = '\033[1;33m' # yellow
GR = '\033[37m' # gray
BR = '\033[2;33m' # brown
# TO DO:
# Maybe go out and get a new user-agent string
# Improve accuracy of session file check after password is found.
# Use regex to check each database file faster.
# Need to know information
MD5SIGN = paint.R+"[MD5]:"+paint.N
SHA1SIGN = paint.R+"[SHA1]:"+paint.N
SHA256SIGN = paint.R+"[SHA256]:"+paint.N
SHA384SIGN = paint.R+"[SHA384]:"+paint.N
SHA512SIGN = paint.R+"[SHA512]:"+paint.N
TYPE = paint.W+"[TYPE]:"+paint.N
INFO = paint.W+"[INFO]:"+paint.N
ERROR = paint.R+"[ERROR]:"+paint.N
QueryFailed = paint.R+"query failed!"+paint.N
QuerySuccess = paint.O+"Password found!"+paint.N
GLOBALUSERAGENT = {"User-Agent":"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"}
# Brute force method in house dictionary
CHARS = string.letters + string.digits + string.punctuation
class UserInformation():
""" User API credentials to acces json data inside home-brewed config file. """
HTTP_PROXY = {} # Set the proxy yourself.
SOCKS5_PROXY = [] # Set the proxy yourself.
# When production code is published, change dict to an empty dict.
HTTP_PROXY["http"] = ""
#HTTP_PROXY["https"] = "" # Does not work at this time.
SOCKS5_PROXY.append("127.0.0.1")
user = UserInformation()
class Utilities():
def Acceleration(self, mtarget):
""" Thread certain processes."""
process = threading.Thread(target=mtarget)
return process.start()
# Get Socks 5 Requests | Will travel through here.
def GetSOCKS5Request(self, url):
""" Global get request w/browser UserAgent string."""
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, user.SOCKS5_PROXY[0], 9050) # TOR network socket
socket.socket = socks.socksocket # use TOR
GetRequestSession = requests.Session()
response = GetRequestSession.get(url, headers=GLOBALUSERAGENT)
return response # Just return the object, not the content.
# Post Socks 5 Requests | Will travel through here.
def PostSOCKS5Request(self, url, params):
""" Global get request w/browser UserAgent string."""
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, user.SOCKS5_PROXY[0], 9050) # TOR network socket
socket.socket = socks.socksocket # use TOR
PostRequestSession = requests.Session()
response = PostRequestSession.post(url, headers=GLOBALUSERAGENT, data=params)
return response # Just return the object, not the content.
# Get Requests HTTP style
def GetHTTPRequest(self, url):
GetRequestSession = requests.Session()
GetRequestSession.proxies = user.HTTP_PROXY['http'] # Only accepts http at this time.
response = GetRequestSession.get(url, headers=GLOBALUSERAGENT)
return response # Just return the object, not the content.
# Post Requests HTTP style
def PostHTTPRequest(self, url, params):
PostRequestSession = requests.Session()
PostRequestSession.proxies = user.HTTP_PROXY['http']
response = PostRequestSession.post(url, headers=GLOBALUSERAGENT, data=params)
return response # Just return the object, not the content.
utilities = Utilities()
class FileOperations():
def HashAWordList(self):
"""
Turn ascii/plain-text/wordlists into hash:pass pairs.
"""
try:
with open(sys.argv[2], 'r') as wl:
choice = raw_input("\nHash Type: ")
fn5 = "newly_hashed_md5_wordlist.txt"
fn1 = "newly_hashed_sha1_wordlist.txt"
fn224 = "newly_hashed_sha224_wordlist.txt"
fn256 = "newly_hashed_sha256_wordlist.txt"
fn384 = "newly_hashed_sha384_wordlist.txt"
fn512 = "newly_hashed_sha512_wordlist.txt"
if choice == "md5":
time.sleep(2)
print INFO, "Turning your wordlist {} into ".format(paint.W+sys.argv[2]+paint.N)+paint.R+"[MD5] hash"+paint.N+":"+paint.B+"pass"+paint.N+" pairs ..."
with open(fn5, "w") as file:
for i in wl:
i = i.replace("\n",'')
md5 = hashlib.md5(i)
md5ers = md5.hexdigest() +":"+ i
file.write(md5ers + "\n")
time.sleep(2)
print INFO, "MD5 hash:pass pairs made."
elif choice == "sha1":
with open(fn1, "w") as file:
for i in wl:
i = i.replace("\n", "")
sha1 = hashlib.sha1(i)
sha1ers = sha1.hexdigest() + ":" + i
file.write(sha1ers + "\n")
print "Wrote:", fn1
elif choice == "sha224":
with open(fn224, "w") as file:
for i in wl:
i = i.replace("\n", "")
sha224 = hashlib.sha224(i)
sha224ers = sha224.hexdigest() + ":" + i
file.write(sha224ers + "\n")
print "Wrote:", fn224
elif choice == "sha256":
with open(fn256, "w") as file:
for i in wl:
i = i.replace("\n", "")
sha256 = hashlib.sha256(i)
sha256ers = sha256.hexdigest() + ":" + i
file.write(sha256ers + "\n")
print "Wrote:",
elif choice == "sha384":
with open(fn384, "w") as file:
for i in wl:
i = i.replace("\n", "")
sha384 = hashlib.sha384(i)
sha384ers = sha384.hexdigest() + ":" + i
file.write(sha384ers + "\n")
elif choice == "sha512":
with open(fn512, "w") as file:
for i in wl:
i = i.replace("\n", "")
sha512 = hashlib.sha512(i)
sha512ers = sha512.hexdigest() + ":" + i
file.write(sha512ers + "\n")
else:
usage()
except Exception, e:
print e
print """
Invalid wordlist."""
usage()
sys.exit(0)
fileoperations = FileOperations()
class DatabaseOperations():
def QueryDatabaseForSingleHash(self, InputHash):
"""
Ping/Query the database for a single given hash.
"""
try:
# MD5 Session file
# re.findall(r"([a-fA-F\d]{32})", data)
if len(InputHash) == 32:
with open(os.path.dirname(__file__) + '/core/database/cracked_MD5_hashes.session', 'r') as md5_session_file:
#if len(InputHash) == 32: HTS = MD5SIGN
print "\n", INFO, "Checking your "+paint.Y+"MD5_session"+paint.N+" file for {} ...".format(paint.BR+InputHash+paint.N)
# The actual search
for x in md5_session_file:
x = x.replace("\n", "")
if len(InputHash) == 32: y = x[:32]
# y = x[:32] only look through md5 hashes
# Compare hashes to to hashes in session file.
if InputHash in y:
time.sleep(1)
print INFO, QuerySuccess
time.sleep(2)
print INFO, "Password is:", paint.C+x[33:]+paint.N + "\n"
time.sleep(2)
break
if InputHash not in y: # Some form of decision making.
time.sleep(2)
print INFO, paint.BR+InputHash+paint.N, "was not found in your "+paint.Y+"MD5_session"+paint.N+" file.\n"
time.sleep(1)
sys.exit(0)
elif len(InputHash) == 40:
# re.findall(r"([a-fA-F\d]{40})", data)
with open(os.path.dirname(__file__) + '/core/database/cracked_SHA1_hashes.session', 'r') as sha1_session_file:
#if len(InputHash) == 40: HTS = SHA1SIGN
print "\n", INFO, "Checking your "+paint.Y+"SHA1_session"+paint.N+" file for {} ...".format(paint.BR+InputHash+paint.N)
for x in sha1_session_file:
x = x.replace("\n", "")
if len(InputHash) == 40: y = x[:40]
# y = x[:40] only look through sha1 hashes
if InputHash in y:
time.sleep(2)
print INFO, QuerySuccess
time.sleep(1)
print INFO, "Password is:", paint.C+x[41:]+paint.N + "\n"
time.sleep(2)
break
if InputHash not in y: # Some form of decision making.
time.sleep(2)
print INFO, paint.BR+InputHash+paint.N, "was not found in your "+paint.Y+"SHA1_session"+paint.N+" file.\n"
time.sleep(1)
sys.exit(0)
#with open(os.path.dirname(__file__) + '/core/database/cracked_SHA224_hashes.session', 'r') as sha224_session_file:
elif len(InputHash) == 64:
# re.findall(r"([a-fA-F\d]{64})", data)
with open(os.path.dirname(__file__) + '/core/database/cracked_SHA256_hashes.session', 'r') as sha256_session_file:
#if len(InputHash) == 64: HTS = SHA256SIGN
print "\n", INFO, "Checking your "+paint.Y+"SHA256_session"+paint.N+" file for {} ...".format(paint.BR+InputHash+paint.N)
for x in sha256_session_file:
x = x.replace("\n", "")
if len(InputHash) == 64: y = x[:64]
# y = x[:40] only look through sha256 hashes
if InputHash in y:
time.sleep(2)
print INFO, QuerySuccess
time.sleep(2)
print INFO, "Password is:", paint.C+x[65:]+paint.N + "\n"
time.sleep(2)
break
if InputHash not in y: # Some form of decision making.
time.sleep(2)
print INFO, paint.BR+InputHash+paint.N, "was not found in your "+paint.Y+"SHA256_session"+paint.N+" file.\n"
time.sleep(1)
sys.exit(0)
elif len(InputHash) == 96:
# re.findall(r"([a-fA-F\d]{96})", data)
with open(os.path.dirname(__file__) + '/core/database/cracked_SHA384_hashes.session', 'r') as sha384_session_file:
#if len(InputHash) == 96: HTS = SHA384SIGN
print "\n", INFO, "Checking your "+paint.Y+"SHA384_session"+paint.N+" file for {} ...".format(paint.BR+InputHash+paint.N)
for x in sha384_session_file:
x = x.replace("\n", "")
# Compare hashes to to hashes in session file.
if InputHash in y:
#print x | for debugging output.
if len(InputHash) == 96: y = x[:96]
# y = x[:40] only look through sha2384 hashes
if InputHash in y:
time.sleep(2)
print INFO, QuerySuccess
time.sleep(2)
print INFO, "Password is:", paint.C+x[97:]+paint.N + "\n"
time.sleep(2)
break
if InputHash not in y: # Some form of decision making.
time.sleep(2)
print INFO, paint.BR+InputHash+paint.N, "was not found in your "+paint.Y+"SHA384_session"+paint.N+" file.\n"
time.sleep(1)
sys.exit(0)
elif len(InputHash) == 128:
# re.findall(r"([a-fA-F\d]{128})", data)
with open(os.path.dirname(__file__) + '/core/database/cracked_SHA512_hashes.session', 'r') as sha512_session_file:
#if len(InputHash) == 128: HTS = SHA512SIGN
print "\n", INFO, "Checking your "+paint.Y+"SHA512_session"+paint.N+" file for {} ...".format(paint.BR+InputHash+paint.N)
# The actual search
for x in sha512_session_file:
x = x.replace("\n", "")
# Compare hashes to to hashes in session file.
if InputHash in y:
#print x | for debugging output.
if len(InputHash) == 128: y = x[:128]
# y = x[:40] only look through sha2384 hashes
if len(InputHash) == 128:
time.sleep(2)
print INFO, QuerySuccess
time.sleep(2)
print INFO, "Password is:", paint.C+x[129:]+paint.N + "\n"
time.sleep(2)
break
if InputHash not in x: # Some form of decision making.
time.sleep(2)
print INFO, paint.BR+InputHash+paint.N, "was not found in your "+paint.Y+"SHA512_session"+paint.N+" file.\n"
time.sleep(1)
sys.exit(0)
except IOError as e:
#print e
print INFO, ""+paint.Y+"Session"+paint.N+" file(s) not found!\n"
def QueryDatabaseWithFile(self):
""" Query the session file with file of hashes and display results."""
pass
def LoadHashedWordlistIntoDatabse():
""" Load a hashed wordlist into your session file. """
# Detect the hash:pass format
pass
def WriteMD5PairToFile(self, InputHash, Password):
print INFO, "checking the "+paint.Y+"MD5_session"+paint.N+" file for the above Hash/Password pair ..."
# print INFO, "Writing hash/password pair to disk ..."
with open(os.path.dirname(__file__) + '/core/database/cracked_MD5_hashes.session', 'a') as file:
with open(os.path.dirname(__file__) + '/core/database/cracked_MD5_hashes.session', 'r') as f:
for x in f:
if InputHash in x:
time.sleep(2)
print INFO, "Hash/Password pair already recorded.\n"
sys.exit(0)
time.sleep(1)
print INFO, "Hash/Password pair not found in the "+paint.Y+"MD5_session"+paint.N+" file ..."
time.sleep(2)
print INFO, "Writing hash/password pair to the "+paint.Y+"MD5_session"+paint.N+" file ...\n"
file.write(InputHash + ":")
file.write(Password + "\n")
time.sleep(2)
sys.exit(0)
def WriteSHA1PairToFile(self, InputHash, Password):
print INFO, "checking the "+paint.Y+"SHA1_session"+paint.N+" file for the above Hash/Password pair ..."
# print INFO, "Writing hash/password pair to disk ..."
with open(os.path.dirname(__file__) + '/core/database/cracked_SHA1_hashes.session', 'a') as file:
with open(os.path.dirname(__file__) + '/core/database/cracked_SHA1_hashes.session', 'r') as f:
for x in f:
if InputHash in x:
time.sleep(2)
print INFO, "Hash/Password pair already recorded.\n"
sys.exit(0)
#print INFO, "Hash/Password pair not"
time.sleep(2)
print INFO, "Hash/Password pair not found in the "+paint.Y+"SHA1_session"+paint.N+" file."
time.sleep(2)
print INFO, "Writing hash/password pair to the "+paint.Y+"SHA1_session"+paint.N+" file ...\n"
file.write(InputHash + ":")
file.write(Password + "\n")
time.sleep(2)
sys.exit(0)
def WriteSHA224PairToFile(self, InputHash, Password):
print INFO, "checking the "+paint.Y+"SHA224_session"+paint.N+" file for the above Hash/Password pair ..."
# print INFO, "Writing hash/password pair to disk ..."
with open(os.path.dirname(__file__) + '/core/database/cracked_SHA224_hashes.session', 'a') as file:
with open(os.path.dirname(__file__) + '/core/database/cracked_SHA224_hashes.session', 'r') as f:
for x in f:
if InputHash in x:
time.sleep(2)
print INFO, "Hash/Password pair already recorded.\n"
sys.exit(0)
#print INFO, "Hash/Password pair not"
time.sleep(2)
print INFO, "Hash/Password pair not found in the "+paint.Y+"SHA224_session"+paint.N+" file."
time.sleep(2)
print INFO, "Writing hash/password pair to the"+paint.Y+"SHA224_session"+paint.N+" file ...\n"
file.write(InputHash + ":")
file.write(Password + "\n")
time.sleep(2)
sys.exit(0)
def WriteSHA256PairToFile(self, InputHash, Password):
print INFO, "checking the SHA256 "+paint.Y+"session"+paint.N+" file for the above Hash/Password pair ..."
# print INFO, "Writing hash/password pair to disk ..."
with open(os.path.dirname(__file__) + '/core/database/cracked_SHA256_hashes.session', 'a') as file:
with open(os.path.dirname(__file__) + '/core/database/cracked_SHA256_hashes.session', 'r') as f:
for x in f:
if InputHash in x:
time.sleep(2)
print INFO, "Hash/Password pair already recorded.\n"
sys.exit(0)
#print INFO, "Hash/Password pair not"
print INFO, "Hash/Password pair not found in "+paint.Y+"session"+paint.N+" file."
time.sleep(2)
print INFO, "Writing hash/password pair to "+paint.Y+"session"+paint.N+" file ...\n"
file.write(InputHash + ":")
file.write(Password + "\n")
time.sleep(2)
sys.exit(0)
def WriteSHA384PairToFile(self, InputHash, Password):
print INFO, "checking the SHA384 "+paint.Y+"session"+paint.N+" file for the above Hash/Password pair ..."
# print INFO, "Writing hash/password pair to disk ..."
with open(os.path.dirname(__file__) + '/core/database/cracked_SHA384_hashes.session', 'a') as file:
with open(os.path.dirname(__file__) + '/core/database/cracked_SHA384_hashes.session', 'r') as f:
for x in f:
if InputHash in x:
time.sleep(2)
print INFO, "Hash/Password pair already recorded.\n"
sys.exit(0)
#print INFO, "Hash/Password pair not"
print INFO, "Hash/Password pair not found in "+paint.Y+"session"+paint.N+" file."
time.sleep(2)
print INFO, "Writing hash/password pair to "+paint.Y+"session"+paint.N+" file ...\n"
file.write(InputHash + ":")
file.write(Password + "\n")
time.sleep(2)
sys.exit(0)
def WriteSHA512PairToFile(self, InputHash, Password):
print INFO, "checking the SHA512 "+paint.Y+"session"+paint.N+" file for the above Hash/Password pair ..."
# print INFO, "Writing hash/password pair to disk ..."
with open(os.path.dirname(__file__) + '/core/database/cracked_SHA512_hashes.session', 'a') as file:
with open(os.path.dirname(__file__) + '/core/database/cracked_SHA512_hashes.session', 'r') as f:
for x in f:
if InputHash in x:
time.sleep(2)
print INFO, "Hash/Password pair already recorded.\n"
sys.exit(0)
#print INFO, "Hash/Password pair not"
print INFO, "Hash/Password pair not found in "+paint.Y+"session"+paint.N+" file."
time.sleep(2)
print INFO, "Writing hash/password pair to "+paint.Y+"session"+paint.N+" file ...\n"
file.write(InputHash + ":")
file.write(Password + "\n")
time.sleep(2)
sys.exit(0)
databaseoperations = DatabaseOperations()
class HashCracking():
# Hash Brute Forcing ----------------------------------------------------------------
def BruteForceByWordList(self, InputHash):
wordlist = sys.argv[4]
with open(wordlist, 'r') as f:
print "\n", INFO,"Loaded words from {}".format(wordlist)
for line in f:
#print TYPE, MD5SIGN, paint.B+InputHash+paint.N
if len(InputHash) == 32:
#time.sleep(1)
hash = hashlib.md5()
hash.update(line[:-1])
if InputHash in hash.hexdigest():
time.sleep(1)
print INFO, QuerySuccess
time.sleep(1)
print INFO, "Password is:", paint.C+line+paint.N
time.sleep(2)
WriteMD5PairToFile(InputHash, line)
if hash.hexdigest() not in InputHash:
time.sleep(1)
print INFO, "Your wordlist "+paint.R+"failed"+paint.N+", try another wordlist.\n"
time.sleep(1)
sys.exit(0)
"""
elif len(InputHash) == 40:
time.sleep(1)
print TYPE, SHA1SIGN, paint.B+InputHash+paint.N
for word in words:
hash = hashlib.sha1(word[:-1])
if hash.hexdigest() in InputHash:
time.sleep(1)
print INFO, QuerySuccess
time.sleep(1)
print INFO, "Password is:", paint.C+word.replace("\n", "")+paint.N
time.sleep(2)
WriteMD5PairToFile(InputHash, word)
if hash.hexdigest() not in InputHash.lower():
time.sleep(1)
print INFO, "Your wordlist "+paint.R+"failed"+paint.N+" try another wordlist."
time.sleep(1)
sys.exit(0)
elif len(InputHash) == 64:
time.sleep(1)
print TYPE, SHA256SIGN, paint.B+InputHash+paint.N
for word in words:
hash = hashlib.sha256(word[:-1])
if hash.hexdigest()in InputHash:
time.sleep(1)
print INFO, QuerySuccess
time.sleep(1)
print INFO, "Password is:", paint.C+word.replace("\n", "")+paint.N
time.sleep(2)
WriteMD5PairToFile(InputHash, word)
if hash.hexdigest() not in InputHash:
time.sleep(1)
print INFO, "Your wordlist "+paint.R+"failed"+paint.N+" try another wordlist."
time.sleep(1)
sys.exit(0)
elif len(InputHash) == 96:
time.sleep(1)
print TYPE, SHA384SIGN, paint.B+InputHash+paint.N
for word in words:
hash = hashlib.sha384(word[:-1])
if hash.hexdigest()in InputHash:
time.sleep(1)
print INFO, QuerySuccess
time.sleep(1)
print INFO, "Password is:", paint.C+word.replace("\n", "")+paint.N
time.sleep(2)
WriteMD5PairToFile(InputHash, word)
if hash.hexdigest() not in InputHash:
time.sleep(1)
print INFO, "Your wordlist "+paint.R+"failed"+paint.N+" try another wordlist."
time.sleep(1)
sys.exit(0)
else:
print "\n ", ERROR, "Hash value length not supported!"
usage()
"""
"""
elif len(algo) == 128:
for word in words:
hash = hashlib.sha512(word[:-1])
value = hash.hexdigest()
if pw == value:
print INFO, QuerySuccess
time.sleep(1)
print INFO, "Password is:", word ,"\n"
time.sleep(1)
with open('cracked_hash_passwords.txt', 'a') as file:
file.write("\nCracked [MD5] Hashes:\n")
file.write(pw + ":")
file.write(word + "\n")
"""
def BruteForceByAlgorithm(self, InputHash):
start_time = time.time()
if len(InputHash) == 32:
for length in range(0,20):
for entry in itertools.product(CHARS ,repeat = length):
password = ''.join(entry)
m = hashlib.md5()
m.update(password)
if m.hexdigest() == InputHash.lower():
stop_time = time.time()
print INFO, QuerySuccess
time.sleep(0)
time.sleep(2)
print INFO, "Password is:", paint.C+password+paint.N
print INFO, "cracked in", int(float(stop_time - start_time)),"seconds."
databaseoperations.WriteMD5PairToFile(InputHash, password)
sys.exit(0)
time.sleep(2)
print INFO, "Trying "+paint.W+"{0}".format(len(password) + 1)+paint.N+" character passwords against "+paint.C+"{0}".format(InputHash)+paint.N+" "
elif len(InputHash) == 40:
for length in range(0,20):
for entry in itertools.product(CHARS ,repeat = length):
password = ''.join(entry)
m = hashlib.sha1()
m.update(password)
if m.hexdigest() == InputHash.lower():
time.sleep(2)
print INFO, QuerySuccess
time.sleep(2)
print INFO, "Password is:", paint.C+password+paint.N
print INFO, "cracked in", int(float(stop_time - start_time)),"seconds."
databaseoperations.WriteSHA1PairToFile(InputHash, password)
sys.exit(0)
time.sleep(2)
print INFO, "Trying "+paint.W+"{0}".format(len(password) + 1)+paint.N+" character passwords against "+paint.C+"{0}".format(InputHash)+paint.N+" "
elif len(InputHash) == 64:
for length in range(0,20):
for entry in itertools.product(CHARS ,repeat = length):
password = ''.join(entry)
m = hashlib.sha256()
m.update(password)
if m.hexdigest() == InputHash.lower():
time.sleep(2)
print INFO, QuerySuccess
time.sleep(2)
print INFO, "Password is:", paint.C+password+paint.N
print INFO, "cracked in", int(float(stop_time - start_time)),"seconds."
databaseoperations.WriteSHA256PairToFile(InputHash, password)
sys.exit(0)
time.sleep(2)
print INFO, "Trying "+paint.W+"{0}".format(len(password) + 1)+paint.N+" character passwords against "+paint.C+"{0}".format(InputHash)+paint.N+" "
elif len(InputHash) == 96:
for length in range(0,20):
for entry in itertools.product(CHARS ,repeat = length):
password = ''.join(entry)
m = hashlib.sha384()
m.update(password)
if m.hexdigest() == InputHash:
time.sleep(2)
print INFO, QuerySuccess
time.sleep(2)
print INFO, "Password is:", paint.C+password+paint.N
print INFO, "cracked in", int(float(stop_time - start_time)),"seconds."
databaseoperations.WriteSHA384PairToFile(InputHash, password)
sys.exit(0)
time.sleep(2)
print INFO, "Trying "+paint.W+"{0}".format(len(password) + 1)+paint.N+" character passwords against "+paint.C+"{0}".format(InputHash)+paint.N+" "
elif len(InputHash) == 128:
for length in range(0,20):
for entry in itertools.product(CHARS ,repeat = length):
password = ''.join(entry)
m = hashlib.sha512()
m.update(password)
if m.hexdigest() == InputHash:
time.sleep(2)
print INFO, QuerySuccess
time.sleep(2)
print INFO, "Password is:", paint.C+password+paint.N
print INFO, "cracked in", int(float(stop_time - start_time)),"seconds."
databaseoperations.WriteSHA512PairToFile(InputHash, password)
sys.exit(0)
time.sleep(2)
print INFO, "Trying "+paint.W+"{0}".format(len(password) + 1)+paint.N+" character passwords against "+paint.C+"{0}".format(InputHash)+paint.N+" "
else:
usage()
def BruteForceByCrossHashReferencingHash(self, HashFile, WordlistFile):
# Read the hash file entered
# Read the wordlist file entered
# compare newly hashed words to already each line in hash file
wordlist = sys.argv[3]
hashlist = sys.argv[4]
try:
wordlistfile = open(wordlist, "r")
except IOError:
print INFO, ERROR,"Check your wordlist path\n"
sys.exit(1)
try:
hashlistfile = open(hashlist, "r")
except IOError:
print INFO, ERROR,"Check your wordlist path\n"
sys.exit(1)
if len(InputHash) == 32:
print "\n", INFO,"Loaded {} words from {}".format(len(words) ,wordlist)
time.sleep(1)
print TYPE, MD5SIGN, paint.B+InputHash+paint.N
for word in words:
hash = hashlib.md5()
hash.update(word[:-1])
if HashFile in hash.hexdigest():
time.sleep(1)
print INFO, QuerySuccess
time.sleep(1)
print INFO, "Password is:", paint.C+word.replace("\n", "")+paint.N
time.sleep(2)
databseoperations.WriteMD5PairToFile(HashFile, word)
hashcracking = HashCracking()
class WatchList():
def MonitorTwitterHashStream(self):
pass
def MonitorDumpMonitor(self):
# https://twitter.com/hashtag/infoleak?f=realtime&src=hash
pass
def MonitorPastebinDorks(self):
pass
def MonitorPastie(self):
pass
def MonitorLeakedIn(self):
# open each link
# examine each <pre>32hex:pass</pre>
# pull each hash
pass
def MonitorPasteBinArchive(self):
time_between = 7 #Seconds between iterations (not including time used to fetch pages - setting below 5s may cause a pastebin IP block, too high may miss pastes)
error_on_cl_args = "Please provide a single regex search via the command line" #Error to display if improper command line arguments are provided
# Check for command line argument (a single regex)
if len(sys.argv) != 1:
search_term = sys.argv[1]
else:
print error_on_cl_args
exit()
iterater = 1
while(1):
counter = 0
print "Scanning pastebin - iteration " + str(iterater) + "..."
#Open the recently posted pastes page
try:
html = utilities.GetSOCKS5Request("http://pastebin.com/archive")
html_lines = html.split('\n')
for line in html_lines:
if counter < 10:
if re.search(r'<td><img src=\"/i/t.gif\" class=\"i_p0\" alt=\"\" border=\"0\" /><a href=\"/[0-9a-zA-Z]{8}">.*</a></td>', line):
link_id = line[72:80]
#print link_id
#Begin loading of raw paste text
url_2 = utilities.GetSOCKS5Request("http://pastebin.com/raw.php?i=" + link_id)
raw_text = url_2.read()
url_2.close()
#if search_term in raw_text:
if re.search(r''+search_term, raw_text):
print "FOUND " + search_term + " in http://pastebin.com/raw.php?i=" + link_id
counter += 1
except(IOError):
print "Network error - are you connected?"
except:
print "Fatal error! Exiting."
exit()
iterater += 1
time.sleep(time_between)
class HashFindings():
# Hash finding/Methods -----------------------------------------------------------------------------------
def FindSHA1onStringFunction(self, sha1erhash):
ReturnedParams = {"string":"{}".format(sha1erhash), "submit":"Decrypt"}
PostResponse = utilities.PostSOCKS5Request("http://www.stringfunction.com/sha1-decrypter.html", ReturnedParams).text
PasswordData = PostResponse.split()
for line in PasswordData:
line = line.strip()
if 'name="result">' in line:
line = line.replace('name="result">', "").replace("</textarea>", "") # Get the actual password
return line
def FindMD5onStringFunction(self, md5erhash):
ReturnedParams = {"string":"{}".format(md5erhash), "submit":"Decrypt"}
PostResponse = utilities.PostSOCKS5Request("http://www.stringfunction.com/md5-decrypter.html", ReturnedParams).text
PasswordData = PostResponse.split()
for line in PasswordData:
line = line.strip()
if 'name="result">' in line:
line = line.replace('name="result">', "").replace("</textarea>", "") # Get the actual password
return line
def FindHashOnHashesDotORG(self, HashReq):
APIres = utilities.GetSOCKS5Request("https://hashes.org/api.php?do=check&hash1={0}&format=json".format(HashReq)).text
return APIres.replace("'", '"')
def FindMD5HashOnMD5Cracker(self, md5hash):
MD5C_response = utilities.GetSOCKS5Request("http://md5cracker.org/api/api.cracker.php?r=8255&database=md5cracker.org&hash={}".format(md5hash)).text
return json.loads(MD5C_response)
def FindMd5oninsomnia247(self, MD5hash):
if len(MD5hash) <= 31:
print INFO, paint.R+"Not an md5 hash!"+paint.N
usage()
sys.exit(0)
elif len(MD5hash) == 32:
#print "\n" + INFO, "querying "+paint.C+"insomnia247"+paint.N+" ..."
MD5Request = utilities.GetSOCKS5Request("https://www.insomnia247.nl/hash_api.php?type=md5&hash={0}".format(MD5hash)).text
return MD5Request
def FindSHA1insomnia247(self, SHA1hash):
if len(SHA1hash) <= 39:
print INFO, paint.R+"Not a sha1 hash!"+paint.N
usage()
sys.exit(0)
elif len(SHA1hash) == 40:
#print "\n" + INFO, "Querying "+paint.C+"insomnia247"+paint.N+" ..."
SHA1Request = utilities.GetSOCKS5Request("https://www.insomnia247.nl/hash_api.php?type=sha1&hash={0}".format(SHA1hash)).text
return SHA1Request
# Search through Google | with different cases.
def FindHashUsingGoogle(self, Hash):
# Modified algorithm; to work for the users specific possible hash types.
HashRequest = utilities.GetHTTPRequest("https://www.google.com/search?q={}".format(Hash)).content
wordlist = HashRequest.split()
# MD5
if len(Hash) == 32:
for word in wordlist:
word = word.strip()
#TO DO: check which algorithm is used, and use the correct one
#for now it is md5
m = hashlib.md5()
m.update(word)
if m.hexdigest() == Hash:
return bytes.decode(word)
# Sha1
elif len(Hash) == 40:
for word in wordlist:
word = word.strip()
#TO DO: check which algorithm is used, and use the correct one
#for now it is md5
m = hashlib.sha1()
m.update(word)
if m.hexdigest() == Hash:
return bytes.decode(word)
# Sha256
elif len(Hash) == 64:
for word in wordlist:
word = word.strip()
#TO DO: check which algorithm is used, and use the correct one
#for now it is md5
m = hashlib.sha256()
m.update(word)
if m.hexdigest() == Hash:
return bytes.decode(word)
# Sha224
elif len(Hash) == 56:
for word in wordlist:
word = word.strip()
#TO DO: check which algorithm is used, and use the correct one
#for now it is md5
m = hashlib.sha224()
m.update(word)
if m.hexdigest() == Hash:
return bytes.decode(word)
# Sha384
elif len(Hash) == 96:
for word in wordlist:
word = word.strip()
#TO DO: check which algorithm is used, and use the correct one
#for now it is md5
m = hashlib.sha384()
m.update(word)
if m.hexdigest() == Hash:
return bytes.decode(word)
# Sha512
elif len(Hash) == 128:
for word in wordlist:
word = word.strip()
#TO DO: check which algorithm is used, and use the correct one
#for now it is md5
m = hashlib.sha512()
m.update(word)
if m.hexdigest() == Hash:
return bytes.decode(word)
# Leak Database json-api | includes rate limiting.
def FindHashLeakDB(self, HASH):
HashRequest = utilities.GetSOCKS5Request("https://api.leakdb.net/?j={0}".format(HASH)).text
return json.loads(HashRequest)
# MD5DB | Random website with free json-api
def FindMD5onMD5DB(self, MD5Hash):
if len(MD5Hash) <= 31:
print INFO, paint.R+"Not an md5 hash!"+paint.N
usage()
sys.exit(0)
if len(MD5Hash) == 32:
MD5Request = utilities.GetSOCKS5Request("http://md5db.net/api/{0}".format(MD5Hash)).text
return MD5Request
# MD5DECODE | Random website with free api
def FindMD5onMD5DECODE(self, MD5):
# This method will always retur na NoneType response when pushing TOR traffic.
if len(MD5) <= 31:
print INFO, paint.R+"Not an md5 hash!"+paint.N
usage()
sys.exit(0)
if len(MD5) == 32:
try:
md5request = utilities.GetSOCKS5request("http://www.md5decode.com/decrypt/{}".format(MD5)).content
return md5request
except:
#print INFO, QueryFailed
pass
def FindMD5onHashToolkit(self, MD5hash):
HTKR = utilities.GetSOCKS5Request("http://hashtoolkit.com/reverse-hash?hash={}".format(MD5hash)).text
pass
hashfindings = HashFindings()
# The usage statement.
def usage():
print """
Basic Usage: """+paint.Y+"""./dhc.py"""+paint.N+""" [HASH]
-----------------------------------------------------------------------------
Keyword & Advanced Examples!
"""+paint.Y+"""./dhc.py"""+paint.N+""" [HASH] | Uses internet resources and attempts determine a hash.
OR
"""+paint.Y+"""./dhc.py"""+paint.N+""" crack bruteforce [HASH] | Attempt to BRUTEFORCE a hash through a built-in algorithm.
OR
"""+paint.Y+"""./dhc.py"""+paint.N+""" crack wordlist [HASH] [PATH-TO-WORDLIST]| Attempt to recover a hash by bruteforce with a given WORDLIST.
OR
"""+paint.Y+"""./dhc.py"""+paint.N+""" google [HASH] | query """+paint.B+"""G"""+paint.R+"""o"""+paint.Y+"""o"""+paint.B+"""g"""+paint.G+"""l"""+paint.R+"""e"""+paint.N+""" directly!
OR
"""+paint.Y+"""./dhc.py"""+paint.N+""" ping [HASH] | Check if a hash is in your session/database file.
OR