示例#1
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $oldPrefix = $this->ipPrefix;
     $ipVersion = $this->ipVersion;
     $ipWhois = new Whois($oldPrefix->ip, $oldPrefix->cidr);
     $parsedWhois = $ipWhois->parse();
     // If null, lets skip
     if (is_null($parsedWhois) === true) {
         $this->cli->br()->error('Seems that whois server returned no results for prefix');
         return;
     }
     $oldPrefix->name = $parsedWhois->name;
     $oldPrefix->description = isset($parsedWhois->description[0]) ? $parsedWhois->description[0] : null;
     $oldPrefix->description_full = json_encode($parsedWhois->description);
     $oldPrefix->counrty_code = $parsedWhois->counrty_code;
     $oldPrefix->owner_address = json_encode($parsedWhois->address);
     $oldPrefix->raw_whois = $ipWhois->raw();
     $oldPrefix->save();
     // Save Prefix Emails
     $oldPrefix->emails()->delete();
     foreach ($parsedWhois->emails as $email) {
         $className = 'App\\Models\\IPv' . $ipVersion . 'PrefixWhoisEmail';
         $prefixEmail = new $className();
         $prefixEmail->prefix_whois_id = $oldPrefix->id;
         $prefixEmail->email_address = $email;
         // Check if its an abuse email
         if (in_array($email, $parsedWhois->abuse_emails)) {
             $prefixEmail->abuse_email = true;
         }
         $prefixEmail->save();
     }
     dump(['name' => $oldPrefix->name, 'description' => $oldPrefix->description, 'description_full' => $oldPrefix->description_full, 'counrty_code' => $oldPrefix->counrty_code, 'owner_address' => $oldPrefix->owner_address]);
 }
示例#2
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $ipPrefix = $this->ipPrefix;
     $ipVersion = $this->ipVersion;
     $ipAllocation = $this->ipAllocation;
     $ipWhois = new Whois($ipPrefix->ip, $ipPrefix->cidr);
     $parsedWhois = $ipWhois->parse();
     $className = 'App\\Models\\IPv' . $ipVersion . 'PrefixWhois';
     $newPrefixWhois = new $className();
     // Skip null results
     if (is_null($parsedWhois) === true) {
         // Add them as null record
         $newPrefixWhois->ip = $ipPrefix->ip;
         $newPrefixWhois->cidr = $ipPrefix->cidr;
         $newPrefixWhois->raw_whois = $ipWhois->raw();
         $newPrefixWhois->save();
         return;
     }
     $newPrefixWhois->rir_id = $ipAllocation->rir_id;
     $newPrefixWhois->ip = $ipPrefix->ip;
     $newPrefixWhois->cidr = $ipPrefix->cidr;
     $newPrefixWhois->ip_dec_start = $this->ipUtils->ip2dec($newPrefixWhois->ip);
     if ($this->ipUtils->getInputType($newPrefixWhois->ip) === 4) {
         $ipv4Cidrs = $this->ipUtils->IPv4cidrIpCount();
         $ipCount = $ipv4Cidrs[$newPrefixWhois->cidr];
     } else {
         $ipv6Cidrs = $this->ipUtils->IPv6cidrIpCount();
         $ipCount = $ipv6Cidrs[$newPrefixWhois->cidr];
     }
     $newPrefixWhois->ip_dec_end = bcsub(bcadd($ipCount, $newPrefixWhois->ip_dec_start), 1);
     $newPrefixWhois->parent_ip = $ipAllocation->ip;
     $newPrefixWhois->parent_cidr = $ipAllocation->cidr;
     $newPrefixWhois->name = $parsedWhois->name;
     $newPrefixWhois->description = isset($parsedWhois->description[0]) ? $parsedWhois->description[0] : null;
     $newPrefixWhois->description_full = json_encode($parsedWhois->description);
     $newPrefixWhois->counrty_code = $parsedWhois->counrty_code;
     $newPrefixWhois->owner_address = json_encode($parsedWhois->address);
     $newPrefixWhois->raw_whois = $ipWhois->raw();
     $newPrefixWhois->save();
     // Save Prefix Emails
     foreach ($parsedWhois->emails as $email) {
         $className = 'App\\Models\\IPv' . $ipVersion . 'PrefixWhoisEmail';
         $prefixEmail = new $className();
         $prefixEmail->prefix_whois_id = $newPrefixWhois->id;
         $prefixEmail->email_address = $email;
         // Check if its an abuse email
         if (in_array($email, $parsedWhois->abuse_emails)) {
             $prefixEmail->abuse_email = true;
         }
         $prefixEmail->save();
     }
     dump(['name' => $newPrefixWhois->name, 'description' => $newPrefixWhois->description, 'description_full' => $newPrefixWhois->description_full, 'counrty_code' => $newPrefixWhois->counrty_code, 'owner_address' => $newPrefixWhois->owner_address]);
 }
示例#3
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $rir_id = $this->rir_id;
     $as_number = $this->as_number;
     $this->cli->br()->comment('Looking up and adding: AS' . $as_number);
     $asnWhois = new Whois($as_number);
     $parsedWhois = $asnWhois->parse();
     $asn = new ASN();
     // Skip null results
     if (is_null($parsedWhois) === true) {
         // Save the null entry
         $asn->rir_id = $rir_id;
         $asn->asn = $as_number;
         $asn->raw_whois = $asnWhois->raw();
         $asn->save();
         return;
     }
     $asn->rir_id = $rir_id;
     $asn->asn = $as_number;
     $asn->name = empty($parsedWhois->name) !== true ? $parsedWhois->name : null;
     $asn->description = isset($parsedWhois->description[0]) ? $parsedWhois->description[0] : $asn->name;
     $asn->description_full = count($parsedWhois->description) > 0 ? json_encode($parsedWhois->description) : json_encode([$asn->description]);
     // Insert PeerDB Info if we get any
     if ($peerDb = $this->peeringDBData) {
         $asn->website = $peerDb->website;
         $asn->looking_glass = $peerDb->looking_glass;
         $asn->traffic_estimation = $peerDb->info_traffic;
         $asn->traffic_ratio = $peerDb->info_ratio;
     }
     $asn->counrty_code = $parsedWhois->counrty_code;
     $asn->owner_address = json_encode($parsedWhois->address);
     $asn->raw_whois = $asnWhois->raw();
     $asn->save();
     // Save ASN Emails
     foreach ($parsedWhois->emails as $email) {
         $asnEmail = new ASNEmail();
         $asnEmail->asn_id = $asn->id;
         $asnEmail->email_address = $email;
         // Check if its an abuse email
         if (in_array($email, $parsedWhois->abuse_emails)) {
             $asnEmail->abuse_email = true;
         }
         $asnEmail->save();
     }
     $this->cli->br()->comment($asn->asn . ' - ' . $asn->description . ' [' . $asn->name . ']');
 }
示例#4
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $oldAsn = $this->oldAsn;
     $oldAsn->emails()->delete();
     $this->cli->br()->comment('Updating: AS' . $oldAsn->asn);
     $asnWhois = new Whois($oldAsn->asn);
     $parsedWhois = $asnWhois->parse();
     // Skip null results
     if (is_null($parsedWhois) === true) {
         $oldAsn->touch();
         return;
     }
     $oldAsn->name = $parsedWhois->name;
     $oldAsn->description = isset($parsedWhois->description[0]) ? $parsedWhois->description[0] : $parsedWhois->name;
     $oldAsn->description_full = count($parsedWhois->description) > 0 ? json_encode($parsedWhois->description) : json_encode([$oldAsn->description]);
     // If we have the PeerDB info lets update it.
     if ($peerDb = $this->peeringDBData) {
         $oldAsn->website = $peerDb->website;
         $oldAsn->looking_glass = $peerDb->looking_glass;
         $oldAsn->traffic_estimation = $peerDb->info_traffic;
         $oldAsn->traffic_ratio = $peerDb->info_ratio;
     }
     $oldAsn->counrty_code = $parsedWhois->counrty_code;
     $oldAsn->owner_address = json_encode($parsedWhois->address);
     $oldAsn->raw_whois = $asnWhois->raw();
     $oldAsn->save();
     // Save ASN Emails
     foreach ($parsedWhois->emails as $email) {
         $asnEmail = new ASNEmail();
         $asnEmail->asn_id = $oldAsn->id;
         $asnEmail->email_address = $email;
         // Check if its an abuse email
         if (in_array($email, $parsedWhois->abuse_emails)) {
             $asnEmail->abuse_email = true;
         }
         $asnEmail->save();
     }
 }