您好,登錄后才能下訂單哦!
本篇內容主要講解“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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。