Intro to ETH
Description
Author: Chovid99 Welcome to the world of Ethereum smart contracts! This warmup challenge is designed to introduce newcomers to the basics of interacting with Ethereum blockchain technology. You'll get hands-on experience with a simple smart contract, learning how to read and interact with it. No prior blockchain knowledge is required – just bring your curiosity and problem-solving skills. Are you ready to take your first steps into the exciting realm of decentralized applications?
We are given a file Setup.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
contract Setup {
bool private solved;
constructor() payable {
}
function solve(bytes calldata secret) public {
require(keccak256(secret) == keccak256(bytes("CJ_INTERNATIONAL_2024-CHOVID99")), "Wrong password");
solved = true;
}
function isSolved() external view returns (bool) {
return solved;
}
}
Looking at the source code above, there are some functions we can interact with.
Functions
solve(bytes calldata secret)
function solve(bytes calldata secret) public {
require(keccak256(secret) == keccak256(bytes("CJ_INTERNATIONAL_2024-CHOVID99")), "Wrong password");
solved = true;
}
This function takes a bytes
parameter called secret. Then it uses the keccak256
hash to match the hash of secret with the hash of the string CJ_INTERNATIONAL_2024-CHOVID99
, if it matches, then it flips the variable solved
to true.
isSolved()
function isSolved() external view returns (bool) {
return solved;
}
This function will return a true/false boolean value. If it returns true, then the challenge is solved and otherwise if it returns false, the challenge is not solved.
Ethernet Launcher
We were also given a web to launch our private blockchain server.

Solve
To solve this, it is very straightforward. We just need to do cast send
(because we are altering the blockchain state and we need our private key to do that) to the solve
function with the parameter CJ_INTERNATIONAL_2024-CHOVID99
converted to hex.
We can use the help of foundry to do that.
First we call the solve function.
cast send 0xA2Fa474F768F08e202294763b23B96c484763EB8 "solve(bytes)" 0x434a5f494e5445524e4154494f4e414c5f323032342d43484f5649443939 --rpc-url http://152.42.183.87:59117/ca1cf1a0-82e8-4f63-b573-61206fc3b88d --private-key 0x3359d77020acd3a10f9b5503824f8866c67f769398a2891b37dfecaf9ac2fdda

And we check if our challenge is solved by calling the isSolved()
function.
cast call 0xA2Fa474F768F08e202294763b23B96c484763EB8 "isSolved()(bool)" --rpc-url http://152.42.183.87:59117/ca1cf1a0-82e8-4f63-b573-61206fc3b88d

And with that, our challenge is solved!

Flag: CJ{m0mMy_I_s0lv3d_bL0cKch41n_ch4ll3ng3zZ}
Last updated