This repository (GAP) is a subproject of April (comming soon), and is also a simplified implementation of the paper Towards Generalizable Autonomous Penetration Testing via Domain Randomization and Meta-Reinforcement Learning.
April (comming soon)
Start by checking out the repository:
git clone https://github.com/Joe-zsc/GAP.git
cd GAP
pip install -r requirment.txt
Take vulnerability CVE-2021-3129 for example:
-
Prepare the API key of GLM-4 or other LLMs.
vul="CVE-2021-3129" api_key = "" llm = ChatOpenAI( temperature=0.96, model="glm-4", openai_api_key=api_key, openai_api_base="https://open.bigmodel.cn/api/paas/v4", )
-
Make sure that the example scenario data exists in
scenarios\auto_probe
. e.g.scenarios\auto_probe\CVE-2021-3129.json
-
Make sure that the vulnerability description exists in
GatheredInfo\Action_description.json
-
run LLM_scenario_generation.py
In this project, we directly use sentence-bert to represent the raw state information and action descriptions as vectors.
- Download pre-trained Sentence-BERT models, or train/fine-tune your own embedding models using domain corpus. (reference: TSDAE)
- Store the embedding models in path
NLP_Module\Embedding_models
. - Modify the config file
config.ini
and write the model names in the corresponding positions.
[Embedding]
embedding_models = NLP_Module\Embedding_models
sbert_model = MySbertModel ; your sentence-bert model name, e,g., all-MiniLM-L12-v2
python April_meta.py --train_env_file meta_scenarios/CVE-2021-3129-train-5.json --eval_env_file meta_scenarios/CVE-2021-3129-eval.json --meta_algo MAML
Run the following commands to run a simulation with PPO:
python April_meta.py --train_env_file auto_probe/CVE-2021-3129.json --eval_env_file auto_probe/CVE-2021-3129.json
The learning curves can be seen via the Tensorboard:
tensorboard --logdir runs --host localhost --port 6666
April (comming soon)
NOTE: This project is for educational purpose only and the author does not condone any illegal use. Use as your own risk.
Please cite our paper at:
@ARTICLE{2024arXiv241204078Z,
author = {{Zhou}, Shicheng and {Liu}, Jingju and {Lu}, Yuliang and {Yang}, Jiahai and {Zhang}, Yue and {Chen}, Jie},
title = "{Towards Generalizable Autonomous Penetration Testing via Domain Randomization and Meta-Reinforcement Learning}",
journal = {arXiv e-prints},
keywords = {Computer Science - Machine Learning, Computer Science - Cryptography and Security},
year = 2024,
month = dec,
eid = {arXiv:2412.04078},
pages = {arXiv:2412.04078},
doi = {10.48550/arXiv.2412.04078},
archivePrefix = {arXiv},
eprint = {2412.04078},
primaryClass = {cs.LG},
}