Using curl with cookies (username / password)

300 views Asked by At

I hope someone can help me out on this one. I have been trying this for a while now, with all sorts of variations and cannot seem to get this to work.

I am trying to script a way to log in to https://login.three.ie/ to check account balance from */My_account_balance

I have tried all sorts of wget commands but from what I read, curl is more likely able to accomplish this task..

I have been trying variations I came across online, including from here on stackoverflow but nothing seems to work.

Here is the last one I tried:

    curl -X POST -c cookies.txt -u "Uern@me:P@ssw0rd" https://login.three.ie/

This does save the cookies file here:

    $ cat cookies.txt

    Netscape HTTP Cookie File

    #http://curl.haxx.se/docs/http-cookies.html
    This file was generated by libcurl! Edit at your own risk.
    HttpOnly_login.three.ie        FALSE   /       FALSE   1433988274
    laravel_session eyJpdiI6IkFZWmxvZ2oyXC9NNGVIbHVpejZwRWp3PT0iLCJ2YWx1ZSI6Imxkd25UKzBoMldiQlhYZVJnVUpuNUVsblZ1cGJYZWcwM2E1bTtIWHRiQ2pwV0VwemJ4NFlYcDlzTndSeFRNanpwdDhMMTIrS2RGZGdGd0RNZU1yREJ3PT0iLCJtYWMiOiI0NWUwYzc1TY4ODI3ZmY3ODY5NjliODkxODMyODIzMjQwNmNkNjljNTE2NzQxNmQ4MzhhNDljNTdjM2QwZGY1In0%3D

But when I try to re-use the cookie, it looks like there is a redirect or something, as this is what I get:

    $ curl -b cookies.txt  https://my3account.three.ie/My_account_balance
    <html><head><title>302 Moved Temporarily</title></head>
    <body bgcolor="#FFFFFF">
    <p>This document you requested has moved temporarily.</p>
    <p>It's now at <a href="https://sso.three.ie/mylogin//login?auth-        
    required=seamless&amp;service=https&#37;3A&#37;F&#37;                   
    2Fmy3account.three.ie&#37;2FMy_account_balance">https://sso.three.ie/mylogin//login?auth-required=seamless&amp;service=https&#37;3A&#37;2F&#37;2Fmy3account.three.ie&#37;2FMy_account_balance</a>.</p>

I don't understand what's happening here. Does anyone have an idea of what's going wrong, or even better, how to remedy this?

Thanks

1

There are 1 answers

1
AudioBubble On

You need to comment this line :

This file was generated by libcurl! Edit at your own risk.

since it's obviously an invalid cookie.