lsdogXG/reentrancy-overflow-ctf
GitHub: lsdogXG/reentrancy-overflow-ctf
一个困难级别的智能合约安全 CTF 挑战,通过组合重入漏洞与整数溢出,让攻击者将代币余额推高至超过总供应量。
Stars: 0 | Forks: 0
# 重入触发溢出 CTF
一个困难级别的智能合约安全 CTF 挑战,它将一个**经典的重入**漏洞与一个**整数溢出**(Solidity 0.6.x,无内置溢出保护)组合成了一次单一的漏洞利用。目标:让你的 VULN 余额超过总供应量(1,000,000 代币)。
## 快速开始
### Docker(推荐)
```
docker build -t reentrancy-overflow-ctf .
docker run --rm -p 3000:3000 -p 8545:8545 reentrancy-overflow-ctf
# Web 界面: http://localhost:3000
# RPC endpoint: http://localhost:8545 (chainId 31337)
```
### 本地
```
npm install
npx hardhat node # in one terminal
npx hardhat run scripts/deploy.js --network localhost
node server.js # web interface on :3000
```
## 布局
```
contracts/VulnerableToken.sol VULN token with chained vulns (reentrancy + overflow)
scripts/deploy.js Deployment for the local Hardhat network
test/exploit_test.js Exploit reproduction test
frontend/index.html, abi.json Minimal web UI for interaction
server.js Express server hosting the frontend
hardhat.config.js Solidity 0.6.12 + chainId 31337
Dockerfile, start.sh One-shot CTF deployment
deployment.json Last deploy info
writeup/
WRITEUP.md Step-by-step solution (bilingual)
AttackContract.sol Attacker contract used by the exploit
exploit.js Plain Hardhat exploit
exploit_docker.js Variant for the Dockerized environment
exploit_final.js Polished final solution
```
## 无剧透的简述
- 合约中存在一个底层调用,它会在状态更新之前将执行权交还给调用者(教科书级别的重入)。
- 第二个通过减法更新 `balanceOf` 的机制作用于 `uint256` 且没有任何溢出检查(Solidity 0.6 的默认行为)。
- 结合这两点,你可以将你的余额从 `0` 推高至超过总供应量。
详细解题步骤位于 `writeup/` 中。所有漏洞利用脚本都使用了 Hardhat 默认测试账户 #0(公钥为人熟知——这是为了便于复现而有意为之)。
## 许可证
MIT
标签:CISA项目, CTF挑战, DApp, Docker, EVM, Hardhat, MITM代理, Solidity, Solidity 0.6, Web3安全, Web安全, 以太坊, 区块链安全, 去中心化应用, 安全防御评估, 安全靶场, 密码学, 手动系统调用, 整数溢出, 智能合约安全, 智能合约审计, 智能合约漏洞, 自定义脚本, 蓝队分析, 请求拦截, 重入攻击