本仓库包含论文 PassGAN: A Deep Learning Approach for Password Guessing 的代码。
PassGAN 模型取自 Improved Training of Wasserstein GANs,并假设 PassGAN 的作者在其工作中使用了 improved_wgan_training 的 TensorFlow 实现。因此,我在本仓库中对参考实现进行了修改,使其易于训练(train.py)和采样(sample.py)。本仓库贡献了:
# 需要预先安装 CUDA 8
pip install -r requirements.txt
使用预训练模型生成 1,000,000 个密码,并保存到 gen_passwords.txt。
python sample.py \
--input-dir pretrained \
--checkpoint pretrained/checkpoints/195000.ckpt \
--output gen_passwords.txt \
--batch-size 1024 \
--num-samples 1000000
在大型数据集(100MB+)上训练模型,GTX 1080 可能需要数小时。
# 下载 rockyou 训练数据
# 包含完整 rockyou 密码中 10 个字符或更短的 80%(含重复)
curl -L -o data/train.txt https://github.com/brannondorsey/PassGAN/releases/download/data/rockyou-train.txt
# 训练 200000 次迭代,每 5000 次保存检查点
# 使用论文中的默认超参数
python train.py --output-dir output --training-data data/train.txt
我们鼓励您使用自己的密码泄露和数据集进行训练。以下是一些获取它们的好地方:
我尚未对我重现 PassGAN 论文结果进行详尽分析。但是,使用预训练的 rockyou 模型生成 10⁸ 个密码样本,我能在测试数据(80%/20% 训练/测试分割)中匹配到 630,347 个(23.97%)唯一密码。
总的来说,我有些惊讶(并失望)于 PassGAN 的作者引用了密码生成领域的 先前工作,但并未将其结果与那项研究进行比较。我对 PassGAN 的初步体验让我相信,它可能明显不如该论文中提到的 RNN 和基于马尔可夫的方法,我希望作者没有选择比较结果不是因为这个原因。
本代码以 MIT 许可证 发布。您可以在此条款下自由使用、修改、分发或出售。
本仓库代码的大部分功劳归于 @igul222 在 improved_wgan_training 上的工作。我只是对其代码进行了一些模块化,添加了命令行界面,并针对 PassGAN 论文进行了特化。
PassGAN 的 研究与论文 由 Briland Hitaj、Paolo Gasti、Giuseppe Ateniese、Fernando Perez-Cruz 发表。