Skip to content

Commit 18f099f

Browse files
committed
basic/50-solidity-security Aderyn
1 parent cc54e02 commit 18f099f

File tree

2 files changed

+109
-18
lines changed

2 files changed

+109
-18
lines changed

basic/50-solidity-security/README.md

+56-18
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
Mythril 是一个以太坊官方推荐的智能合约安全分析工具,使用符合执行来检测智能合约中的各种安全漏洞,在 Remix、Truffle 等 IDE 里都有集成。
99
其包含的安全分析模型如下,具体可参考 [链接](https://learnblockchain.cn/article/1283)
10+
1011
<center><img src="https://github.com/Dapp-Learning-DAO/Dapp-Learning-Arsenal/blob/main/images/basic/50-solidity-security/securityModule.png?raw=true" /></center>
1112

1213
- 安装 ( docker 方式 )
@@ -73,10 +74,12 @@ cd /oyente/oyente && python oyente.py -s greeter.sol
7374
Slither 是一个用 Python 3 编写的智能合约静态分析框架,提供如下功能:
7475

7576
1. 自动化漏洞检测。提供超 30 多项的漏洞检查模型,模型列表详见: https://github.com/crytic/slither#detectors
77+
7678
2. 自动优化检测。Slither 可以检测编译器遗漏的代码优化项并给出优化建议
79+
7780
3. 代码理解。Slither 能够绘制合约的继承拓扑图,合约方法调用关系图等,帮助开发者理解代码
78-
4. 辅助代码审查。用户可以通过 API 与 Slither 进行交互
7981

82+
4. 辅助代码审查。用户可以通过 API 与 Slither 进行交互
8083
- 安装 ( docker 方式 )
8184

8285
```shell
@@ -97,31 +100,39 @@ slither Suicidal.sol --solc /usr/bin/solc-v0.5.13
97100
```
98101

99102
输入结果如下
103+
100104
<center><img src="https://github.com/Dapp-Learning-DAO/Dapp-Learning-Arsenal/blob/main/images/basic/50-solidity-security/slither.png?raw=true" /></center>
101105

102106
- [可选] 使用 [solc-select](https://github.com/crytic/solc-select) 切换/管理solidity(solc)版本
103-
- 安装
104-
```shell
105-
pip3 install solc-select
106-
```
107-
- 安装需要的版本 & 使用需要的版本
108-
```shell
109-
solc-select install 0.8.17
110-
solc-select use 0.8.17
111-
solc --version
112-
```
113-
- 使用slither(无需版本声明)
114-
```shell
115-
cd /contracts
116-
slither MyContract.sol
117-
```
107+
108+
- 安装
109+
110+
```shell
111+
pip3 install solc-select
112+
```
113+
114+
- 安装需要的版本 & 使用需要的版本
115+
116+
```shell
117+
solc-select install 0.8.17
118+
solc-select use 0.8.17
119+
solc --version
120+
```
121+
122+
- 使用slither(无需版本声明)
123+
124+
```shell
125+
cd /contracts
126+
slither MyContract.sol
127+
```
118128

119129
## MythX
120130

121131
mythX 是一个付费工具, 支持命令行, vscode 插件等形式进行分析.
122132
可参考 [官网](https://docs.mythx.io/) 操作指导进行操作.
123133
进行正确配置后, 就可以进行 solidity 文件漏洞扫描了, 这里以 vscode 为例, 扫描结果如下.
124134
总的来说, 毕竟是付费的, 体验还是很不错的 ^\_^
135+
125136
<center><img src="https://github.com/Dapp-Learning-DAO/Dapp-Learning-Arsenal/blob/main/images/basic/50-solidity-security/scanResult.png?raw=true" /></center>
126137

127138
## Solgraph
@@ -157,12 +168,13 @@ dot -Tpng GraphContract.dot -o GraphContract.png
157168
manticore 是基于**符号执行**方法的合约分析工具,它实际上也是通过断言,来判断是否满足某种属性。
158169

159170
- 特点:
160-
161171
1. 给定输入,搜索可能的状态。
172+
162173
2. 自动生成输入信息。
174+
163175
3. 检测执行失败或者崩溃的地方。
164-
4. 通过事件或者指令钩子,更精确的控制搜索路径。
165176

177+
4. 通过事件或者指令钩子,更精确的控制搜索路径。
166178
- 安装:
167179

168180
```bash
@@ -191,6 +203,32 @@ pip install "manticore[native]"
191203
192204
这是一个 vscode 的插件,通过可视化的方式辅助分析合约。建议使用时换成它自定义的主题,可能显示效果会好一些。使用方法请看标题的官方网站,介绍的很清楚,也有动图演示。
193205
206+
## [Aderyn](https://github.com/Cyfrin/aderyn)
207+
208+
Aderyn是一个用 Rust 编写的开源 solidity 智能合约静态分析框架,可以快速检测潜在漏洞,生成分析报告,使安全审计人员有时间专注于更复杂的漏洞。
209+
210+
Aderyn可以根据需要构建自定义检测器,具体参考[Detectors Quickstart](https://docs.cyfrin.io/aderyn-custom-detectors/detectors-quickstart)。
211+
212+
- 安装:
213+
214+
```bash
215+
cargo install aderyn
216+
```
217+
218+
- 使用:
219+
220+
```bash
221+
aderyn path/to/your/project
222+
```
223+
224+
- 举例(Overflow_Add.sol):
225+
226+
```bash
227+
aderyn Overflow_Add.sol
228+
```
229+
230+
分析报告见[report.md](report.md)
231+
194232
## 参考链接
195233
196234
- https://learnblockchain.cn/eth/dev/%E5%AE%89%E5%85%A8%E5%88%86%E6%9E%90.html

basic/50-solidity-security/report.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Aderyn Analysis Report
2+
3+
This report was generated by [Aderyn](https://github.com/Cyfrin/aderyn), a static analysis tool built by [Cyfrin](https://cyfrin.io), a blockchain security company. This report is not a substitute for manual audit or security review. It should not be relied upon for any purpose other than to assist in the identification of potential security vulnerabilities.
4+
# Table of Contents
5+
6+
- [Summary](#summary)
7+
- [Files Summary](#files-summary)
8+
- [Files Details](#files-details)
9+
- [Issue Summary](#issue-summary)
10+
- [Low Issues](#low-issues)
11+
- [L-1: Inconsistency in declaring uint256/uint (or) int256/int variables within a contract](#l-1-inconsistency-in-declaring-uint256uint-or-int256int-variables-within-a-contract)
12+
13+
14+
# Summary
15+
16+
## Files Summary
17+
18+
| Key | Value |
19+
| --- | --- |
20+
| .sol Files | 1 |
21+
| Total nSLOC | 7 |
22+
23+
24+
## Files Details
25+
26+
| Filepath | nSLOC |
27+
| --- | --- |
28+
| src/Overflow_Add.sol | 7 |
29+
| **Total** | **7** |
30+
31+
32+
## Issue Summary
33+
34+
| Category | No. of Issues |
35+
| --- | --- |
36+
| High | 0 |
37+
| Low | 1 |
38+
39+
40+
# Low Issues
41+
42+
## L-1: Inconsistency in declaring uint256/uint (or) int256/int variables within a contract
43+
44+
Consider keeping the naming convention consistent in a given contract
45+
46+
- Found in src/Overflow_Add.sol [Line: 2](Overflow_Add.sol#L2)
47+
48+
```solidity
49+
contract Overflow_Add {
50+
```
51+
52+
53+

0 commit comments

Comments
 (0)