#!/usr/bin/perl 
#Tool para ver las vhosts que tiene un webserver
#Coded by Sha0   badchecksum.tk

use IO::Socket;
use LWP;
require HTTP::Headers;
require LWP::UserAgent;


die "USO: ./vhosts.pl <dominio>  por ej   ./vhosts.pl  microsoft.com" if ($#ARGV != 0);

my $victima = $ARGV[0];
my $url; 
my $content = '';
my $posicion=0;

my $ua = LWP::UserAgent->new;
$ua->agent("Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)");
$ua->timeout(10);
$ua->max_size(60000);


while (1) {
	
	$url="http://www.google.es/search?num=100&hl=es&lr=&as_qdr=all&start=$posicion&sa=N&q=site:$victima";
	my $req = HTTP::Request->new(GET => $url);
	$req->content_type('application/x-www-form-urlencoded');
	my $response = $ua->request($req);
	sleep 1;
	$content .= $response->content();
	$posicion+=100;
	last if ($content =~ /nav_last\.gif/);
	last if ($content !=~ /nav_/);


}

my @urls = $content =~ /[a-z|A-Z|0-9|-|_]+\.$victima/g;



my @vhosts = sort(@urls);
my $prev = '';
foreach $i (@vhosts) {
	print `host $i ` if ($i ne $prev);
	$prev=$i;
}



