01.check-in @Greeter
2023-07-13 16:27:18 # 02.ChainflagCTF

check-in(Greeter)

contract

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
pragma solidity 0.8.7;

contract Greeter {
string greeting;

constructor(string memory _greeting) public {
greeting = _greeting;
}

function greet() public view returns (string memory) {
return greeting;
}

function setGreeting(string memory _greeting) public {
greeting = _greeting;
}

function isSolved() public view returns (bool) {
string memory expected = "HelloChainFlag";
return keccak256(abi.encodePacked(expected)) == keccak256(abi.encodePacked(greeting));
}
}

analyses

To make isSolved() returns true, we should modify greeting to “HelloChainFlag”. So we call setGreeting() with “HelloChainFlag” and then it will be solved.