Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jun 2008
    Location
    Vista, CA
    Posts
    59
    Thanks
    3
    Thanked 0 Times in 0 Posts

    using cURL to login

    I'm trying to use cURL to login to http://s1.zetaboards.com/Egg_Rescue_HQ/index/ this is the code I'm currently using (I've replaced my password with 'privet'):

    PHP Code:
    $ch curl_init(); //create cURL
    $agent=$_SERVER["HTTP_USER_AGENT"];
      
    curl_setopt($chCURLOPT_USERAGENT$agent);
      
    curl_setopt($chCURLOPT_URL"http://s1.zetaboards.com/Egg_Rescue_HQ/login/log_in/");
      
    curl_setopt($chCURLOPT_POST1); //set cURL to post data
      
    curl_setopt($chCURLOPT_POSTFIELDS"uname=Christian271&pw=privet"); //set data to post
      
    curl_setopt($chCURLOPT_FOLLOWLOCATION  ,1); //set cURL to fallow rederects
      
    curl_setopt($chCURLOPT_RETURNTRANSFER  ,1);  // return the contents of the call
      
    $data curl_exec($ch);
      echo 
    $data;
      
    curl_close($ch); 
    When I run the script it just displays the forum content as if I wasn't logged in. you can see the page here: http://mobileforum.200u.com/. Any ideas?

  • #2
    New Coder
    Join Date
    Jun 2008
    Location
    Vista, CA
    Posts
    59
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Anyone?

  • #3
    New Coder
    Join Date
    Dec 2009
    Posts
    84
    Thanks
    6
    Thanked 3 Times in 3 Posts
    Your script look like right on the place...

    hm... do you have access to change/modified the file "http://s1.zetaboards.com/Egg_Rescue_HQ/login/log_in/" Let say login.php
    if yes just try put this:

    PHP Code:
    <?php
        var_dump
    ($_POST);
    ?>
    to login.php
    i hope this can help You
    Best Regards,

  • #4
    New Coder
    Join Date
    Jun 2008
    Location
    Vista, CA
    Posts
    59
    Thanks
    3
    Thanked 0 Times in 0 Posts
    No I do not have accesses.

  • #5
    Regular Coder hinch's Avatar
    Join Date
    Sep 2005
    Location
    UK
    Posts
    923
    Thanks
    25
    Thanked 80 Times in 80 Posts
    your login curl script will need to store the cookie generated by the forums else you won't be able to login
    A programmer is just a tool which converts caffeine into code

    My work: http://www.fcsoftware.co.uk && http://www.firstcontactcrm.com
    My hobby: http://www.angel-computers.co.uk
    My life: http://www.furious-angels.com

  • #6
    New Coder
    Join Date
    Jun 2008
    Location
    Vista, CA
    Posts
    59
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks for your replay!

    I added cookie handling and it still doesn't work,
    PHP Code:
    $ch curl_init(); //create cURL
    $agent=$_SERVER["HTTP_USER_AGENT"];
    curl_setopt($chCURLOPT_COOKIEJAR'cookies.txt');
    curl_setopt($chCURLOPT_COOKIEFILE'cookies.txt');
    curl_setopt($chCURLOPT_USERAGENT$agent);
    curl_setopt($chCURLOPT_URL"http://s1.zetaboards.com/Egg_Rescue_HQ/login/log_in/");
    curl_setopt($chCURLOPT_POST1); //set cURL to post data
    curl_setopt($chCURLOPT_POSTFIELDS"uname=Christian271&pw=privet"); //set data to post
    curl_setopt($chCURLOPT_FOLLOWLOCATION  ,1); //set cURL to fallow rederects
    curl_setopt($chCURLOPT_RETURNTRANSFER  ,1);  // return the contents of the call
    $data curl_exec($ch);
    echo 
    $data;
    $info curl_getinfo($ch);
    print_r($info);
    curl_close($ch); 
    http://whirlwindproduction.com/dchat...obile%20Forum/

  • #7
    Regular Coder hinch's Avatar
    Join Date
    Sep 2005
    Location
    UK
    Posts
    923
    Thanks
    25
    Thanked 80 Times in 80 Posts
    the forums won't just create a cookie called cookie.txt it'll be something like domainname.cookie or user-date.cookie etc something similar you'll have to replicate that else when the forum then requests the cookie back it'll be looking for a cookie that doesn't exist with a different name.

    you may also want to check if the forums pass a sessionid across the query string that matches the cookie contents and also check for xss protection on the forum as there may be a hidden key that needs to be returns to match the cookie too before login form submission will work properly
    A programmer is just a tool which converts caffeine into code

    My work: http://www.fcsoftware.co.uk && http://www.firstcontactcrm.com
    My hobby: http://www.angel-computers.co.uk
    My life: http://www.furious-angels.com

  • #8
    New Coder
    Join Date
    Jun 2008
    Location
    Vista, CA
    Posts
    59
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I created a test form http://whirlwindproduction.com/dchat.../testlogin.php it works fine, meaning that it's not a missing field or something. The way I understood cURL cookies is that cookies.txt is where cURL would store to cookies, not the cookie name its self. If I am wrong than can you point me in the right direction?

    Thanks!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •