All pastes #79179 Raw Edit

Unnamed

public text v1 · immutable
·published 2006-07-05 01:10 UTC
rendered paste body
#!/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 );
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}.*/ ) {
    my @octet = split( /./, $ip );
    if (   $octet[0] > 255
        || $octet[1] > 255
        || $octet[2] > 255
        || $octet[3] > 255 )
    {
        print "invalid ip!\n";
        exit;
    }
    $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 =~ /whois.webhosting.info\/(.*)\."/ ) {
            if ( !$output ) {
                my $file = "./reverse.html";
                open( FILE, ">$file" );
                print FILE;
            }
        }
    }
}

#$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");
sub usage {
    print "whois.webhosting.info reverse ip parser\n";
    print "usage: perl $0 -io\n\n";
    print "  -i\t\tip/domain to run a reverse ip lookup on\n";
    print "  -o\t\tfile to output the results to (default: reverse.html\n";
    exit;
}