JettChenT / blog

My Blog
https://blog.jettchen.me
0 stars 0 forks source link

posts/whack-a-frog/ #2

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Corctf 2022 Whack a Frog Writeup - Jett's blog

Corctf 2022 Whack a Frog Writeup

https://blog.jettchen.me/posts/whack-a-frog/

ghost commented 2 years ago

Hi Jett. Thanks very much for your writeup. I do have a couple of questions - I'm still learning python and haven't worked with the libraries that you mentioned. Certainly understand you may not be able to reply and/or some of my questions might be show I'm struggling with fundamentals.

Data processing I think I understand how parse and search work to give the list of (x.y) pairs. You open the file with 'rb' and search the lines matching b'anticheat'. Some Googling suggests 'rb' gives you a bytes object which I kind of understand but not fully. When you then search for lines with b'anticheat' is this looking for the hex values that make up the ascii characters a,n,t,i,c,h,e,a and t?

Visualization For the line a = np.zeros((525,70)) I understand this creates a new array (https://numpy.org/doc/stable/reference/generated/numpy.zeros.html). I was wondering how you came up with that size? Is it a bit of trial and error?

For the line plt.imshow(a.transpose(), cmap='hot') I wasn't sure on the transpose. I understand transpose would swap x and y. From another writeup I see that the image needed to be flipped vertically, but that isn't a transpose is it?

sun-xx commented 2 years ago

@donotdox

Glad to help you.
About your first question:
I think ‘rb’ in Python means open a binary(or hex) file and analyze it to a readable one.
About your second question…I am puzzled with it as well.😂

ghost commented 2 years ago

Haha, thanks for that. I'll remember to try transpose if I get a similar problem in future

sun-xx commented 2 years ago

About the second question…I think, it’s not very important, because it may be just a fit size to display the image.
Possibly by trialing? I think🤔

JettChenT commented 2 years ago

@sun-xx Thank you so much for the response!

@donotdox : For the size I simply calculated the maximum value for the x and y coordinates and added some buffer. I left it out since it could be figured out in many ways and the code for that could be long and even more confusing 😂.

For the transpose command, I simply found out that when I plotted the heatmap it's rotated 90 degrees clockwise, so I used the transpose statement to swap x and y. Different plotting libraries could use different coordinate systems, which is why you might see other manipulation in other writeups.

ghost commented 2 years ago

Thank you both, that's really helpful :)