Insomni Hack 2023 - NotSuchSolidIT challenge

This article presents the challenge NotSuchSolidIT from Insomni’hack

Contracts

The challenge was formed of two different files :

  • setup.sol
  • Challenge.sol

Two smartcontracts have been deployed, try to withdrawal the Challenge.sol to get the flag.

Setup.sol

// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.1;
import "./Challenge.sol";

contract Setup {
	Challenge public chall;

	constructor() payable {
		require(msg.value >= 100, "Not enough ETH to create the challenge..");
		chall = (new Challenge){ value: 50 ether }();
	}

	function isSolved() public view returns (bool) {
		return address(chall).balance == 0;
	}
	
	function isAlive(string calldata signature, bytes calldata parameters, address addr) external returns(bytes memory) {
		(bool success, bytes memory data) = address(addr).call(
			abi.encodeWithSelector(
				bytes4(keccak256(bytes(signature))),
				parameters
			)
		);
		require(success, 'Call failed');
		return data;
	}
}

Challenge

// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.1;
contract Challenge {

	address payable owner;
	constructor() payable {
		owner = payable(msg.sender); 
	}

	modifier onlyOwner {
		require(msg.sender == owner);
		_;
	}
	
	function getBalance() public view returns (uint){
		return address(this).balance;
	}
	
	function withdrawAll(address payable _to) public onlyOwner {
		_to.transfer(address(this).balance);
	}
	
	function destroy() public onlyOwner {
		selfdestruct(owner);
	}
}

Solution

1.Compile the contracts with Remix: https://remix.ethereum.org

2.Connect with a custom external provider

insomniak2023

3.Call withdrawAll with the parameters

insomniak2023

4.Check if the challenge isSolved

insomniak2023

You might also enjoy