Temp Searcher Perl

Posted on 19:02 by Xianur0

Busca Archivos temporales mediante diccionario y mediante spider:...

#!/usr/bin/perl

#Temp Searcher By Xianur0
#uxmal666@gmail.com

use LWP::UserAgent;
use Term::ANSIColor qw(:constants);

$Term::ANSIColor::AUTORESET = 1;
$ua = LWP::UserAgent->new;
my $web = $ARGV[0];
$web = shift || &uso;

sub uso { print "Uso: temsearch.pl [url]\n"; exit;}
$useragent = "Mozilla/5.0 (X11; U; Linux i686; es-ES; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15";
&tempse;
&spider();

sub tempse {
print RED "\nCargando Diccionario....\n";
my $temp;
open(TEMPS, "libs/temps.txt") || die "No existe la DB!\n";
while($temp = <TEMPS>){
chomp($temp);
my @datas = split("/", $web);
if($web =~ "http://") {
$host = $datas[2];
} else { $host = $datas[0];}
$tempurl = "http://".$host."/".$temp;
$req = HTTP::Request->new(GET => $tempurl);
$req->header('Accept' => 'text/html');
$res = $ua->request($req);
if ($res->is_success) {
print "Temp Encontrado: ".$tempurl."\n";
}
}
print RED "\nEjecutando Spider.......\n";
}

sub spider() {

my @nexo = ();
sub tags {
my($tag, %attr) = @_;
return if $tag ne 'a';
push(@nexo, values %attr);
}

$p = HTML::LinkExtor->new(\&tags);
$ua->agent($useragent);
$res = $ua->request(HTTP::Request->new(GET => $web),
sub {$p->parse($_[0])});
if(!$res->is_success) { print YELLOW "\nLa Web No Esta Respondiendo Correctamente!\n"; } else {
my $base = $res->base;
@nexo = map { $_ = url($_, $base)->abs; } @nexo;
foreach $url (@nexo) {
my @dat = split("/", $url);
if($dat[0] eq "") { $url = "http://".$host.$url;}
my @corregido = split(/\?/, $url);
$urls= $corregido[0]."~\n";
if(!$urll[$urls]) {
$urll[$urls] = $urls;
$req = HTTP::Request->new(GET => $urls);
$req->header('Accept' => 'text/html');
$res = $ua->request($req);
if ($res->is_success) {
print "Temp Encontrado: ".$urls."\n";
}
}
spider($urls);
}
}
}



El Diccionario (temps.txt):

index.php~
Settings.php~
sql.php~
sql.php.bak
sql_bak.php~
index.bak
index.php.bak
Settings.php.bak
Settings_bak.php~
db.php~
db.php.bak
db.bak
db_bak.php~

0 comentarios: