#Cracking Offensive Security's web challenge for CTP
# http://fc4.me/
# - n1nja
import urllib2
import hashlib

m = hashlib.md5()

host = "http://fc4.me/index.php"
page = urllib2.urlopen(host)
for index in page:
	if 'srvstr' in index:
		index = index.split('\'')
		srvstr = str(index[1])

host = "http://fc4.me/fc4.js"
page = urllib2.urlopen(host)
for index in page:
	if 'hex' in index:
		index = index.split('hexMD5')[1:]
		index = index[0].split('\"')[1]
		valhex = str(index)

valhex = valhex.split('\\x')
data = "".join(valhex)
hexstr = "".join(chr(int(data[i:i+2], 16)) for i in range(0, len(data), 2))

strs = hexstr+srvstr
m.update(strs)
print "\n\nCongratulations for cracking the Offensive Security Challenge\nhttp://fc4.me/index.php\n\nYour Secret Code is: "+m.hexdigest()+"\n"

