Jump to content

PHP Login with CURL

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
juice

juice

    Newbie

  • Members
  • Pip
  • 5 posts
Hello i have a problem with curl loggin into website mobile.de
Login page is https login.mobile.de
I have this code

<?

        $curl=curl_init();


        curl_setopt($curl,CURLOPT_RETURNTRANSFER ,1 );

        curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10');

        curl_setopt($curl,CURLOPT_HEADER , 1);

        curl_setopt($curl,CURLOPT_FOLLOWLOCATION, 1);

         // enable SSL

        curl_setopt($curl,CURLOPT_SSL_VERIFYPEER, FALSE);

        curl_setopt($curl,CURLOPT_SSL_VERIFYHOST, 2);


        curl_setopt($curl,CURLOPT_COOKIEJAR, "cookie.txt");

        curl_setopt($curl,CURLOPT_COOKIEFILE, "cookie.txt");

        curl_setopt($curl,CURLOPT_TIMEOUT,10000);

        curl_setopt($curl,CURLOPT_URL,"https://login.mobile.de/cas/login");


        curl_setopt($curl,CURLOPT_POST ,1);

        $post = array(

          "username" => 'user',

          "password" => 'parola',

          "_eventId" => 'submit',

          "browserFingerprint" => $_SERVER['HTTP_USER_AGENT'],

          "lt"  =>      '_cB7B0D11C-F30B-414D-BC92-7EBD653B5E4D_k5E047450-68AD-67E5-B3FA-5414826C52D8'

        );

        //print_r($post);

        curl_setopt($curl,CURLOPT_POSTFIELDS,$post);

        echo curl_exec($curl);


?>


I tried to post first request , and after this to get the value of "lt" variable, and to post it together with user and password.
The login page doesnt reply any message.
I tried to make a personally certifiy with openssl from my server , but no working.
Where i'm wrong in this code?
I just want to login automatically with CURL into mobile.de
Thanks

#2
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
I'm pretty sure lt changes for each user, so first, just open the page and read it's content to get the lt-code from the page, then try to login with the for this time valid lt-code
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#3
juice

juice

    Newbie

  • Members
  • Pip
  • 5 posts
<?php

@unlink("page.html");

@unlink("result.html");

@unlink("cookie.txt");

$stdopts = array(

    CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10',

    CURLOPT_SSL_VERIFYPEER => FALSE,

    CURLOPT_SSL_VERIFYHOST => 2,

    CURLOPT_COOKIEJAR => 'cookie.txt',

    CURLOPT_COOKIEFILE => 'cookie.txt',

    CURLOPT_RETURNTRANSFER => TRUE,

    CURLOPT_HEADER => TRUE,

    CURLOPT_CAINFO => 'cacert.pem',

    CURLOPT_HTTPHEADER => array(

        "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8,application/json",

        "Accept-Language: en-us,en;q=0.5",

        //"Accept-Encoding: gzip,deflate",

        "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7",

        //"Keep-Alive: 115",

        //"Connection: keep-alive",

    ),

);

//-------- 1st request

$ch = curl_init();

var_dump(curl_setopt_array($ch,$stdopts));

var_dump(curl_setopt_array($ch,array(

    CURLOPT_URL => 'https://login.mobile.de/cas/login'

)));


$site = tidy_repair_string(curl_exec($ch),array(),'utf8');

var_dump(curl_error($ch));

file_put_contents('page.html',$site);

curl_close($ch);

$doc = new DOMDocument();

var_dump($doc->loadHTML($site));

unset($site);

$path = new DOMXPath($doc);

$lts = $path->query('//input[@name="lt"]/@value');

if(1 === $lts->length) {

    $lt = $lts->item(0)->value;

}

else {

    die('no lt');

}

//-------- 2nd request

sleep(rand(30,60));

$ch2 = curl_init();

var_dump(curl_setopt_array($ch2,$stdopts));

var_dump(curl_setopt_array($ch2,array(

    CURLOPT_URL => 'https://login.mobile.de/cas/login',

    CURLOPT_REFERER => 'https://login.mobile.de/cas/login',

    CURLOPT_POST => TRUE,

    CURLOPT_POSTFIELDS => array(

        'username' => 'foo',

        'password' => 'bar',

        'lt' => $lt,

        '_eventId' => 'submit',

        'browserFingerprint' => ''

    ),

)));


$site = tidy_repair_string(curl_exec($ch2),array(),'utf8');

var_dump(curl_error($ch2));

curl_close($ch2);

file_put_contents('result.html',$site);

Done this:)
I got lt from website , i wrote a sleep rand between 30 and 60 to simulate human actions.
I simulate mozilla firefox in header.
Certify is from http://curl.haxx.se/ca/cacert.pem i read that is more advanced than one created with openssl.
I dont know what i'm wrong, with firebug i see just these variabiles, and that page doesnt get my variables.

#4
juice

juice

    Newbie

  • Members
  • Pip
  • 5 posts
nobody know the login curl problem ?

#5
rbm

rbm

    Newbie

  • Members
  • Pip
  • 1 posts
Hello,

do you have solved the problem? I tried for two weeks to login in this site...

Thank you!

#6
juice

juice

    Newbie

  • Members
  • Pip
  • 5 posts
No man , i cant make a good login , and i cant find any alternative for logging into website.
I tried many ideas, but nothing.
I understand that mobile.de uses CAS - centralised authentification service, and i dont know if this does matter.

#7
juice

juice

    Newbie

  • Members
  • Pip
  • 5 posts
nobody can help me with this login? i can post my code here , to test it