Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. <?php
  2.  
  3. error_reporting(E_ERROR | E_PARSE);
  4.  
  5. class worker_tcp extends Thread {
  6.     public function __construct($host, $port){
  7.         $this->host=$host;
  8.         $this->port=$port;
  9.         $this->complete = false;
  10.         //global $cc;
  11.     }
  12.  
  13.     public function run(){
  14.         global $cc;
  15.         $fp = fsockopen($this->host, $this->port, $errno, $errstr, 1);
  16.         if (!$fp) {
  17.             //echo "$errstr ($errno)\n"; // closed port
  18.         }
  19.         else {
  20.  
  21.             echo "port $this->port open on $this->host\n";
  22.             $cc += 1;
  23.         }
  24.         fclose($fp);
  25.         $this->complete = true;
  26.     }
  27.  
  28.     public function status() {
  29.         return $this->complete;
  30.     }
  31. }
  32.  
  33. global $cc;
  34. $cc = 0;
  35. $p = new Pool(2048);
  36. $tasks = array();
  37.  
  38. for($k=0;$k<1;$k++){
  39.     for($i=0;$i<256;$i++) {
  40.         $c = "0" + $k;
  41.         $ip = "89.40.$c.$i";
  42.  
  43.         array_push($tasks, new worker_tcp($ip, 80));
  44.     }
  45. }
  46.  
  47. foreach($tasks as $task){
  48.     $p->submit($task);
  49. }
  50. sleep(4);
  51. print("cc: $cc\n");
  52. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement