PassCode Walkthrough

Challenge Statement#

image

Solution#

Heading over to the site, we can view the contract’s source code.

image

The contract’s logic is straightforward, it only unlocks if you provide the correct number via the unlock function.
The flag is stored in the secret variable and is only revealed by the getFlag function once unlock_flag is set to true.
The unlock function takes an input and compares it to the stored variable code. If they match, it sets unlock_flag to true.
We can try to read code from the contract’s storage.

image

Now, we can send a transaction to call unlock

image

Now, we can call the getFlag() function to reveal the flag.

image


Adapted from harishkannan05/THM-HackfinityBattle-Writeup under MIT.

Find us elsewhere

Merch, stickers, and moreSupport the work at the Solvere Labs shop