1

I am working on the ethernaut CTF level (code below)...I need to take over ownership of the instance (it's been deployed). I thought I could do it by sending a small amount of ETH to the instance address with the hex data being the encoded function selector for pwn(). Since the fallback function does a delegatecall to the delegate contract using whatever msgdata is included with the call.

But I've tried it and it doesn't work. Here is my tx Note that it fails from contract execution not out of gas

Why does this not work?

Here is the contract:

// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; 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; } } } 
1
  • 1
    why do you send eth in your transaction? fallback isn't payable here Commented Nov 18, 2023 at 14:53

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.