Skip to content

Latest commit

 

History

History
69 lines (58 loc) · 4.25 KB

README.md

File metadata and controls

69 lines (58 loc) · 4.25 KB

基于GAN的口令猜测漫步攻击 GAN-based password guessing (trawling attacking)

基本介绍 Introduction

        在巨人的肩膀上(基于Attribution中各个项目的代码),本项目进行了再创造,实现了两个基于GAN的口令猜测攻击模型,两个模型共同点和区别如下:

  • 共同点: 使用IWGAN,基于普通GAN,在判别器的损失函数中增加了一项约束项,具体可见相关论文。

  • 不同点: 生成器和判别器使用了不同的网络结构。

    1. 生成器和判别器使用5层ResNets。ResNets是一种基于CNN的Residual Blocks,进行残差学习。详见reference中的PassGAN, A Deep Learning Approach for Password Guessing.pdf

    2. 生成器和判别器使用两层GRU循环神经网络。在这种情况下生成器。CNN是捕捉样本局部特征的有利工具,非常适合CV任务。但是口令猜测任务类似NLP的文本生成任务,一般使用循环神经网络,以利用其处理序列样本的优势。详见reference中的Recurrent GANs Password Cracker For IoT Password Security Enhancement.pdf

使用方法 Usage

        train.py用于训练模型,sample.py用于生成口令。

直接生成口令 Generate passwords

        使用预训练好的模型,直接生成口令的方法如下(以csdn数据集为例):

# 使用CNN-GAN
python sample.py -m cnn -n 1000000 -i ./model/csdn_cnn_model -o ./guess/gen_csdn_cnn.txt -ck ./model/csdn_cnn_model/checkpoints/checkpoint_100000.ckpt
# 使用RNN-GAN
python sample.py -m rnn -n 1000000 -i ./model/csdn_rnn_model -o ./guess/gen_csdn_rnn.txt -ck ./model/csdn_rnn_model/checkpoints/checkpoint_100000.ckpt

从头开始训练模型 Train from beginning

        使用csdn数据集训练模型:

# 使用CNN-GAN
python train.py -m cnn -b 64 -i ./data/csdn_train.txt -o ./model/csdn_cnn_model
# 使用RNN-GAN
python train.py -m rnn -b 64 -i ./data/csdn_train.txt -o ./model/csdn_rnn_model

        可以使用自己的数据集,改变-i参数即可。

继续训练模型 Restore training

        比从头开始训练多了-ck命令行参数:

# 使用CNN-GAN
python train.py -m cnn -b 64 -i ./data/csdn_train.txt -o ./model/csdn_cnn_model -ck ./model/csdn_cnn_model/checkpoints/checkpoint_100000.ckpt
# 使用RNN-GAN
python train.py -m rnn -b 64 -i ./data/csdn_train.txt -o ./model/csdn_rnn_model -c 1 -ck ./model/csdn_cnn_model/checkpoints/checkpoint_100000.ckpt

其他问题 Other question

python依赖要求

# requires CUDA 8 to be pre-installed
pip install -r requirements.txt

训练集和测试集

        csdn数据集打乱后按照80%和20%比例划分为csdn_train.txtcsdn_test.txt,分别为训练集和测试集。yahoo数据集同理。模型训练均只使用训练集。

Attribution and License

This code is released under an MIT License and another MIT License. You are free to use, modify, distribute, or sell it under those terms.

The majority of the credit for the code in this repository goes to @brannondorsey for his work on the PassGAN, whose code is based on improved_wgan_training written by @igul222. I've simply modified some module, added rnn-based implementation and changed some command-line interface.

The PassGAN research and paper was published by Briland Hitaj, Paolo Gasti, Giuseppe Ateniese, Fernando Perez-Cruz. The PassGAN based on RNN research and paper was published by Sungyup Nam, Seungho Jeon, Hongkyo Kim and Jongsub Moon. The default RNN-based PassGAN implemented in this project is different from above article, but you may change the neural network structure by providing specific command-line arguments.