#!/usr/bin/perl -w
# a simple script to sort out the
# websites passed back to you
# when using their reverse ip
# tool to make it so it gives you
# direct links to the websites to
# make your life a little easier
#
use strict;
use LWP::UserAgent;
use HTTP::Headers;
use Getopt::Long;
my ( $ip, $data, $output, $http, $i );
my $options = { i => \$ip, o => \$output };
GetOptions( $options, "i=s", "o:s" );
&usage unless $ip;
if ( $ip =~ /[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}.*/ ) {
$http = LWP::UserAgent->new() or die;
$http->agent(
"Mozilla/5.0 (Windows; U; Windows NT 5.1; us-EN; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.1"
);
$data = $http->get("http://whois.webhosting.info/$ip");
if ( $data->is_success ) {
my $html = $data->content;
if ( $html =~ /\?pi=(.*)&ob=SLD&oo=ASC"> Last/ ) {
my @pages;
my $pages;
for ( $i = 1 ; $i < $1 ; $i++ ) {
$pages[$i] = $i;
}
foreach my $page (@pages) {
my $mdata = $http->get("http://whois.webhosting.info/$page");
my $mhtml = $mdata->content;
my @matches = $mhtml =~ /whois.webhosting.info\/(.*)\."/g;
foreach my $parse (@matches) {
print "$parse\n";
}
}
}
else {
my @matches = $html =~ /whois.webhosting.info\/(.*)\."/g;
foreach my $parse (@matches) {
print "$parse\n";
}
}
}
else {
print "error loading page";
}
}
else {
print "please insert a valid ip\n";
}
sub usage {
print "whois.webhosting.info reverse ip parser\n";
print "usage: perl $0 -io\n\n";
print " -i\t\tip to run a reverse ip lookup on\n";
print " -o\t\tfile to output the results to (default: reverse.html\n";
exit;
}