picoCTF writeup : keygenme-py

1 min read
Table of contents
Challenge Details
Name : keygenme-py
Category: Reverse Engineering
Difficulty: Beginner
Description
We are just given a file keygenme.py and expected to find the flag from there
First Look
If you open the python file in an editor, you will see the first part of the flag.
key_part_static1_trial = "picoCTF{1n_7h3_|<3y_of_"
key_part_dynamic1_trial = "xxxxxxxx"
key_part_static2_trial = "}"
We only have to find the dynamic1_trial part of the key.
Solution
If you further investigate, you will see a check_key function, which checks for the key i.e. the flag in this case.
I created a custom python program printing the characters one by one the program was checking for.
import hashlib
username_trial = "SCHOFIELD" # given
num_code = [4, 5, 3, 6, 2, 7, 1, 8] #extracted from challenge
hashed = ""
for num in num_code:
hashed += hashlib.sha256(username_trial.encode()).hexdigest()[num]
print(hashed)
This program gives the remaining part of the flag.
The final flag we get is : picoCTF{1n_7h3_|<3y_of_e584b363}
1
Subscribe to my newsletter
Read articles from Sagnik Ghosh directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
