How to save POST&GET headers of a web page with "Wireshark"?

Posted by brilliant on Super User See other posts from Super User or by brilliant
Published on 2010-04-08T23:00:50Z Indexed on 2010/04/08 23:03 UTC
Read the original article Hit count: 399

Filed under:
|
|

Hello everybody,

I've been trying to find a python code that would log in to my mail box on yahoo.com from "Google App Engine". I was given this code:

import urllib, urllib2, cookielib

url = "https://login.yahoo.com/config/login?"
form_data = {'login' : 'my-login-here', 'passwd' : 'my-password-here'}

jar = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
form_data = urllib.urlencode(form_data)
# data returned from this pages contains redirection
resp = opener.open(url, form_data)
# yahoo redirects to http://my.yahoo.com, so lets go there instead
resp = opener.open('http://mail.yahoo.com')
print resp.read()

The author of this script looked into HTML script of yahoo log-in form and came up with this script.

That log-in form contains two fields, one for users' Yahoo! ID and another one is for users' password.

However, when I tried this code out (substituting mu real Yahoo login for 'my-login-here' and my real password for 'my-password-here'), it just return the log-in form back to me, which means that something didn't work right.

Another supporter suggested that I should send an MD5 hash of my password, rather than a plain password.

He also noted that in that log-in form there are a lot other hidden fields besides login and password fields (he called them "CSRF protections") that I would also have to deal with:

<input type="hidden" name=".tries" value="1"> 
<input type="hidden" name=".src" value="ym"> 
<input type="hidden" name=".md5" value=""> 
<input type="hidden" name=".hash" value=""> 
<input type="hidden" name=".js" value=""> 
<input type="hidden" name=".last" value=""> 
<input type="hidden" name="promo" value=""> 
<input type="hidden" name=".intl" value="us"> 
<input type="hidden" name=".bypass" value=""> 
<input type="hidden" name=".partner" value=""> 
<input type="hidden" name=".u" value="bd5tdpd5rf2pg"> 
<input type="hidden" name=".v" value="0"> 
<input type="hidden" name=".challenge" value="5qUiIPGVFzRZ2BHhvtdGXoehfiOj"> 
<input type="hidden" name=".yplus" value=""> 
<input type="hidden" name=".emailCode" value=""> 
<input type="hidden" name="pkg" value=""> 
<input type="hidden" name="stepid" value=""> 
<input type="hidden" name=".ev" value=""> 
<input type="hidden" name="hasMsgr" value="0"> 
<input type="hidden" name=".chkP" value="Y"> 
<input type="hidden" name=".done" value="http://mail.yahoo.com"> 

He said that I should do the following:

  1. Simulate normal login and save login page that I get;
  2. Save POST&GET headers with "Wireshark";
  3. Compare login page with those headers and see what fields I need to include with my request;

I really don't know how to carry out the first two of these three steps. I have just downloaded "Wireshark" and have tried capturing some packets there. However, I don't know how to "simulate normal login and save the login page". Also, I don't how to save POST$GET headers with "Wireshark". Can anyone, please, guide me through these two steps in "Wireshark"? Or at least tell me what I should start with. Thank You.

© Super User or respective owner

Related posts about wireshark

Related posts about headers