A box of chocolate

my public personal notebook

0CTF 2015 Quals - Task geo_newbie

My code is kinda messy and buggy :<. I can fix it, but I would like to keep things like during the contest (sorry for this weird habit :p). So I will outline my ideas from my solution here:

  • For level 0 and 1, I use Google Geocoding API (https://developers.google.com/maps/documentation/geocoding/) to determine a place's location and then extract info about which country that location is pointing to, and then use pycountry to get that country's ISO 3166-1 alpha-2 code (I can use the short_code tag in Google's result instead, but I added it after I implemented my solution for level 0 with pycountry so...)

  • For level 2, I just run my script, get questions and then hard-code them into my solution. (Another bad habit, right :<)

Implementation issues:

  • Google Geocoding API will return results biased to the USA (or some other places if I change the parameter) so I manually added places that GGAPI will respond differently from the correct answer by the judge.

  • GGAPI also has a limit on how many requests we can send in 24 hrs, so we must cache the result. (I reached the limit once :<)

  • I still don't know where Lego is :<

Here is my code:

0ctf geo newbie