SHARE
TWEET

filter.php

wtfbbq Jul 14th, 2015 1,315 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?PHP
  2. function discover($host, $timeout = 1) {
  3.     $data = "M-SEARCH * HTTP/1.1\r\nHOST: 239.255.255.250:1900\r\nMAN: \"ssdp:discover\"\r\nMX: 3\r\nST: ssdp:all\r\n\r\n";
  4.     $socket  = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
  5.     socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array('sec' => $timeout, 'usec' => 0));
  6.     socket_connect($socket, $host, 1900);
  7.     socket_send($socket, $data, strLen($data), 0);
  8.     $buf = "";
  9.     $from = "";
  10.     $port = 0;
  11.     @socket_recvfrom($socket, $buf, 1000, 0, $from, $port);
  12.     socket_close($socket);
  13.     return $buf;
  14.     }
  15.        
  16. function partition( $list, $p ) {
  17.         $listlen = count( $list );
  18.         $partlen = floor( $listlen / $p );
  19.         $partrem = $listlen % $p;
  20.         $partition = array();
  21.         $mark = 0;
  22.         for ($px = 0; $px < $p; $px++) {
  23.                 $incr = ($px < $partrem) ? $partlen + 1 : $partlen;
  24.                 $partition[$px] = array_slice( $list, $mark, $incr );
  25.                 $mark += $incr;
  26.         }
  27.         return $partition;
  28. }
  29.  
  30. if($argc != 6) {
  31.         echo "Usage: php $argv[0] ssdplist.txt newssdplist.txt threads reply_size resolves_per_reflector\n";
  32.                 echo "SSDP Filter by Andy Quez - quezstresser.com\n";
  33.         die();
  34.         }
  35.        
  36. if (!file_exists("$argv[1]")) {
  37.         die("Invalid input file!\n");
  38.         }
  39.  
  40. $childcount = $argv[3];
  41. $ReplySize = $argv[4];
  42. $part = array();
  43. $array = file($argv[1], FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  44. $array = array_unique($array);
  45. $part = partition($array, $childcount);
  46. file_put_contents($argv[2], "");
  47.  
  48. $rpr = $argv[5];
  49.  
  50. for($i = 0; $i < $childcount; $i ++)
  51. {
  52.         $pid = pcntl_fork();
  53.         if ($pid == -1) {
  54.                 echo "Forking failed on loop $i\n";
  55.                 exit;
  56.         } else if ($pid) {
  57.                 continue;
  58.         } else {
  59.                         foreach($part[$i] as $ip)
  60.                         {
  61.                         $addr = explode(" ", $ip);
  62.                         $arl = 0;
  63.                         for ($y = 0; $y <= $rpr; $y++)
  64.                         {
  65. $content = discover($addr[0]);
  66. $arl += strlen($content);
  67. }
  68. $alen = ($arl / $rpr);
  69. if ($alen != 0) {
  70. echo "$addr[0] - Average reply: $alen\n";
  71. if ($alen > $ReplySize) {
  72.         file_put_contents($argv[2], "$addr[0] $alen\r\n", FILE_APPEND);
  73.         }
  74. } else {
  75.         echo "$addr[0] - DEAD\n";
  76.         }
  77.  
  78. }
  79. die;
  80. }
  81. }
  82. for($j = 0; $j < $childcount; $j++)
  83. {
  84.         $pid = pcntl_wait($status);
  85. }
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
 
Top