3 function connect(method)
5 HOST = "ctf.nullcon.net"
6 FILE = "/inet/tcp/0/" HOST "/80"
7 PATH = "/challenges/programming/challenge.php"
9 print method " " PATH " HTTP/1.0" |& FILE
10 print "Host: " HOST "" |& FILE
20 while (sock |& getline line) {
21 if (match(line, "Set-Cookie:"))
23 if (match(line, "span"))
28 gsub(" ", " ", text)
29 gsub("<[^>]*>", " ", text)
30 gsub("^ *| *$", "", text)
32 gsub("^[^:]*: *", "", cookie)
33 gsub(" *;.*", "", cookie)
35 sock = connect("POST")
36 resp = "answer=" text "&submit=Submit"
37 print "Content-Type: application/x-www-form-urlencoded" |& sock
38 print "Content-Length: " length(resp) |& sock
39 print "Cookie: " cookie |& sock
43 while (sock |& getline line)