x2Fusion

PHP ASN to Ranges with Info, to Serialized Array

Oct 19th, 2015
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Get CIDRs from Robtex, per ASN
  4.  */
  5. $output = array();
  6. #400000
  7. for($i = 0; $i<=400000; $i++)
  8. {
  9.     $data = @file_get_contents('https://www.robtex.com/as/as'.$i.'.html');
  10.    
  11.     preg_match('/<title>(.*)<\/title>/', $data, $ASN_title);
  12.     preg_match_all('/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}\/[0-9]{2}/', $data, $ASN_ranges);
  13.    
  14.     if(count($ASN_title)<1)
  15.     {
  16.         continue;
  17.     }
  18.    
  19.     foreach($ASN_ranges[0] as $range)
  20.     {
  21.         $return[$ASN_title[1]][] = $range;
  22.     }
  23.     $output[] = $return;
  24.     unset($return);
  25. }
  26.  
  27. file_put_contents('output.txt', serialize($output));
Advertisement
Add Comment
Please, Sign In to add comment