import threading
import string

# 用于生成密码的字符
chars = string.ascii_letters + string.digits

# 密码长度
pwd_len = 8

# 密码字典
pwd_dict = []

# 多线程数
thread_num = 8

# 生成密码,length表示密码的长度
def generate_pwd(length):
    if length == 1:
        for c in chars:
            pwd_dict.append(c)
    else:
        for pwd in generate_pwd(length - 1):
            for c in chars:
                pwd_dict.append(pwd + c)

# 运行线程
def main():
    # 运行线程
    thread_list = []
    for i in range(thread_num):
        thread_list.append(threading.Thread(target=generate_pwd, args=(pwd_len,)))
    for t in thread_list:
        t.start()
    for t in thread_list:
        t.join()

if __name__ == '__main__':
    main()
    # 将字典写入文件
    with open('pwd.txt', 'a') as f:
        for pwd in pwd_dict:
            f.write(pwd + '\n')

本脚本使用 Python 多线程技术,通过创建多个线程来加速密码字典的生成过程。

使用方法:

  1. 修改 chars 变量,添加或删除用于生成密码的字符。
  2. 修改 pwd_len 变量,设置要生成的密码长度。
  3. 修改 thread_num 变量,设置要使用的线程数量。
  4. 运行脚本,脚本会将生成的密码字典存储到 pwd.txt 文件中。

注意:

  • 生成大量密码组合可能需要较长时间。
  • 脚本仅供学习和研究使用,请勿用于非法目的。
Python 多线程密码字典生成脚本:高效生成密码组合

原文地址: https://www.cveoy.top/t/topic/lh4s 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录