Also, submitting the answer after sometime results in a "too late" response. Inspecting the HTTP headers, there is a "Set-Cookie" and "EQ" header.
The value of the "EQ" HTTP header is base64 encoded which decodes to an array that contains the equation to be solved.
It requires automation due to the time bound nature of the challenge. Also, the cookie needs to be passed along with the POST request since it is used to track the answer of the corresponding "EQ" equation.
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 | |
import urllib | |
import base64 | |
url="http://176.9.193.13/ASmallCalculationChal411A784Y.php" | |
u=urllib2.urlopen(url) | |
eq=u.headers["EQ"] | |
cookie=u.headers["Set-Cookie"].split(";")[0] | |
s=base64.decodestring(eq).replace("\n","").replace(" ","").replace("array(","").replace(")","").replace("'","")[0:-1] | |
d=urllib.urlencode({'result':eval("".join(list(i.split("=>")[1] for i in s.split(","))))}) | |
req=urllib2.Request(url) | |
req.add_header('Cookie',cookie) | |
print urllib2.urlopen(req,d).read() |
0 comments:
Post a Comment