实战
# -*- coding: utf-8 -*-
# @Author : Tony
import exrex
# 生成字典密码
def make_pass(pwds):
# 保存生成的字典
fout = open('password_out.txt', 'w')
fout.close()
# 假设包含三种内容 1.字符串 2.数字密码 3.下划线或井号
for pwd in pwds:
# 生成三种组合(含大小写)
rules = ['({pwd})([az][Xx][Zz])(_|#)',
'([Tz][Xx][Zz])({pwd})(_|#)',
'(_|#)({pwd})([Tz][Xx][Zz])']
# 密码生成
for rule in rules:
final_pwds = list(exrex.generate(rule.format(pwd=pwd)))
for final_pwd in final_pwds:
print(final_pwd)
# 保存生成的字典
fout = open('password_out.txt', 'a+')
fout.write(final_pwd + '\n')
fout.close()
# 主函数
if __name__ == '__main__':
# 常见密码 弱口令 -- 过滤
pwds = ['123456', '111111', '666666', '12345678', 'qwerty', '123456789', 'abc123']
make_pass(pwds)