unix 密码破解,zip破解总结
unix /etc/passwd 破解,假设的前两位是salt
import crypt #数据比较 def password_crak(pass_word): salt = pass_word[0:2] diction = open("dictionary","r") for word in diction.readlines(): data = word.strip("\n") crak = crypt.crypt(data,salt) if crak == pass_word: print ("[+]Found password:%s\n" %data) else: print ("[-]Not Found password\n") #处理数据 def main(): pass_file = open("password.txt","r") for line in pass_file.readlines(): if ":" in line: user = line.split(":")[0] pass_word = line.split(":")[1].strip(" ") print ("[*]Craking password for:%s\n" %user) password_crak(pass_word)
if __name__ == '__main__': main()
zip密码破解,自己的环境是python3,一定要在password.encode("utr-8),不然报typeError: pwd: expected bytes, got str
import zipfile #密码错误抛出异常pass继续循环 def crack(zfile,password): try: zfile.extractall(pwd=password.encode("utf-8")) return password except: pass #处理数据 def main(): zip_name = input("Please input your zip name:") zfile = zipfile.ZipFile(zip_name) pass_file = open("dictionary.txt","r") for data in pass_file.readlines(): password = data.strip("\n") guess = crack(zfile,password) if guess: print ("[+]Password :%s\n" %password) exit(0) if __name__ == '__main__': main()
多线程版:
import zipfile import threading #密码错误抛出异常pass继续循环 def crack(zfile,password): try: zfile.extractall(pwd=password.encode("utf-8")) print ("[+]Password :%s\n" %password) except: pass #处理数据 def main(): zip_name = input("Please input your zip name:") zfile = zipfile.ZipFile(zip_name) pass_file = open("dictionary.txt","r") for data in pass_file.readlines(): password = data.strip("\n") t = threading.Thread(target=crack,args=(zfile,password)) t.start() if __name__ == '__main__': main()
总结:基于字典的破解
zipfile:https://www.cnblogs.com/ManyQian/p/9193199.html
python3编码解决:https://bbs.csdn.net/topics/390190563