Level 1 Noob Hacker
Ethernaut 06 Delegation
0 / 100 EXP 100 EXP to Junior Hacker
0%

Challenge 6 / Ethernaut

Delegation

Goal

  1. Claim ownership through the Delegation fallback path.

Your task

Read Delegation.sol, then complete Exploit.s.sol.

:~/targets/ethernaut-delegation$
// 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);
        result;
    }
}