cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Creating cookie for authentication

From: Ralph Mitchell <ralphmitchell_at_gmail.com>
Date: Sun, 16 Oct 2011 22:10:29 -0400

On Sun, Oct 16, 2011 at 3:57 PM, Josh Luthman
<josh_at_imaginenetworksllc.com>wrote:

> I am trying to create a cookie so that I can then use wget to obtain
> an image embedded behind a login page.
>
> I am working with this HTML log in page:
> http://pastebin.com/CP9YsbTr
>
> Now I am trying to create a cookie with this command:
> curl -silent -c inxcamcookie --form username=admin --form
> password=thisismypasswd --form Submit=Login
> http://10.10.10.191/login.cgi
> curl -silent -c inxcamcookie --form
> "username=admin&password=thisismypasswd&Submit=Login"
> http://10.10.10.191/login.cgi
>

 You're probably going to need to do a "get" on the login page first, which
very likely will hand you the cookie. Then post back the login form with
userid and password. Something like this:

     curl -s -S -L -b cookies -c cookies -o loginpage.html
http://10.10.10.191/login.html

     curl -s -S -L -b cookies -c cookies -o loginresult.html \
           --form username=admin \
           --form password=thisismypasswd \
           --form Submit=Login \
           http://10.10.10.191/login.cgi

Are you sure the login requires a multipart form? In all the web page
monitoring scripts I've written for hobbit/xymon I don't believe I ever used
a multipart form post.

Ralph Mitchell

-------------------------------------------------------------------
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 2011-10-17