Smart contract vulnerability detection using graph neural network (DR-GCN).
This repo is a python implementation of smart contract vulnerability detection using graph neural networks (DR-GCN).
Run the following script to install the required packages.
pip install --upgrade pip
pip install torch==1.0.0
pip install numpy==1.18.2
pip install scikit-learn==0.20.2
Please use this citation in your paper if you refer to our paper or code.
@inproceedings{zhuang2020smart,
title={Smart Contract Vulnerability Detection using Graph Neural Network.},
author={Zhuang, Yuan and Liu, Zhenguang and Qian, Peng and Liu, Qi and Wang, Xiang and He, Qinming},
booktitle={IJCAI},
pages={3283--3290},
year={2020}
}
parser.py
.Examples:
python3 SMVulDetector.py --dataset training_data/REENTRANCY_CORENODES_1671
python3 SMVulDetector.py --dataset training_data/REENTRANCY_CORENODES_1671 --model gcn_modify --n_hidden 192 --lr 0.001 -f 64,64,64 --dropout 0.1 --vector_dim 100 --epochs 50 --lr_decay_steps 10,20
Using script:
Repeating 10 times for different seeds with train.sh
.
for i in $(seq 1 10);
do seed=$(( ( RANDOM % 10000 ) + 1 ));
python3 SMVulDetector.py --model gcn_modify --seed $seed | tee logs/smartcheck_"$i".log;
done
Then, you can find the training results in the logs/
.
For original dataset, please turn to the dataset repo.
The normalized train data can be found in
training_data/REENTRANCY_CORENODES_1671
, REENTRANCY_FULLNODES_1671
Note that the instruction of constructing the dataset can be found in the GraphLearning, and the XXX_node_attributes
can be obtained using our designed tools.