1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

cURL socks5 proxy checker class times out when handling more than 3 ip's

Discussion in 'PHP & Perl' started by grinding, Dec 6, 2009.

  1. grinding

    grinding Registered Member

    Joined:
    Oct 27, 2009
    Messages:
    62
    Likes Received:
    72
    Occupation:
    I'd rather be snorting cocaine off a hooker's ass
    Location:
    City of Angels
    Hello fellow blackhatters :)

    Trying to set up an online socks5 checker. In short, you add a list of socks5's, and the script then checks which works and which don't

    I am able to check the status of up to 3 socks correctly, but if i try to check more than 3 in the same session i get an "500 Internal server error" . Obviously it is too much to handle for the class/server.

    Anyone who has an idea on how to edit this, so you can check larger lists?

    My proxy checker class looks like this

    PHP:
    <?
    // PHP anonymity checker
    //
    //   (c) Involutive 2008 http://www.involutive.com
    //   author: Paolo Ardoino < paolo@involutive.com >
    //
    //      Usage:
    //              $anons = array(
    //                      array("ip" => "1.2.3.4", "port" => 8080, "type" => "socks4"),
    //                      array("ip" => "1.2.3.5", "port" => 8080, "type" => "socks5"),
    //                      array("ip" => "1.2.3.6", "port" => 8080, "type" => "proxy")
    //              );
    //
    //              $pa = new phpanon(array("anons" => $anons));
    //              $pa->check();
    //              $pa->done();
    //
    //              $anons is an array of triples ("ip" => ip, "port" => port, "type" => type)
    //                      ip: ip address of the socks / proxy
    //                      port: port of the socks / proxy
    //                      type: socks5 (for socks5), socks4 (for socks4), proxy (for proxy)
    //
    //              Other options:
    //                      "url" => "http://www.example.com" : connection test page
    //                      "needle" => "someword" : some word contained in the page set by "url"
    //                      "user_agent" => "Mozilla Firefox" : set an alternative user_agent
    //                      "url_referer" => "http://www.mypage.com" : set a referer url
     
     
    class phpanon {

        public 
    $anons = array();
        public 
    $opts = array("user_agent" => """url_referer" => """url" => "http://www.google.com""needle" => "groups");
     
        function 
    __construct($opts) {
     
            if(
    sizeof($opts["anons"]) > 0) {
                
    $this->anons $opts["anons"];
            }
     
            if(
    $opts["user_agent"] != "") {
                
    $this->opts["user_agent"] = $opts["user_agent"];
            }
     
            if(
    $opts["url_referer"] != "") {
                
    $this->opts["url_referer"] = $opts["url_referer"];
            }
     
        }
     
        function 
    check() {
     
            if(
    sizeof($this->anons) > 0) {
                for(
    $i 0$cnt_good 0$cnt_gad 0$y sizeof($this->anons); $i $y$i++) {
                    
    $anon = &$this->anons[$i];
                    if(
    $anon["ip"] != "" && $anon["port"] != "" && $anon["type"]) {
                        echo 
    "".$anon["ip"].":".$anon["port"]." ... ";
                        
    $ch curl_init($this->opts["url"]);
     
                        
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
                        
    curl_setopt($chCURLOPT_HEADER0);
                        
    curl_setopt($chCURLOPT_CONNECTTIMEOUT10);
                        
    curl_setopt($chCURLOPT_TIMEOUT10);
                        
    curl_setopt($chCURLOPT_FOLLOWLOCATION1);
     
                        if(
    $this->opts["user_agent"] != "") {
                            
    curl_setopt($chCURLOPT_USERAGENT$this->opts["user_agent"]);
                        }
                        if(
    $this->opts["url_referer"] != "") {
                            
    curl_setopt($chCURLOPT_REFERER$this->opts["url_referer"]);
                        }
     
                        
    curl_setopt($chCURLOPT_PROXY$anon["ip"].":".$anon["port"]);
                        if(
    $anon["type"] == "socks4"curl_setopt($chCURLOPT_PROXYTYPECURLPROXY_SOCKS4);
                        else if(
    $anon["type"] == "socks5"curl_setopt($chCURLOPT_PROXYTYPECURLPROXY_SOCKS5);
     
                        
    $html curl_exec($ch);
                        if(
    curl_errno($ch) || $html == "" || strpos($html$this->opts["needle"]) === FALSE) {
                            
    //Hvis proxy ikke virker
                            
                            
    $anon["status"] = 0;
                            
    $cnt_gad++;
                            echo 
    "not working, die\n <br>";
                        } else {
                            
                            
    // Hvis proxy virker
     
                            
    $anon["status"] = 1;
                            
    $cnt_good++;
                            echo 
    "working, insert into db\n <br>";
                        }
                        
    curl_close ($ch);
                        unset(
    $ch);
                    }
                    unset(
    $anon);

                }
            }
     
        }
    }
     
    ?>
    My checker.php script looks like this:

    PHP:
    <?php
    include("connect.php");
    require(
    "proxycheck.class.php");

    set_time_limit(0);
    $timeout 0;
    $result mysql_query("SELECT * FROM prx limit 10");
    $anons = array();


    while(
    $row mysql_fetch_array($result)) 
              {
               
    $anons[] = array ( ip=>$row['ip'], port=>$row['port'], type=>"socks5");
              }
        

    $pa = new phpanon(array("anons" => $anons));
    $pa->check();


    ?>
    Thank you in advance!
     
    • Thanks Thanks x 1
  2. Crooker

    Crooker Newbie

    Joined:
    Jun 1, 2009
    Messages:
    0
    Likes Received:
    483
    500 error is a general error catcher for internal server connection errors.
    Since your working with proxies, or anything ip related for that matter, is the reason why you get that error.
    Your script is working with the first three and then errors a logical guess is that it might be the timeout.
    Standard it is set to 30 second.
    Try;
    Code:
    ini_set('max_execution_time', 'sometime');
    or maybe
    Code:
    @set_time_limit(typesecondsinnumbershere);
    Some documentation here.
    Code:
    http://php.net/manual/en/function.ini-set.php
     
    • Thanks Thanks x 1
  3. grinding

    grinding Registered Member

    Joined:
    Oct 27, 2009
    Messages:
    62
    Likes Received:
    72
    Occupation:
    I'd rather be snorting cocaine off a hooker's ass
    Location:
    City of Angels
    Hey Crooker, thanks for you reply.

    I just tested your 2 suggestions, but am still only able to test 3 proxies successfully. If i try to test more, the page still gives me an "500 Internal error" ... hmm.

    Could it be possible to loop the proxies through the class one by one, and then return the total result when finished?
     
  4. Crooker

    Crooker Newbie

    Joined:
    Jun 1, 2009
    Messages:
    0
    Likes Received:
    483
    Sure you can convert the input into a variable.
    Then you use a foreach loop with the variable.
    Then each ip will be executing the proxy script separately.
    And at the of the loop just use the echo function to display the results and then close the loop.