Advertisement
Guest User

Untitled

a guest
Sep 28th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. #/etc/shadow Bruteforcer
  2. #Coded by Aaditya Purani
  3. #Just for Fun after Remote Exploitation
  4. #It will crack shadow password by Dictionary attack
  5.  
  6. import optparse
  7. import crypt
  8.  
  9. def checkPass(cryptPass, dname):
  10. salt = "$"+cryptPass.split('$')[1]+"$"+cryptPass.split('$')[2]
  11. dictFile = open(dname, 'r')
  12. for word in dictFile.readlines():
  13. word = word.strip('\n')
  14. cryptWord = crypt.crypt(word, salt)
  15. if (cryptWord == cryptPass):
  16. print "[+] The Password is "+word+"\n"
  17. return
  18. print "[-] Password not found \n"
  19. return
  20.  
  21.  
  22. def main():
  23. parser = optparse.OptionParser("usage %prog "+"-f <passwordFile> -d <dictionary>")
  24. parser.add_option('-f', dest='pname', type='string', help='specify password file')
  25. parser.add_option('-d', dest='dname', type='string', help='specify dictionary file')
  26. (options, args) = parser.parse_args()
  27. if (options.pname == None) | (options.dname == None):
  28. print parser.usage
  29. exit(0)
  30. else:
  31. pname = options.pname
  32. dname = options.dname
  33.  
  34. passFile = open(pname)
  35. for line in passFile.readlines():
  36. if ":" in line:
  37. user = line.split(':')[0]
  38. cryptPass = line.split(':')[1]
  39. print "[*] Cracking Password for "+user
  40. checkPass(cryptPass, dname)
  41.  
  42. if __name__ == '__main__':
  43. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement