您好,登錄后才能下訂單哦!
本篇內(nèi)容主要講解“python怎么生成密碼字典”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學(xué)習(xí)“python怎么生成密碼字典”吧!
所謂密碼字典,主要是配合解密使用,一般情況用來暴力破解密碼,是由指定字符排列組合組成的文本文件。如果知道密碼設(shè)置的規(guī)律指定性生成密碼,會對破解密碼有決定性的幫助!!
代碼如下(示例):
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="密碼字典內(nèi)密碼的長度") parser.add_argument('-filename',metavar='filename',type=str,default='password.txt',help="密碼字典文件昵稱") #parser.add_argument('-numonly',metavar='numonly',type=bool,default=False,help="是否只含有數(shù)字") args=parser.parse_args() func=choices[args.model] func(args.length,args.filename)
到此,相信大家對“python怎么生成密碼字典”有了更深的了解,不妨來實際操作一番吧!這里是億速云網(wǎng)站,更多相關(guān)內(nèi)容可以進入相關(guān)頻道進行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。