基于社会工程学的弱口令密码字典生成工具
CCUPP 是一个基于社会工程学的弱口令密码字典生成工具,通过分析用户的个人信息(姓名、生日、电话、地址等),智能生成可能的弱口令密码字典。
- 智能拼音转换:自动将中文姓名、地名等转换为拼音、首字母、首字母大写等多种形式
- 基于规则的生成:按优先级生成密码(旧密码变体 → 姓名+生日 → 姓名+电话 → 组合 → 文化数字 → 键盘模式)
- 中国特色数字:自动组合 520、1314、888、666 等文化含义数字
- 日期格式变换:从生日自动生成 19830924、830924、0924、83-09-24 等十余种变体
- Leetspeak 变换:支持 a→@、e→3、o→0 等变换
- 密码过滤:支持按长度、字符类型过滤
- 多输出格式:支持 txt、json 格式输出
- 统计信息:
--stats显示生成密码的长度分布 - 交互模式:引导式输入用户信息
- 高性能:迭代器生成,内存高效
pip install ccuppgit clone https://github.com/WangYihang/ccupp.git
cd ccupp
uv sync# 自动生成示例配置
ccupp init
# 或使用交互模式
ccupp interactive手动创建 config.yaml:
- surname: 李
first_name: 二狗
phone_numbers:
- '13512345678'
identity: '220281198309243953'
birthdate:
- '1983'
- '09'
- '24'
hometowns:
- 四川
- 成都
places:
- - 河北
- 秦皇岛
social_media:
- '987654321'
workplaces:
- - 腾讯
- tencent
educational_institutions:
- - 清华大学
- tsinghua
accounts:
- twodogs
passwords:
- old_password# 基本使用
ccupp generate
# 输出到文件
ccupp generate -o passwords.txt
# 过滤长度
ccupp generate --min-length 8 --max-length 16
# 查看统计
ccupp generate --stats
# JSON 格式
ccupp generate -f json -o passwords.json
# 禁用某些策略
ccupp generate --no-leetspeak --no-cultural --no-keyboard除了命令行,CCUPP 也可以作为库在你自己的代码里调用。核心 API 都从顶层 ccupp 包直接导出。
from ccupp import Profile, generate_passwords
profile = Profile(
surname='李',
first_name='二狗',
birthdate=['1983', '09', '24'],
phone_numbers=['13512345678'],
passwords=['old_password'],
)
# 返回一个惰性迭代器,按可能性从高到低排序、自动去重
for pw in generate_passwords(profile, min_length=6, max_length=16):
print(pw)generate_passwords 的常用参数:
| 参数 | 说明 | 默认 |
|---|---|---|
min_length / max_length |
长度过滤(0 表示不限制) | 0 |
enable_leetspeak |
Leetspeak 变换(a→@、e→3…) | True |
enable_case_variants |
大小写变换 | True |
enable_cultural_numbers |
文化数字组合(520、1314…) | True |
enable_keyboard_patterns |
键盘模式组合 | True |
suffixes / prefixes / delimiters |
覆盖默认的后缀/前缀/分隔符规则 | 内置默认值 |
第一个参数也可以传入「多个 Profile」,会跨用户统一去重:
from ccupp import load_profiles, generate_passwords
profiles = load_profiles('config.yaml') # 从 YAML 加载多个用户
passwords = list(generate_passwords(profiles)) # 跨用户去重如果需要在「提取组件」和「生成」之间插入自定义逻辑,可以分两步调用:
from ccupp import Profile, extract_components, PasswordGenerator
profile = Profile(surname='李', first_name='二狗', passwords=['old_password'])
components = extract_components(profile) # Profile → {类别: [候选值, ...]}
generator = PasswordGenerator(
components,
enable_keyboard_patterns=False,
suffixes=['', '123', '!'], # 自定义后缀规则
)
for pw in generator.generate():
...| 名称 | 说明 |
|---|---|
Profile |
用户信息数据模型(Pydantic) |
load_profiles(path) |
从 YAML 文件加载 list[Profile] |
extract_components(profile) |
从 Profile 提取密码组件 |
PasswordGenerator |
底层规则生成引擎 |
generate_passwords(profile, **options) |
一步到位的高层封装(推荐) |
CCUPP 是完整类型标注的库:包内携带 PEP 561
py.typed标记,整个包通过mypy --strict,下游用户在自己的项目里能直接享受到类型检查与编辑器补全。
| 字段 | 类型 | 说明 | 示例 |
|---|---|---|---|
surname |
string | 姓氏 | 李 |
first_name |
string | 名字 | 二狗 |
phone_numbers |
list[string] | 电话号码列表 | ['13512345678'] |
identity |
string | 身份证号 | '220281198309243953' |
birthdate |
list[string] | 出生日期 [年, 月, 日] | ['1983', '09', '24'] |
hometowns |
list[string] | 家乡列表 | ['四川', '成都'] |
places |
list[list[string]] | 地点列表 | [['河北', '秦皇岛']] |
social_media |
list[string] | 社交媒体账号 | ['987654321'] |
workplaces |
list[list[string]] | 工作单位列表 | [['腾讯', 'tencent']] |
educational_institutions |
list[list[string]] | 教育机构列表 | [['清华大学', 'tsinghua']] |
accounts |
list[string] | 账号列表 | ['twodogs'] |
passwords |
list[string] | 旧密码列表 | ['old_password'] |
密码按可能性优先级排序输出:
- 旧密码变体:旧密码 + 大小写/leetspeak/后缀变换
- 单组件 + 后缀:姓名/电话/账号 + 常见后缀(123, @, !!! 等)
- 姓名 + 生日:最常见的中国用户弱口令模式
- 姓名 + 电话/身份证尾号
- 双组件组合:任意两类信息的组合
- 文化数字组合:组件 + 520/1314/888/666 等
- 键盘模式:qwerty/1qaz2wsx 等 + 组件
ccupp/
├── ccupp/
│ ├── __main__.py # CLI 入口 (Typer)
│ ├── api.py # SDK 高层 API (generate_passwords)
│ ├── models.py # Profile 数据模型 (Pydantic)
│ ├── config.py # YAML 配置加载
│ ├── generator.py # 基于规则的密码生成引擎
│ ├── extractors/
│ │ └── components.py # 从 Profile 提取密码组件
│ ├── transforms/
│ │ ├── pinyin.py # 中文拼音转换
│ │ ├── date.py # 日期格式变换
│ │ ├── case.py # 大小写变换
│ │ └── leetspeak.py # Leetspeak 变换
│ └── data/ # 示例配置文件
├── tests/ # pytest 测试套件
├── .github/workflows/ # CI/CD (test + release)
├── pyproject.toml
└── Dockerfile
- Python 3.12+
- Typer — CLI 框架
- Pydantic — 数据验证
- pypinyin — 中文拼音转换
- PyYAML — 配置解析
- Rich — 终端美化
git clone https://github.com/WangYihang/ccupp.git
cd ccupp
uv sync --dev
uv run pytest -v欢迎提交 Issue 和 Pull Request!
MIT License. 详见 LICENSE 文件。
- 参考了 chinese-weak-password-generator 的设计思路
- 相关研究:arXiv:2306.01545
本工具仅用于安全研究和授权的安全测试。使用者需遵守相关法律法规,不得用于非法用途。作者不对任何误用行为承担责任。