您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
本篇内容主要讲解“python怎么生成密码字典”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“python怎么生成密码字典”吧!
所谓密码字典,主要是配合解密使用,一般情况用来暴力破解密码,是由指定字符排列组合组成的文本文件。如果知道密码设置的规律指定性生成密码,会对破解密码有决定性的帮助!!
代码如下(示例):
import itertools as its words = 'abcdefghijklmnopqrstuvwxyz1234567890' #采用的字符 r = its.product(words, repeat=6) # repeat 要生成多少位的字典 dic = open("pass.txt", "a") #保存 for i in r: dic.write("".join(i)) dic.write("".join("\r")) dic.close()
python dictionary.py default python dictionary.py numonly python dictionary.py letteronly
代码如下(示例):
import itertools as its import argparse def run_default(length,filename): global words ''' words='ha' if numonly == True: words="1234567890" else: words="1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM" ''' words="1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM" r =its.product(words,repeat=length) dic = open(filename,'a') for i in r: dic.write("".join(i)) dic.write("".join("\n")) dic.close() def run_numonly(length,filename): global words words="1234567890" r =its.product(words,repeat=length) dic = open(filename,'a') for i in r: dic.write("".join(i)) dic.write("".join("\n")) dic.close() def run_letteronly(length,filename): global words words="qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM" r =its.product(words,repeat=length) dic = open(filename,'a') for i in r: dic.write("".join(i)) dic.write("".join("\n")) dic.close() if __name__ == "__main__": choices={"default":run_default,"numonly":run_numonly,"letteronly":run_letteronly} parser=argparse.ArgumentParser(description='快速生成密码字典') parser.add_argument('model',choices=choices,help='选择哪个模式运行') parser.add_argument('--length',metavar='length',type=int,default=3,help="密码字典内密码的长度") parser.add_argument('-filename',metavar='filename',type=str,default='password.txt',help="密码字典文件昵称") #parser.add_argument('-numonly',metavar='numonly',type=bool,default=False,help="是否只含有数字") args=parser.parse_args() func=choices[args.model] func(args.length,args.filename)
到此,相信大家对“python怎么生成密码字典”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。