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

PHP proxy checker

Discussion in 'Other Languages' started by ignas2526, Jul 20, 2010.

  1. ignas2526

    ignas2526 Newbie

    Joined:
    Jul 7, 2010
    Messages:
    2
    Likes Received:
    6
    Yesterday I made successful spam attack on one website, over 3000 posts, I even somehow managed to corrupt database o_O.
    In attack I used list of proxies, and without BHW I would never collect enough proxies, so I decided to post script I used to check proxies for attack as a thank.
    This script can check whatever amount proxies you want at the same time using Curl library in PHP. Script will fail on some working proxies, however, it will make sure what proxies will 100% work in future with Curl.
    I assume what you have basic idea of what is PHP and how it works.
    Here is source of all files required for proxy checking:
    proxylst.txt -- contains list of proxies to check, for example:
    Code:
    109.121.136.11:8000
    109.230.209.186:8080
    
    website.php:
    Code:
    <?php
    $website='';
    $ch=curl_init();
    curl_setopt($ch,CURLOPT_URL,$website);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    $content=curl_exec($ch);
    curl_close($ch);
    echo $proxy.'<br>MD5: '.md5($content).'<br>website: '.$website.'<br>Content:'.$content;
    ?>
    proxy_checker.php:
    Code:
    <?php
    set_time_limit(0);
    $md5='';
    $website='';
    if($_GET['l']==$_GET['s']){die;}
    $list=file('proxylst.txt');
    $wlist=array();
    for($i=$_GET['s'];$i<$_GET['s']+5;$i++){
      if(isset($list[$i])){
      $ch=curl_init();
      curl_setopt($ch,CURLOPT_URL,$website);
      curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
      curl_setopt($ch,CURLOPT_HTTPPROXYTUNNEL,1);
      curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,8);
      curl_setopt($ch,CURLOPT_PROXY,$list[$i]);
      $content=curl_exec($ch);
      curl_close($ch);
      if(md5($content)==$md5){$wlist[]=$list[$i];}
      }
    }
    if(count($wlist)){
      $fh=fopen('proxys\p-'.$_GET['s'].'-'.($_GET['s']+5).'.php','w');
      fwrite($fh,implode('',$wlist));
      fclose($fh);
    }
    echo ($_GET['s']+5).'/'.$_GET['l'].'<script>parent.r("'.$_GET['f'].'","'.($_GET['s']+5).'","'.$_GET['l'].'");</script>';
    ?>
    proxy_checker.html:
    Code:
    <html>
      <head>
        <title>Proxy Checker</title>
        <script>
        function r(f,s,l){
            var iframe=document.getElementById(f);
            if(iframe){iframe.src='proxy_checker.php?s='+s+'&f='+f+'&l='+l;}
          }
            function c(){
            var i=0;
            for(i=0;i<9;i++){
            var iframe=document.getElementById('f'+i);
            if(iframe){iframe.src=iframe.src;}
            }
            setTimeout('c()',120000);
          }c();
          </script>
      </head>
      <body>
        <iframe id="f0" width="70" height="50" src="proxy_checker.php?s=0&f=f0&l=100"/></iframe>
        <iframe id="f1" width="70" height="50" src="proxy_checker.php?s=100&f=f1&l=200"/></iframe>
        <iframe id="f2" width="70" height="50" src="proxy_checker.php?s=200&f=f2&l=300"/></iframe>
        <iframe id="f3" width="70" height="50" src="proxy_checker.php?s=300&f=f3&l=400"/></iframe>
        <iframe id="f4" width="70" height="50" src="proxy_checker.php?s=400&f=f4&l=500"/></iframe>
        <iframe id="f5" width="70" height="50" src="proxy_checker.php?s=500&f=f5&l=600"/></iframe>
        <iframe id="f6" width="70" height="50" src="proxy_checker.php?s=600&f=f6&l=700"/></iframe>
        <iframe id="f7" width="70" height="50" src="proxy_checker.php?s=700&f=f7&l=800"/></iframe>
        <iframe id="f8" width="70" height="50" src="proxy_checker.php?s=800&f=f8&l=900"/></iframe>
      </body>
    </html>
    proxy_list_generator.php:
    Code:
    <?php
    $proxys=array();
    if($h=opendir('proxys')){
      while(false!==($file=readdir($h))){
        if($file!='.'&&$file!='..'){
          $l=file('proxys\\'.$file);
          foreach($l as $v){$proxys[]='\''.$v.'\'';}
        }
      }
    }
    $c='<?php $proxys=array('."\r\n".implode(','."\r\n",$proxys)."\r\n".'); ?>';
    $fh=fopen('proxys.php','w');
    fwrite($fh,$c);
    fclose($fh);
    ?>
    All scripts must be in same directory.
    How it works:
    1. In website.php set $website to a website what will be used to check proxies, note what website must always return same content. If everything works, you will get URL of the website, MD5 of its content and content itself.
    2. In proxy_checker.php set $website to website you just used in website.php and $md5 to MD5 hash you got from executing website.php. That MD5 will be used to make sure what proxy returns exactly same content as expected.
    3. In same directory create folder "proxys" it will be used to temporally store working proxies.
    4. proxy_checker.html currently set to check up to 900 proxies in total, 9 proxies at the same time. here is all get variables of proxy_checker.php:
    Code:
    proxy_checker.php?s=(row number to start)&f=(frame id)&l=(row number to finish).
    5. After proxy checker is done, use proxy_list_generator.php to generate from all files in proxys folder one list. proxy_list_generator.php will create file proxys.php who will look like this:
    Code:
    <?php $proxys=array(
    '210.15.255.245:31337',
    '210.82.57.79:8080',
    '213.26.255.134:3128'
    ); ?>
    Here is basic example of using random proxy from list:
    Code:
    include 'proxys.php';
    $proxy=$proxys[rand(0,count($proxys)-1)];
    $ch=curl_init();
    curl_setopt($ch,CURLOPT_URL,'website');
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch,CURLOPT_HTTPPROXYTUNNEL,1);
    curl_setopt($ch,CURLOPT_PROXY,$proxy);
    $content=curl_exec($ch);
    curl_close($ch);
    I don't really care about that code, so do with it whatever you want.
    THANK YOU BHW COMMUNITY!
     
    • Thanks Thanks x 6
  2. ron.ray

    ron.ray Jr. VIP Jr. VIP Premium Member

    Joined:
    May 24, 2010
    Messages:
    878
    Likes Received:
    401
    Home Page:
    that looks very useful, Thanks !!!

    one question though - after running the proxy_checker.html , i need to go to proxy_list_generator.php ? if not the result files would not be written ?

    Great share for a first post , keep on posting useful stuff !:30:
     
  3. ignas2526

    ignas2526 Newbie

    Joined:
    Jul 7, 2010
    Messages:
    2
    Likes Received:
    6
    proxy_checker.html checks if proxies work, after its done run proxy_list_generator.php once and you will have 'proxys.php' file in the same folder which will contain working proxies.
    By the way, yesterday using PHP and cURL I was able to not only flood the forum, but also knock the server down for a couple hours, so you can really perform DDOS attacks using PHP, cURL and bunch of proxies.
     
  4. R3vproxy

    R3vproxy Newbie

    Joined:
    Sep 21, 2011
    Messages:
    17
    Likes Received:
    0
    thanks.. something very usefull
     
  5. thailand

    thailand Newbie

    Joined:
    Sep 13, 2011
    Messages:
    13
    Likes Received:
    0
    This might come in handy for those that steal my creative :p
     
  6. captchaman

    captchaman Junior Member

    Joined:
    Sep 16, 2010
    Messages:
    190
    Likes Received:
    842
    Occupation:
    Software Programmer
    Location:
    USA
    "The forum" referring to Blackhatworld?