conn.py

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/python
import httplib, urllib
params = urllib.urlencode({'pma_username': 'pacify', 'pma_password': 'password', 'lang': 'ru-utf-8'})
conn = httplib.HTTPConnection("localhost")
conn.putrequest("POST", "/phpmyadmin/index.php")
conn.putheader("Content-Type", "application/x-www-form-urlencoded")
conn.putheader("Accept", "text/plain")
conn.putheader("Content-Length", str(len(params)))
conn.endheaders()
conn.send(params)
response = conn.getresponse()
print 'Params',repr(params)
print '[1]',response.status, response.reason
cookies = response.msg.getheader("Set-Cookie")
conn.close()
print 'Cookies',repr(cookies)
conn = httplib.HTTPConnection("localhost")
conn.connect()
conn.putrequest("GET", "/phpmyadmin/index.php")
conn.putheader("Cookie",cookies)
conn.endheaders()
response = conn.getresponse()
print '[2]',response.status, response.reason
data = response.read()
conn.close()
print 'Size',len(data)