cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Creating cookie for authentication

From: Josh Luthman <josh_at_imaginenetworksllc.com>
Date: Mon, 17 Oct 2011 01:20:07 -0400

On Sun, Oct 16, 2011 at 10:10 PM, Ralph Mitchell
<ralphmitchell_at_gmail.com> wrote:
> 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
>
>

I tried your two commands and the cookie "cookies" looks very similar
to that of my "inxcookie". Neither of these allowed me to wget an
image, the request is saving the login page's HTML and stores it to
image.jpg.

>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.

Based on the HTML of the login page - http://pastebin.com/CP9YsbTr -
you'll see Content-Type: multipart/form-data. This is why I believe I
need --form. This is not for Xymon but rather an IP camera.

-------------------------------------------------------------------
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