Created
October 24, 2013 10:12
-
-
Save trietptm/7134569 to your computer and use it in GitHub Desktop.
Hack.lu 2013 CTF
https://ctf.fluxfingers.net/challenges/24 Geolocation Flag (Category: Misc) Author(s): javex
This challenge is a special challenge. You can collect some minor extra points here by proving that you are a truly international player. Each time you visit your reference URL from a different country, that flag will be activated and yo…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import urllib2, re | |
| import urllib | |
| #Leech proxies from http://gatherproxy.com/ | |
| for line in open('proxy_urls.txt','r').readlines(): | |
| print line | |
| response = urllib2.urlopen(line) | |
| html = response.read() | |
| #print html | |
| match = re.findall(r'"PROXY_IP":"(.*)","PROXY_LAST_UPDATE":".*","PROXY_PORT":"(.*)","PROXY_REFS"', html) | |
| for i in xrange(0,len(match)): | |
| proxy_ip = match[i][0] | |
| proxy_port = match[i][1] | |
| proxy_text = proxy_ip + ':' + proxy_port | |
| print proxy_text | |
| proxy = urllib2.ProxyHandler({'https': proxy_text}) | |
| opener = urllib2.build_opener(proxy) | |
| urllib2.install_opener(opener) | |
| try: | |
| response = urllib2.urlopen('https://ctf.fluxfingers.net/ref/7xYpAcceEDfEEuk') | |
| datum = response.read().decode("UTF-8") | |
| response.close() | |
| print datum | |
| if 'Location' in datum: | |
| break | |
| except urllib2.URLError, e: | |
| print(str(e) + '\n') | |
| continue | |
| except Exception, e: | |
| print(str(e) + '\n') | |
| continue |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/trietptm/7134588
https://gist.github.com/trietptm/7134604