+ Reply to Thread
Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: Logging into vBulletin using cURL

  1. #1
    Affix is offline Learning Programmer
    Join Date
    Feb 2009
    Location
    Scotland
    Posts
    47
    Blog Entries
    2
    Rep Power
    12

    Logging into vBulletin using cURL

    Well I was writing a Spider to crawl forums and Mirror them and Needed a way to login to a vBulletin based forum. vBulletin does not Allow a cURL Post unless the URL Has been added to the "allow post from" list in the Admin Control Panel.

    Using cURL However we can set an Option that will mask the user agent and Referrer so the vBulletin forum will think we are a normal browser.

    Lets Begin by Creating a new PHP Document

    Code:
    <?php
    /********************
    * cURL Tutorial By Affix
    * Login to a vB forum
    *********************/
    ?>
    Now lets crate a Function in our Document. We should call it vBulletinLogin() and Pass 2 variables. These Variables shall be $user and $pass

    Code:
    <?php
    /********************
    * cURL Tutorial By Affix
    * Login to a vB forum
    *********************/

    function vBulletinLogin($user$pass)
    {

    }
    ?>
    Now we have our function created we need it to start doing something.
    First of all we will need to MD5 The $pass variable as vBulletin submits the MD5 of the password before the server begins to process it.

    Code:
    <?php
    /********************
    * cURL Tutorial By Affix
    * Login to a vB forum
    *********************/

    function vBulletinLogin($user$pass)
    {
           
    $md5Pass md5($pass);
    }
    ?>
    Now we have the MD5 of the password submitted we need to create the post data we are going to submit using cURL. I usually do this by using a variable as it makes it easier to read later.

    Code:
    <?php
    /********************
    * cURL Tutorial By Affix
    * Login to a vB forum
    *********************/

    function vBulletinLogin($user$pass)
    {
           
    $md5Pass md5($pass);
           
    $data "do=login&url=%2Findex.php&vb_login_md5password=$md5Pass&vb_login_username=$user&cookieuser=1";
    }
    ?>
    Notice the syntax of the POST is Similar to a GET.

    Now we have the data we should start to Work with our cURL options But first we need to activate cURL this is done by Defininf a variable using curl_init();

    Code:
    <?php
    /********************
    * cURL Tutorial By Affix
    * Login to a vB forum
    *********************/

    function vBulletinLogin($user$pass)
    {
           
    $md5Pass md5($pass);
           
    $data "do=login&url=%2Findex.php&vb_login_md5password=$md5Pass&vb_login_username=$user&cookieuser=1";

          
    $ch curl_init();
    }
    ?>
    Now we have cURL Initialized lets start setting out Options. This is done using the curl_setopt() Function of PHP. I am not going into detail about each cURL option but will show you the Syntax of curl_setopt()

    Code:
    <?php
    /********************
    * cURL Tutorial By Affix
    * Login to a vB forum
    *********************/

    function vBulletinLogin($user$pass)
    {
           
    $md5Pass md5($pass);
           
    $data "do=login&url=%2Findex.php&vb_login_md5password=$md5Pass&vb_login_username=$user&cookieuser=1";

           
    $ch curl_init();

        
    curl_setopt ($chCURLOPT_URL"h**p://forum.codecall.net/login.php?do=login"); // replace ** with tt
        
    curl_setopt ($chCURLOPT_USERAGENT"Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
        
    curl_setopt ($chCURLOPT_TIMEOUT'10');
        
    curl_setopt($chCURLOPT_POST1);
        
    curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
        
    curl_setopt($chCURLOPT_COOKIEJAR"/tmp/codecall_$user.txt");
        
    curl_setopt($chCURLOPT_COOKIEFILE"/tmp/codecall_$user.txt");
        
    curl_setopt($chCURLOPT_FOLLOWLOCATION1);
        
    curl_setopt ($chCURLOPT_RETURNTRANSFER1);
        
    $store curl_exec ($ch);
    }
    ?>
    Now we have the Page Returned and it is stored in the Variable $store we can close cURL using curl_close()

    Code:
    <?php
    /********************
    * cURL Tutorial By Affix
    * Login to a vB forum
    *********************/

    function vBulletinLogin($user$pass)
    {
           
    $md5Pass md5($pass);
           
    $data "do=login&url=%2Findex.php&vb_login_md5password=$md5Pass&vb_login_username=$user&cookieuser=1";

           
    $ch curl_init();

        
    curl_setopt ($chCURLOPT_URL"h**p://forum.codecall.net/login.php?do=login"); // replace ** with tt
        
    curl_setopt ($chCURLOPT_USERAGENT"Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
        
    curl_setopt ($chCURLOPT_TIMEOUT'10');
        
    curl_setopt($chCURLOPT_POST1);
        
    curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
        
    curl_setopt($chCURLOPT_COOKIEJAR"/tmp/codecall_$user.txt");
        
    curl_setopt($chCURLOPT_COOKIEFILE"/tmp/codecall_$user.txt");
        
    curl_setopt($chCURLOPT_FOLLOWLOCATION1);
        
    curl_setopt ($chCURLOPT_RETURNTRANSFER1);
        
    $store curl_exec ($ch);

            
    curl_close($ch);
    }
    ?>
    Now we can check to see if we Logged in successfully. To do this we search the page for the string "thank you for logging in" using an IF statement and the strpos function

    Code:
    <?php
    /********************
    * cURL Tutorial By Affix
    * Login to a vB forum
    *********************/

    function vBulletinLogin($user$pass)
    {
           
    $md5Pass md5($pass);
           
    $data "do=login&url=%2Findex.php&vb_login_md5password=$md5Pass&vb_login_username=$user&cookieuser=1";

           
    $ch curl_init();

        
    curl_setopt ($chCURLOPT_URL"h**p://forum.codecall.net/login.php?do=login"); // replace ** with tt
        
    curl_setopt ($chCURLOPT_USERAGENT"Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
        
    curl_setopt ($chCURLOPT_TIMEOUT'10');
        
    curl_setopt($chCURLOPT_POST1);
        
    curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
        
    curl_setopt($chCURLOPT_COOKIEJAR"/tmp/codecall_$user.txt");
        
    curl_setopt($chCURLOPT_COOKIEFILE"/tmp/codecall_$user.txt");
        
    curl_setopt($chCURLOPT_FOLLOWLOCATION1);
        
    curl_setopt ($chCURLOPT_RETURNTRANSFER1);
        
    $store curl_exec ($ch);

            
    curl_close($ch);

           
    $pos strpos($store"Thank you for Logging in");
           if(
    $pos === FALSE) {
                   RETURN 
    0;
           }
           else
           {
                   RETURN 
    1;
            }
    }
    ?>
    Now if the Function finds we are logged in it will return 1 or TRUE
    To call it we can do something like this

    Code:
    <?php
    /********************
    * cURL Tutorial By Affix
    * Login to a vB forum
    *********************/

    function vBulletinLogin($user$pass)
    {
           
    $md5Pass md5($pass);
           
    $data "do=login&url=%2Findex.php&vb_login_md5password=$md5Pass&vb_login_username=$user&cookieuser=1";

           
    $ch curl_init();

        
    curl_setopt ($chCURLOPT_URL"h**p://forum.codecall.net/login.php?do=login"); // replace ** with tt
        
    curl_setopt ($chCURLOPT_USERAGENT"Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
        
    curl_setopt ($chCURLOPT_TIMEOUT'10');
        
    curl_setopt($chCURLOPT_POST1);
        
    curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
        
    curl_setopt($chCURLOPT_COOKIEJAR"/tmp/codecall_$user.txt");
        
    curl_setopt($chCURLOPT_COOKIEFILE"/tmp/codecall_$user.txt");
        
    curl_setopt($chCURLOPT_FOLLOWLOCATION1);
        
    curl_setopt ($chCURLOPT_RETURNTRANSFER1);
        
    $store curl_exec ($ch);

            
    curl_close($ch);

           
    $pos strpos($store"Thank you for Logging in");
           if(
    $pos === FALSE
          {
                   RETURN 
    0;
           }
           else
           {
                   RETURN 
    1;
            }
    }

    if(
    vBulletinLogin("username","password"))
    {
           echo 
    "Logged In";
    }
    else 
    {
           echo 
    "Failed to Login check User / Pass";
    }
    ?>
    Glossary :
    cURL : Client URL. This library basically allows the PHP Server to act as a web browsing client. This libabry is available from hxxp://curl.haxx.se/

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Jordan Guest

    Re: Logging into vBulletin using cURL

    Very nice tutorial! I wrote something similar (although much cruder) a couple of months back. +rep!

    P.S. - Please don't mirror CC

  4. #3
    Join Date
    Sep 2008
    Location
    Australia
    Posts
    4,834
    Blog Entries
    10
    Rep Power
    51

    Re: Logging into vBulletin using cURL

    It seems that cURL is as simple as that Good tutorial mate, +rep
    jQuery Selectors Tutorial - jQuery Striped Table tutorial - jQuery Events - jQuery Validation
    Sorry if I don't post as often as I did, I'll try to get here as much as possible! I'm working my bum off to get this scholarship and other stuff!

  5. #4
    Affix is offline Learning Programmer
    Join Date
    Feb 2009
    Location
    Scotland
    Posts
    47
    Blog Entries
    2
    Rep Power
    12

    Re: Logging into vBulletin using cURL

    Quote Originally Posted by Jordan View Post
    Very nice tutorial! I wrote something similar (although much cruder) a couple of months back. +rep!

    P.S. - Please don't mirror CC

    don't worry Its not for spidering these kinds of sites. It was a paid project to copy post text vBulletin makes it so easy by putting comments where the message starts and ends lmao.

    I got more coming soon

  6. #5
    Jordan Guest

    Re: Logging into vBulletin using cURL

    Yes, vbulletin themes put comments on everything.

  7. #6
    Join Date
    Sep 2008
    Location
    Australia
    Posts
    4,834
    Blog Entries
    10
    Rep Power
    51

    Re: Logging into vBulletin using cURL

    So putting comments everywhere is a good thing?
    jQuery Selectors Tutorial - jQuery Striped Table tutorial - jQuery Events - jQuery Validation
    Sorry if I don't post as often as I did, I'll try to get here as much as possible! I'm working my bum off to get this scholarship and other stuff!

  8. #7
    Affix is offline Learning Programmer
    Join Date
    Feb 2009
    Location
    Scotland
    Posts
    47
    Blog Entries
    2
    Rep Power
    12

    Re: Logging into vBulletin using cURL

    Quote Originally Posted by Brandon W View Post
    So putting comments everywhere is a good thing?
    It depends on what you are doing

    You done really need

    Code:
    <!-- Message -->
    and

    Code:
    <!-- / Message -->
    Just makes it easier for postbots and spammers

    E.g all you need is use cURL or file_get_contents() and you can do this

    Code:
        function split_tag($haystack,$start,$end) {
            if (
    strpos($haystack,$start) === false || strpos($haystack,$end) === false) {
                return 
    false;
            } else {
                
    $start_position strpos($haystack,$start)+strlen($start);
                
    $end_position strpos($haystack,$end);
                return 
    substr($haystack,$start_position,$end_position-$start_position);
            }
        }

    split_tag($content"<!-- Message -->""<!-- / Message -->"); 
    it will then return

    Code:
    <div id="post_message_126767">
                      
    
    
                      Well I was writing a Spider to crawl forums and Mirror them and Needed a way to login to a vBulletin based forum. vBulletin does not Allow a cURL Post unless the URL Has been added to the &quot;allow post from&quot; list in the Admin Control Panel.<br />
    <br />
    Using cURL However we can set an Option that will... 
    This libabry is available from hxxp://curl.haxx.se/</div>
    Then use striptags() on that and you got the full post body.

    Then the post has been stolen. Alot of Warez Boards use this technique to leech posts automatically.

  9. #8
    Jordan Guest

    Re: Logging into vBulletin using cURL

    Why do you not use regular expressions to find all the data between to tags? It would reduce all of that code above (9 lines) to 1.

  10. #9
    Affix is offline Learning Programmer
    Join Date
    Feb 2009
    Location
    Scotland
    Posts
    47
    Blog Entries
    2
    Rep Power
    12

    Re: Logging into vBulletin using cURL

    Plain and simple..

    .. I suck at regex lmao

  11. #10
    Join Date
    Sep 2008
    Location
    Australia
    Posts
    4,834
    Blog Entries
    10
    Rep Power
    51

    Re: Logging into vBulletin using cURL

    Hmmm, I think I need to learn about Regular Expressions......

    You could learn, I use to Google everything when I started HTML. But now, it's like my second language. Just takes time. Maybe VB did this for a reason :S
    jQuery Selectors Tutorial - jQuery Striped Table tutorial - jQuery Events - jQuery Validation
    Sorry if I don't post as often as I did, I'll try to get here as much as possible! I'm working my bum off to get this scholarship and other stuff!

+ Reply to Thread
Page 1 of 3 123 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Logging and handlers
    By denarced in forum Python
    Replies: 0
    Last Post: 05-05-2011, 10:18 PM
  2. How to redirect a page after logging in?
    By hudbarnett in forum PHP Development
    Replies: 4
    Last Post: 09-07-2010, 06:53 AM
  3. C# - Need Help in code for logging
    By JDomo in forum C# Programming
    Replies: 3
    Last Post: 01-22-2010, 01:50 AM
  4. logging username
    By dandoe in forum ionFiles
    Replies: 1
    Last Post: 06-29-2009, 07:07 PM
  5. Logging ?
    By Victor in forum Java Help
    Replies: 5
    Last Post: 07-22-2008, 01:30 PM

Tags for this Thread

Bookmarks

Posting Permissions

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