cURL / Mailing Lists / curl-users / Single Mail

curl-users

Newbie help : logging into website with cookies

From: Al Grant <bigal.nz_at_gmail.com>
Date: Sun, 12 Oct 2014 10:48:34 +1300

Hi All,

I would really appreicate any help on this. I have been trying to
login to a website and POST data to a second page for about 3 days now
without success.

I can acheive a login by copying the curl commands from firefox, but
if I try to script it, I fail. In essence when I try to script it I am
removing the -H "Cookie:...." for -b

Here is what I get from FF:

curl "https://www.anpronline.net/j_spring_security_check" -H "Host:
www.anpronline.net" -H "User-Agent: Mozilla/5.0 (Windows NT 6.1;
WOW64; rv:32.0) Gecko/20100101 Firefox/32.0" -H "Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" -H
"Accept-Language: en-GB,en;q=0.5" -H "Accept-Encoding: gzip, deflate"
-H "Referer: https://www.anpronline.net/index.html" -H "Cookie:
__utma=86946376.583746695.1412828339.1413009922.1413057495.9;
__utmz=86946376.1412828339.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not"%"20provided);
JSESSIONID=113idx1ipor6y10oul7yy6uaoi;
AWSELB=A7A737371AF52D0B544DAF902D9C2A0C5FBFC37325B3CB707E1EFDCF041AE1E91355018DDFD9065F26A21E422A304806A548114E34518568CA193FB0649451B57AE20FD01E;
__utmc=86946376; __utmb=86946376.10.10.1413057495; __utmt=1" -H
"Connection: keep-alive" --data
"j_username=al"%"40test.co.nz&j_password=SECRET"

curl "https://www.anpronline.net/blacklists/bl.html" -H "Host:
www.anpronline.net" -H "User-Agent: Mozilla/5.0 (Windows NT 6.1;
WOW64; rv:32.0) Gecko/20100101 Firefox/32.0" -H "Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" -H
"Accept-Language: en-GB,en;q=0.5" -H "Accept-Encoding: gzip, deflate"
-H "Referer: https://www.anpronline.net/blacklists.html" -H "Cookie:
__utma=86946376.583746695.1412828339.1413009922.1413057495.9;
__utmz=86946376.1412828339.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not"%"20provided);
JSESSIONID=kyr8s0yhfj408gbfauj4yroh;
AWSELB=A7A737371AF52D0B544DAF902D9C2A0C5FBFC37325B3CB707E1EFDCF041AE1E91355018DDFD9065F26A21E422A304806A548114E34518568CA193FB0649451B57AE20FD01E;
__utmc=86946376; __utmb=86946376.14.10.1413057495; __utmt=1" -H
"Connection: keep-alive" --data "name=test&siteId=0"

And to script it:

#!/bin/bash
#new
curl --cookie-jar /tmp/anpronline.cookie "https://anpronline.net"

curl "https://www.anpronline.net/j_spring_security_check" -H "Host:
www.anpronline.net" -H "User-Agent: Mozilla/5.0 (Windows NT 6.1;
WOW64; rv:32.0) Gecko/20100101 Firefox/32.0" -H "Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" -H
"Accept-Language: en-GB,en;q=0.5" -H "Accept-Encoding: gzip, deflate"
-H "Referer: https://www.anpronline.net/index.html" "Connection:
keep-alive" -b /tmp/anpronline.cookie --data
"j_username=al"%"40test.co.nz&j_password=SECRET"

curl "https://www.anpronline.net/blacklists/bl.html" -H "Host:
www.anpronline.net" -H "User-Agent: Mozilla/5.0 (Windows NT 6.1;
WOW64; rv:32.0) Gecko/20100101 Firefox/32.0" -H "Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" -H
"Accept-Language: en-GB,en;q=0.5" -H "Accept-Encoding: gzip, deflate"
-H "Referer: https://www.anpronline.net/blacklists.html" -b
/tmp/anpronline.cookie -H "Connection: keep-alive" --data
"name=test&siteId=0"

Could someone please help?

Many thanks,

-- 
"Beat it punk!"
- Clint Eastwood
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2014-10-12