Skip to content

Commit

Permalink
Check validity of PTR records for each hop
Browse files Browse the repository at this point in the history
traceroute-circl now checks if the PTR record got the same
IP address than the requested one. To find any suspicious
differences between the PTR/A records set.
  • Loading branch information
adulau committed Feb 7, 2011
1 parent 7dee0dc commit a08f8ae
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion bin/traceroute-circl
Expand Up @@ -21,6 +21,7 @@
use strict;
use utf8;

use Socket;
use Getopt::Compact;

use Net::Whois::RIS;
Expand Down Expand Up @@ -105,12 +106,21 @@ while (<TRACEROUTE>) {
my $abuse = join( ' ', Net::Abuse::Utils::get_ipwi_contacts($tip) );
$r .= " Abuse contact:" . $abuse . "\n";
$ris->getIPInfo($tip);
my $ptr = GetPTR($tip);
my $ra = GetA($ptr);
my $raok = "WRONG";
if ( !defined($ra) ) { $raok = "No A record for PTR"; }
if ( $ra == $tip ) { $raok = "OK"; }
if ( !defined($ptr) ) { $raok = "N/A"; }
$r .=
" ASN (RIS):"
. $ris->getOrigin() . " "
. $ris->getDescr()
. " ASN INFO:"
. join( ' ', Net::Abuse::Utils::get_asn_info($tip) );
. join( ' ', Net::Abuse::Utils::get_asn_info($tip) ) . " PTR:"
. $ptr . " ("
. $ra . "-"
. $raok . ")";

if ( defined( $opts->{rbl} ) ) {
$r .= " RBL:"
Expand Down Expand Up @@ -143,6 +153,28 @@ if ( defined( $opts->{geomap} ) ) {

close(TRACEROUTE);

sub GetPTR {
my $ip = shift;
my $iip = inet_aton($ip);
if ( length($iip) > 1 ) {
return gethostbyaddr( $iip, AF_INET );
}
else {
return undef;
}
}

sub GetA {
my $name = shift;
my $iip = gethostbyname($name);
if ( length($iip) > 1 ) {
return inet_ntoa($iip);
}
else {
return undef;
}
}

sub GetCountryLatLng {

my $country = shift;
Expand Down

0 comments on commit a08f8ae

Please sign in to comment.