This is a guest post written by Michael who is part of the CyberStart Community.
Find out the tips and processes players use to solve CyberStart’s challenges.
Michael walks through a challenge in HQ base and shows how he solved it.
Note: This blog contains spoilers and solutions to HQ L09 C08 - Bogdan’s Data
Michael - HQ L09 C08 - Bogdan’s Data
“It was very nice to learn a new Python command in the challenge, as now I can carry on knowing just a little more about Py”.
Part 1: Briefing
“Alright,” I tell myself, “new challenge”.
“The briefing mentions ‘services.cyberprotection.agency:3166’, which looks similar to information required to use sockets. 99% we’re using that”.
“Just gonna read in a little… source code? Oh, cool, a .py file. It’s not password protected, I’m probably just fixing some code.”
So, I downloaded the code and uploaded it to my work environment.
“Yeah, it’s sockets. Let’s run it…”
[NameError: name 'clientsock is not defined]
And I get my first error.
“Ok, uh… oh. “sockets” hasn’t been imported yet. Do that…”
[NameError: name 'clientsock' is not defined]
“Oh right, we didn’t actually initialize ‘clientsock’. Lemme just open Moon L03 C02 for a quick paste…”
And I pasted in the socket initializing code. And then I ran it once more.
[TypeError: a bytes-like object is required, not 'str']
“Alright, I just have to specify the string in here as bytes. Easy peasy!”
“Just gonna code up something on main.py to access this file…”
I run it again. No errors, but instead, nothing is output.
“Ok, so no console output… hrmm. What’s with it?”
And then it hit me. I was fixing code… that was just grabbed source code being ran on the server. One facepalm later, I knew exactly what I had to do.
“Alright! Let’s modify this to connect instead and see what happens, commenting out the source code.”
Looking at the source code, I saw some pretty weird stuff. First of all, this “eval” command was something I’d never seen before. So, I started messing around to see if I could make something work.
“Not sure what this math is, but I’ll just set both numbers to the same thing and see what happens.”
Spoilers: It didn’t work.
“Yep, didn’t work. I expected that… time to do some research on eval().”
After some research on the eval() python command, I noticed it actually allows you to set variables to other values/variables. So, I got a bright idea.
“Ok, let’s make the second number our first number by sending secondNum = firstNum!”
It worked, and I got the flag!
See how a CyberStart Community member solved HQ L06 C06 in this blog post.
One of the biggest challenges I faced was understanding the new command, eval(). I was completely unfamiliar with this. I hadn’t used it or seen it before in any Python programs. I wasn’t sure what it was doing. I only assumed I could input numbers for quite a while.
After some research, though, it was much clearer what the solution would be! It was very nice to learn a new Python command in the challenge, as now I can carry on knowing just a little more about Py.
In addition to HQ, you’ll learn how to use Python in Moon base. Find out more in our Moon base blog post.
It may be obvious from the storyline, but I have a fairly logical process for going about solving these challenges.
First, I scan the briefing for my goal and any hints/clues at what I should try.
Second, I mess around with what’s given to see where I can go and what to try.
Then, if I find something new (and I usually do!), I enter a research phase to figure out these new concepts. The research usually takes the longest, since I don’t always know what I’m looking for!
Ready to get stuck into fun, problem-solving challenges like these? Have a go for free right now in CyberStart’s Intern base or upgrade to access HQ, Moon and Forensics base.