import os,sys from random import randint,sample import argparse
def Open_File(file): with open(file,"r",encoding="utf-8") as fp: for item in fp.readlines(): data = "".join(item.split("\n")) yield data
def OrderDict(template,outfile,world,flag): Count = 0 fp = open(outfile,"a+",encoding="utf-8") if len(flag) <= 0: for item in Open_File(template): for w in world: fp.write(w + item + "\n") fp.write(item + w + "\n") Count = Count + 2 else: for item in Open_File(template): for w in world: for f in flag: fp.write(item + w + f + "\n") fp.write(item + f + w + "\n") fp.write(w + item + f + "\n") fp.write(w + f + item + "\n") fp.write(f + item + w + "\n") fp.write(f + w + item + "\n") Count = Count + 6 fp.close() print("[+] 总共生成弱密码条数: {}".format(Count))
def RandomDict(outfile,world,flag): Count = 0 fp = open(outfile,"a+",encoding="utf-8") if len(flag) <= 0: for item in range(1,1000): random = sample(world, 2) fp.write(random[0]+random[1] + "\n") Count = Count + 1 else: for item in range(1,1000): random = sample(world, 2) for f in flag: fp.write(random[0] + random[1] + f + "\n") fp.write(f + random[0] + random[1] + "\n") fp.write(random[0] + f + random[1] + "\n") Count = Count + 3 fp.close() print("[+] 总共生成随机密码条数: {}".format(Count))
def Banner(): print(" _ ____ _ _ ") print(" | | _ _/ ___|| |__ __ _ _ __| | __") print(" | | | | | \___ \| '_ \ / _` | '__| |/ /") print(" | |__| |_| |___) | | | | (_| | | | < ") print(" |_____\__, |____/|_| |_|\__,_|_| |_|\_\\") print(" |___/ \n") print("E-Mail: me@lyshark.com")
if __name__== "__main__": Banner() parser = argparse.ArgumentParser() parser.add_argument("-t","--template",dest="template",help="指定一个基础模板字典.") parser.add_argument("-k","--keyword",dest="keyword",help="指定一些关键字,用逗号分隔.") parser.add_argument("-s","--symbol",dest="symbol",help="指定一些特殊符号,用逗号分隔.") parser.add_argument("-o","--outfile",dest="outfile",help="指定输出字典的名字.") args = parser.parse_args()
if args.template and args.keyword and args.outfile: world = [item for item in args.keyword.split(",")] if args.symbol == None: flag = [] OrderDict(args.template,args.outfile,world,flag) else: flag = [item for item in args.symbol.split(",")] OrderDict(args.template,args.outfile,world,flag) else: parser.print_help()
|