View Single Post
Old Jan 6th, 2006, 10:18 AM   #13
Steveire
Newbie
 
Join Date: Jan 2006
Posts: 13
Rep Power: 0 Steveire is on a distinguished road
Thanks very much for that. I've been playing around with it for a while. No progress yet, but I've tried a few things.

First off, turning on the listener, and connecting to local host with Firefox:
C:\Python22>python tcplistener.py 80
GET / HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/200511
11 Firefox/1.5
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plai
n;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive

turn on listener and attempt to submit the page with firefox:
C:\Python22>python tcplistener.py 80
POST /w/index.php?title=Wikipedia:Sandbox&action=submit HTTP/1.1
Host: en.wikipedia.org
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/200511
11 Firefox/1.5
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plai
n;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://en.wikipedia.org/w/index.php?title=Wikipedia:Sandbox&action=edit

Cookie: enwikiUserName=Steveire; enwikiUserID=411483; enwiki_session=f173420c3f5
db04746c52be228d5ec8e

Content-Type: multipart/form-data; boundary=---------------------------114782935
826962
Content-Length: 1045

-----------------------------114782935826962
Content-Disposition: form-data; name="wpSection"


-----------------------------114782935826962
Content-Disposition: form-data; name="wpStarttime"

20060106152025
-----------------------------114782935826962
Content-Disposition: form-data; name="wpEdittime"

20060106152007
-----------------------------114782935826962
Content-Disposition: form-data; name="wpScrolltop"

0
-----------------------------114782935826962
Content-Disposition: form-data; name="wpTextbox1"

{{Please leave this line alone (sandbox heading)}}
<!-- Hello! Feel free to try your formatting and editing skills below this line.
 As this page is for editing experiments, this page will automatically be cleane
d every 12 hours. -->
test2

-----------------------------114782935826962
Content-Disposition: form-data; name="wpSummary"

this is test 2
---------------------
--------114782935826962
Content-Disposition: form-data; name="wpSave"

Save page
-----------------------------114782935826962--

Using this python code:
import urllib
import httplib


params = urllib.urlencode({
    'wpTextbox1': '{{Please leave this line alone (sandbox heading)}}\nThis test is the best',
    'wpSummary': 'This is a clear test', 'wpSave': 1})
   
headers = {"Content-type": "application/x-www-form-urlencoded",
    "User-agent": "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5",
    "Referer": "http://en.wikipedia.org/w/index.php?title=Wikipedia:Sandbox&action=edit",
    "Accept": "text/plain"}

conn = httplib.HTTPConnection("en.wikipedia.org:80")
conn.request("POST", "/w/index.php?title=Wikipedia:Sandbox&action=submit", params, headers)
response = conn.getresponse()
print response.status, response.reason

data = response.read()
conn.close()
print response
print data

Next, turn on the listener, and attempt to submit the code with python:
C:\Python22>python tcplistener.py 80
POST /w/index.php?title=Wikipedia:Sandbox&action=submit HTTP/1.1
Host: en.wikipedia.org
Accept-Encoding: identity
Content-Length: 137
Referer: http://en.wikipedia.org/w/index.php?title=Wikipedia:Sandbox&action=edit

Content-type: application/x-www-form-urlencoded
Accept: text/plain
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/200511
11 Firefox/1.5


wpSave=1&wpTextbox1=%7B%7BPlease+leave+this+line+alone+%28sandbox+heading%29%7D%
7D%0AThis+test+is+the+best&wpSummary=This+is+a+clear+test

I don't know if there is an issue with whether "User-agent" or "User-Agent" is used, but i've tried both in the python submission headers. I also added the referrer bit to see what happened. I find it interesting that it was grouped above, while the "User-agent" bit was left below, as if the program didn't know what to do with them.

I tried to listen on the Login page, but, even though i have en.wikipedia.org aliased to 127.0.0.1, it still logs in sucessfully. I imagined it was logging in through a different server, so I tried aliasing "*.wikipedia.org" and "wikipedia.org" but to no effect.

I thought this TCP listener would sort all of this out, but it seems like I'm losing sight of the original issue here, and getting bogged down a bit.

So, any other ideas on how to submit the edit page form and login form? Or can you see anything immediately and basically wrong with how I am attempting to send the HTTP headers or any other part of the code?
Steveire is offline   Reply With Quote