智能合约传统检测工具的使用与测试(oyente、Mythril、Slither、ConFuzzius、sFuzz、SmartCheck)

#oyente的使用

##爬取镜像

docker pull luongnguyen/oyente

##创建oyente 相关的容器

docker run -it --privileged=true -v /home/wtf/oyente_test:/oyente/workspace --name oyente luongnguyen/oyente

##使用oyente测试合约

cd /oyente/oyente && python oyente.py -s file_path -ce

#Mythril的使用

##爬取镜像

docker pull mythril/myth

## 创建Mythril相关的容器

docker run -it --privileged=true -v /home/wtf/Mythril_test:/Mythril_test --name Mythril mythril/myth /bin/bash

# Mythril测试合约

myth analyze file_path -o json

# Slither的使用
##爬取镜像

docker pull trailofbits/eth-security-toolbox


##创建Slither相关的容器

docker run -it --privileged=true -v /home/wtf/Slither_test:/Slither_test --name Slither trailofbits/eth-security-toolbox /bin/bash


#Slither测试合约
 

slither file_path --detect reentrancy-eth,reentrancy-no-eth,reentrancy-events --print human-summary

#ConFuzzius的使用
#爬取镜像

docker pull christoftorres/confuzzius


##创建ConFuzzius相关的容器

docker run -it --privileged=true -v /home/wtf/ConFuzzius_test:/ConFuzzius_test --name ConFuzzius christoftorres/confuzzius /bin/bash


#ConFuzzius测试合约
 

python3 /root/fuzzer/main.py -s /ConFuzzius_test/sourcecode/3.sol  --solc v0.4.26 --evm byzantium -t 10

#sFuzz的使用

##爬取镜像

docker pull smartbugs/sfuzz:48934c0

##创建sFuzz相关的容器

docker run -it --privileged=true -v /home/wtf/sFuzz_test:/sFuzz_test --name sFuzz smartbugs/sfuzz:48934c0 /bin/bash

##sFuzz测试合约

cd home/ ##到fuzzer执行文件所在的目录
mkdir contracts/ #创建存储合约的目录!!!注意此处存储的合约文件名要和内部合约的名字一致
##将要测试的合约复制到contracts/目录
##Start fuzzing using the command:
./fuzzer -g -r 0 -d 120 && chmod +x fuzzMe && ./fuzzMe 
##如果想实时观看测试结果,并将其输出到一个文件之中可以使用如下命令
./fuzzMe | tee result.txt

sFuzz测试的Warning:如果一次性测试多个合约,一定要保证contracts/目录一开始是空的,然后将想要的测试的合约全部放在contracts/目录下。sFuzz会依次测试所有合约并标准输出所有合约的测试结果。

#SmartCheck的使用

##爬取镜像

docker pull smartbugs/smartcheck:latest

##创建SmartCheck相关的容器

SmartCheck镜像无法实现交互式命令行,只能在创建镜像时,直接测试合约。

sudo docker run -it --rm -v /home/wtf/smartcheck_test:/contracts smartbugs/smartcheck -p /contracts/SimpleDAO.sol

##--rm 容器退出后自动删除。
## -v /home/user/contracts:/contracts: 将宿主机的 /home/wtf/smartcheck_test 目录挂载到容器内的 /contracts 目录。宿主机的/smartcheck_test的目录下要存放有要测试的合约,例如SimpleDAO.sol

以上就是经典传统智能合约漏洞检测工具的使用与测试,本文旨在方便大家使用这些工具进行测试,希望对大家有所帮助!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值