-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnack.py
More file actions
executable file
·145 lines (114 loc) · 4.14 KB
/
nack.py
File metadata and controls
executable file
·145 lines (114 loc) · 4.14 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
import sys
import os
import hashlib
from threading import Thread
def nums(h, hp):
for i in range(0,1000000):
if (len(str(i)) <= 4):
h = hashlib.new('md5')
guess = str(i).zfill(4)
#print guess
h.update(guess)
guessHash = h.hexdigest().upper()
#print guessHash
#print hp
if (guessHash == hp):
print "passwd found: " + guess + "\n\n"
return
if (len(str(i)) <= 5):
h = hashlib.new('md5')
guess = str(i).zfill(5)
#print guess
h.update(guess)
guessHash = h.hexdigest().upper()
#print guessHash
#print hp
if (guessHash == hp):
print "passwd found: " + guess + "\n\n"
return
if (len(str(i)) <= 6):
h = hashlib.new('md5')
guess = str(i).zfill(6)
#print guess
h.update(guess)
guessHash = h.hexdigest().upper()
#print guessHash
#print hp
if (guessHash == hp):
print "passwd found: " + guess + "\n\n"
return
print "passwd not type 1 (nums)\n\n"
def dictWords(h, hp):
dictFile = open('/usr/share/dict/words', 'r')
for line in dictFile.readlines():
if(len(line) == 5):
for i in range(0, 10):
h = hashlib.new('md5')
guess = line.strip('\n') + str(i)
#print guess.title()
h.update(guess.title())
guessHash = h.hexdigest().upper()
# print guessHash
#print hp
if (guessHash == hp):
print "passwd found: type2: " + guess.title() + "\n\n"
return
elif(len(line) == 6):
# print line
guess = line.strip('\n')
i = 0
for x in range(0, guess.count('e')):
holder = guess
i = guess.find('e', i + 1)
if (i != -1):
guess[i:i+1].replace(guess[i], '3')
temp = list(guess)
temp[i] = '3'
guess = "".join(temp)
h = hashlib.new('md5')
h.update(guess)
guessHash = h.hexdigest().upper()
if (guessHash == hp):
print "passwd found: type3: " + guess + "\n\n"
return
else:
h = hashlib.new('md5')
guess = line.strip('\n')
#print guess
h.update(guess)
guessHash = h.hexdigest().upper()
if (guessHash == hp):
print "passwd found: type 4: " + guess + "\n\n"
print "passwd not type 2, 3, 4\n\n"
def charBrute(h, hp):
x = 1
def main():
hasher = hashlib.md5()
if len(sys.argv) == 2:
filename = sys.argv[1]
if not os.path.isfile(filename):
print filename + ' does not exist'
exit(0)
x
if not os.access(filename, os.R_OK):
print filename + ': cannot read'
exit(0)
hashFile = open(filename, 'r')
for line in hashFile.readlines():
if ":" in line:
uname = line.split(':')[0]
hashedPasswd = line.split(':')[1].strip('\n ')
print "cracking: " + uname
#print uname
#print hashedPasswd
#thread try rule 1
nums(hasher, hashedPasswd)
#thread try rule 2
dictWords(hasher, hashedPasswd)
#thread try rule 3
charBrute(hasher, hashedPasswd)
else:
print 'please provide a hash file e.g. \n\npython nack.py hashes.txt\n'
#make sure hashes.txt is formatted like uname:passwdHash:[othercrap]
# or uname:passwdHash
main()