Underc0de

Programación Scripting => Perl => Mensaje iniciado por: BigBear en Agosto 19, 2011, 11:29:14 PM

Título: [Perl] LocateIP
Publicado por: BigBear en Agosto 19, 2011, 11:29:14 PM
Un simple script para conocer el origen de una ip mediante el servicio de una web

La web que uso para el script es http://www.melissadata.com/lookups/iplocation.asp

Código (perl) [Seleccionar]

#!usr/bin/perl
#LocateIP (C) Doddy Hackman 2011

use LWP::UserAgent;
use IO::Socket;

my $nave = LWP::UserAgent->new();
$nave->timeout(5);
$nave->agent("Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.1.12) Gecko/20080201Firefox/2.0.0.12");


head();
if($ARGV[0]) {
start($ARGV[0]);
} else {
sintax();
}
copyright();

sub start {
print "\n[+] Target :  $_[0]\n";
infocon(get_ip($_[0]));

}

sub sintax {
print "\n[+] sintax : $0 <web>\n";
}

sub head {
print q(



@      @@@@    @@@@    @    @@@@@  @@@@@     @  @@@@@
@     @    @  @    @   @      @    @         @  @    @
@     @    @  @       @ @     @    @         @  @    @
@     @    @  @       @ @     @    @         @  @    @
@     @    @  @      @   @    @    @@@@      @  @@@@@
@     @    @  @      @   @    @    @         @  @     
@     @    @  @      @@@@@    @    @         @  @     
@     @    @  @    @@     @   @    @         @  @     
@@@@@  @@@@    @@@@ @     @   @    @@@@@     @  @     



);
}

sub copyright {
print "\n\n== --(C) Doddy Hackman 2011 -- ==\n\n";
exit(1);
}

sub get_ip {
my $get = gethostbyname($_[0]);
return inet_ntoa($get);
}

sub infocon {
my $target = shift;
print "\n\n[+] Getting info\n\n\n";
$total = "http://www.melissadata.com/lookups/iplocation.asp?ipaddress=$target";
$re = toma($total);

if ($re=~/City<\/td><td align=(.*)><b>(.*)<\/b><\/td>/) {
print "[+] City : $2\n";
} else {
print "[-] Not Found\n";
copyright();
}
if ($re=~/Country<\/td><td align=(.*)><b>(.*)<\/b><\/td>/) {
print "[+] Country : $2\n";
}
if ($re=~/State or Region<\/td><td align=(.*)><b>(.*)<\/b><\/td>/) {
print "[+] State or Region : $2\n";
}
}

sub toma {
return $nave->get($_[0])->content;
}

# ¿ The End ?