Perl Reverse-DNS Script

Here's a quick and nasty hack/script to detect IPs in STDIN and find their reverse DNS. Complete with echo off.

Win.


#!/usr/bin/perl -w
#Code by Rhett Kipps - www.kipps.com.au
use strict;

my $stty_orig = `stty -g`;
`stty -echo`;
my $hostname;
while (<STDIN>) {
  if (/([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})/) {
    $hostname = `host $1`;
    $hostname =~ s/.+?domain name pointer //;
    print $hostname;
  }
}

`stty $stty_orig`;