oyente工具安装
注意
① python 的版本要大于 3.5,如果同时有 python2 和 python3,所有命令使用 python3 和 pip3。
② Oyente 目前只支持 0.4.19 以下的 solidity 版本,最好的办法是使用 solc-select 来管理安装不同版本的solidity。
③ Oyente 目前只支持 geth 1.7.3 和 evm 1.7.3 。
④ geth 1.7.3 需要 go 的版本大于等于 1.7,但是 go 的版本过高在构建 geth 时也会出现问题。
⑤ Oyente 目前只支持 z3. 4.5.1 。
⑥ Oyente 官方文档中没有提到需要安装 crytic_compile 库,但是 input_helper 中又引入了这个库,需要额外通过 pip3安装。但 crytic-compile 库安装版本不可以超过 v0.1.13,否则会出现错误。
安装
0.安装前更改go和pip3的下载源
特别是pip3的下载源需要更改,因为后面的z3解析器和crytic-compile 库的安装全都需要下载文件,如果不更改会造成连接失败错误。
1) 更改go的下载源
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
// 编辑文件
vim ~/.bashrc
// 写入文件
# 启用 Go Modules 功能
go env -w GO111MODULE=on
# 配置 GOPROXY 环境变量,以下三选一
# 1. 七牛 CDN
# go env -w GOPROXY=https://goproxy.cn,direct
# 2. 阿里云
go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/,direct
# 3. 官方
# go env -w GOPROXY=https://goproxy.io,direct
source ~/.bashrc
|
2) 更改pip3的下载源
1
2
3
4
5
6
7
8
9
|
# 使用**科技大学**的镜像地址(尝试多个后测试有效)
方法1
sudo pip3 install cython -i https://pypi.mirrors.ustc.edu.cn/simple/
方法2
vim ~/.pip/pipconfig
// 写入
[global] index-url = https://pypi.mirrors.ustc.edu.cn/simple/
|
1.安装 solc 0.4.19
1
2
3
4
5
6
7
8
9
10
11
|
# 安装 solc-select
pip3 install solc-select
# 使用 solc-select 安装 solc 0.4.19
solc-select install 0.4.19
# 使用 solc 0.4.19 版本
solc-select use 0.4.19
# 查看 solc 版本,验证是否安装成功(如果无法查看,关闭终端重新打开)
solc --version
|
2. 安装 go-ethereum v1.7.3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# 克隆 go-ethereum
git clone https://github.com/ethereum/go-ethereum.git
# 切换分支
git checkout v1.7.3
# 构建 geth(使用 make geth 指定不会构建 evm)
make all
# 配置环境
sudo vim ~/.bashrc
# 增加 geth bin 目录到环境变量
# 以下路径根据实际安装路径进行修改
export PATH=$PATH:$HOME/go-ethereum/build/bin
# 退出并使修改命令生效
source ~/.bashrc
# 查看 geth 版本
geth version
|
注: github的地址打不开,可以在windows上面的先将对应的tag下载好了,然后再放到linux中。
如果make all 时候报错,让升级 go 版本,但你的 go 版本明明大于 1.7,那么可以重新安装个 go 1.7,在网上查说这是一个古老的bug。直接安装对应的版本即可。(不是1.17而是1.7看错了怎么也调不出来)
3. 安装 z3-solver 4.5.1.0
1
2
|
# 通过 python3 来安装 z3-solver 4.5.1.0
pip3 install z3-solver==4.5.1.0
|
4. 安装 crytic-compile 0.1.13
1
|
pip3 install crytic-compile==0.1.13
|
注:在安装这个库的时候如果出现build错误,可以重新尝试一次。
注:requests库和web3的库不安装也可
5.下载oyente工具
1
|
git clone https://github.com/enzymefinance/oyente.git
|
6.测试合约
1
|
python3 oyente.py -s `contract.sol`
|
参考文章
Oyente:智能合约漏洞检测工具的安装与使用:https://www.codeleading.com/article/54966128742/