auto login mit curl

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • auto login mit curl

    Hallo,

    bei folgender Sache komme ich nicht weiter: Ich schaffe es nicht, Username und Passwort autom. zu übermitteln.
    aclUsername und aclPassword sind die Namen der Eingabefelder, siehe $POSTFIELDS (habe ich dem Quelltext entnommen)


    Die seite wird zwar geladen, aber es erscheint die login maske,
    das soll nicht sein. Log ich mich per Hand ein, passiert das:
    Seite wird fehlerhaft geladen ("Site: yyyyyy/disp.cgi/_ad/Login missing", Browsermeldung).
    Passwort wird übrigens als byte-Array erwartet.
    Idee, was ich Depp falsch mache?



    PHP-Code:
    <?

        $user_id = "????"; // ID
        $user_password = "?????"; // Passwort
        $header = "Content-Type: application/x-www-form-urlencoded";
        

        $LOGINURL= "https://xxxxx.de.xxo/yyyyyy/disp.cgi/_ad/Login";
        $agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; 
            rv:1.4) 
            Gecko/20030624 Netscape/7.1 (ax)";
     
          

        $ch = curl_init();
     
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
            curl_setopt($ch, CURLOPT_URL,$LOGINURL);
        curl_setopt($ch, CURLOPT_USERAGENT, $agent);
        curl_setopt($ch, CURLOPT_HEADER, 0);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

        $result = curl_exec ($ch);
        
        curl_close ($ch);

        // schick die Daten ab


        $LOGINURL = "https://xxxxx.de.xxo/yyyyyy/disp.cgi/_ad/Login";
        
            $POSTFIELDS =                        
           'aclUsername='.$user_id.'&id=loginname&aclPassword=
           '.$user_password.'
           &id=password&loginBtn=Login';

          $reffer = "https://xxxxx.de.xxo/yyyyyy/disp.cgi/_ad/Login";

        $ch = curl_init(); 
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
            curl_setopt($ch, CURLOPT_URL,$LOGINURL);
        curl_setopt($ch, CURLOPT_USERAGENT, $agent);
        curl_setopt($ch, CURLOPT_HEADER, 0);
           curl_setopt($ch, CURLOPT_POST, 1); 
            curl_setopt($ch, CURLOPT_POSTFIELDS,$POSTFIELDS); 
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_REFERER, $reffer);
        
        $result = curl_exec ($ch);
        
        print $result;    
        curl_close ($ch); 
    ?>
    Zuletzt geändert von Phillip; 10.06.2005, 21:23.

  • #2
    Ich bin der Meinung, dass man auch diesen Code auf eine vernünfige Breite kürzen kann...

    Kommentar


    • #3
      Ich hab's schon....
      Quelltext genau ansehen, sowohl hidden fields mit name und value übergeben, als auch name der text fields mit username und Passwort...aber das kommt eben ganz auf den Quelltext an.

      Angenommen, ein Login Formular hat folgende Elemente:

      <input type=hidden name="Id" value="Das">
      <input type=hidden name="sid" value="">
      <input type=hidden name="ToLogIn" value="Login">

      <INPUT type="text" username=Name>
      <INPUT type="password" name=password>

      Dann muss

      curl_setopt($ch, CURLOPT_POSTFIELDS, "&Id=Das&sid=
      &ToLogIn=Login&username=Name&password=password");

      so aussehen...

      Dann klappt's.

      Kommentar

      Lädt...
      X