imsellbaox / GraphDeeSmartContract

Smart contract vulnerability detection using graph neural network (DR-GCN).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GraphDeeSmartContract GitHub stars GitHub forks License

This repo is a python implementation of smart contract vulnerability detection using graph neural networks (DR-GCN).

Requirements

Required Packages

  • python3 or above
  • PyTorch1.0.0
  • numpy1.18.2
  • sklearn for model evaluation

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

Citation

Please use this citation if you want to cite our paper or codebase in your paper:

@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}
}

Running project

  • To run program, use this command: python SMVulDetector.py.
  • In addition, you can use specific hyper-parameters to train the model. All the hyper-parameters can be found in parser.py.

Examples:

python SMVulDetector.py --dataset training_data/REENTRANCY_CORENODES_1671
python 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 ));
python SMVulDetector.py --model gcn_modify --seed $seed | tee logs/smartcheck_"$i".log;
done

Then, you can find the training results in the logs/.

Dataset

ESC: Ethereum Smart Contracts

VSC: Vntchain Smart Contacts

The train data after normalization:

training_data/LOOP_CORENODES_1317, LOOP_FULLNODES_1317, REENTRANCY_CORENODES_1671, REENTRANCY_FULLNODES_1671

Reference

  1. A fraction of the code reuses the code of graph_unet.
  2. Thomas N. Kipf, Max Welling, Semi-Supervised Classification with Graph Convolutional Networks, ICLR 2017.

About

Smart contract vulnerability detection using graph neural network (DR-GCN).


Languages

Language:Python 77.1%Language:Solidity 12.0%Language:C 10.8%Language:Shell 0.1%