celiakwan/ethereum-attack-examples

GitHub: celiakwan/ethereum-attack-examples

以太坊智能合约常见安全漏洞的攻击示例与测试用例集合。

Stars: 15 | Forks: 7

# ethereum 攻击示例 针对以太坊智能合约的攻击示例,例如重入攻击、整数溢出、整数下溢以及通过 revert 进行的 DoS 攻击。 ### 版本 - [Solidity](https://solidity.readthedocs.io/): 0.7.6 - [Truffle](https://www.trufflesuite.com/): 5.4.5 - [Ganache CLI](https://github.com/trufflesuite/ganache-cli): 6.12.2 - [Web3.js](https://web3js.readthedocs.io/): 1.5.1 - [Node.js](https://nodejs.org/en/): 16.6.1 ### 安装说明 安装 Node.js。 ``` brew install node ``` 全局安装 Truffle。 ``` npm install truffle -g ``` 全局安装 Ganache CLI。 ``` npm install ganache-cli -g ``` ### 配置 默认情况下,Ganache 将创建 10 个账户,并在您的本地区块链网络中为每个账户预充 100 ETH。如果您想连接到其他以太坊网络,则需要更新 Truffle 配置文件 `truffle-config.js`。 ### 部署 1. 使用 Ganache 运行本地测试网。 ganache-cli -p 7545 2. 编译智能合约。 truffle compile 3. 部署智能合约。 truffle migrate ### 测试 运行重入攻击的测试用例。 ``` truffle test test/Reentrancy.js ``` 运行整数溢出的测试用例。 ``` truffle test test/IntegerOverflow.js ``` 运行整数下溢的测试用例。 ``` truffle test test/IntegerUnderflow.js ``` 运行通过 revert 进行 DoS 攻击的测试用例。 ``` truffle test test/DosRevert.js ```
标签:DoS, Ganache, MITM代理, OPA, RuleLab, Solidity, Truffle, Web3.js, Web3安全, 以太坊, 加密货币安全, 区块链安全, 合约审计, 安全漏洞, 拒绝服务, 攻击向量, 整数下溢, 整数溢出, 智能合约, 漏洞复现, 自定义脚本, 自定义脚本, 配置错误, 重入攻击, 靶场