All pastes #80191 Raw Edit

Untitled

public text v1 · immutable
·published 2006-07-06 04:48 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, $i );
my $options  = { i => \$ip, o => \$output };
my $nextPage = 1;
my $currPage = 1;
GetOptions( $options, "i=s", "o:s" );

&usage unless $ip;

if ( !$output ) {
    $output = "reverse.html";
}

do {

    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?pi=$currPage&ob=SLD&oo=ASC");

        if ( $data->is_success ) {
            my $html    = $data->content;
            my @matches = $html =~ /whois.webhosting.info\/(.*)\."/g;

            if ( !@matches && $currPage != 1 ) {
                if ( $html =~ /The IP Address entered by you is InValid !!/ ) {
                    print "no no.. we need a REAL ip\n";
                }
                
                if ( $html =~ /N\/A/ && $currPage > 1 ) {
                    print "no domains are hosted on this ip\n";
                }
                
                if ( $html =~ /The security key helps us prevent automated searches. This is not your password./ ) {
                    print "they're asking for captcha, go open your browser and type it in\n";
                }
                
                $nextPage = 0;
            }
            
            else {
                open( FILE, ">>$output" );
                foreach my $parse (@matches) {
                    if (@matches) {
                        $parse = lc($parse);
                        print FILE "<a href=http://$parse/>$parse</a><br>\n";
                    }
                }
            }
        }
    }
    
    else {
        print "enter a IP, that means 4 octets numbers only..\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?pi=$currPage&ob=SLD&oo=ASC");
    my $html    = $data->content;
    if ( $html =~ /ASC">Next/ ) {
        $currPage++;
    }

} while ( $nextPage == 1 );

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;
}