I am trying to create a python script that will do a form submission or a "post". I have captured data from wireshark, but I'm not quite sure how to get what I need into python.
Here is the captured data:
python script:
One part that I know will be a problem, is that the "fvContestID" is always going to be different, so I'm not sure how I would generate the right one for the post.
Greatly appreciate anyone who can help, or get me on the right track. Thanks.
Here is the captured data:
Code:
C}bEL[@@}+N&,SP+>\.d
/0POST /somesite/entry.do HTTP/1.1
Host: somesite.network.com
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.1) Gecko/2008071620 Firefox/3.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
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: [URL unfurl="true"]http://www.somesite.network.com/rubbish.html[/URL]
Content-Type: application/x-[URL unfurl="true"]www-form-urlencoded[/URL]
Content-Length: 298
fvContestId=1242&fvEntryType=STANDARD&fvRId=&fvFirst=First&fvLast=Last&fvEmail=email%40gmail.com&fvEmailConfirm=email%40gmail.com&fvAddress1=100+Fake&fvCity=Somewhere+Somewhere&fvState=NY&fvZip=19000&fvEvePhone=123-123-1234&fvGender=m&submitButton=Enter+for+a+chance+to+win%21
python script:
Code:
#!/usr/bin/env python
import pycurl, StringIO, os
# Constants
USER_AGENT = 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.1) Gecko/2008071620 Firefox/3.0.1'
LOGIN_URL = '[URL unfurl="true"]http://www.somesite.network.com/rubbish.html'[/URL]
LOGIN_POST_DATA = 'fvContestId=1242&fvEntryType=STANDARD&fvRId=&fvFirst=First&fvLast=Last&fvEmail=email%40gmail.com&fvEmailConfirm=email%40gmail.com&fvAddress1=100+Fake&fvCity=Somewhere+Somewhere&fvState=NY&fvZip=19000&fvEvePhone=123-123-1234&fvGender=m&submitButton=Enter+for+a+chance+to+win%21'
SUBMISSION_URL = '[URL unfurl="true"]http://somesite.network.com//somesite/entry.do'[/URL]
headers = ['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']
# Request post page
slurpp = pycurl.Curl()
slurpp.setopt(pycurl.COOKIEFILE, 'cookiejar.txt')
slurpp.setopt(pycurl.URL, SUBMISSION_URL)
slurpp.setopt(pycurl.POSTFIELDS, LOGIN_POST_DATA)
slurpp.setopt(pycurl.POST, 1)
slurpp.setopt(pycurl.VERBOSE, 1)
slurpp.perform()
# Clean up and close out
slurpp.close()
os.remove('cookiejar.txt')
One part that I know will be a problem, is that the "fvContestID" is always going to be different, so I'm not sure how I would generate the right one for the post.
Greatly appreciate anyone who can help, or get me on the right track. Thanks.