[Perl Tk] Exploit DB Helper 0.5

Iniciado por BigBear, Septiembre 30, 2012, 02:37:23 PM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Version Tk de esta tool para bajar exploits desde exploit-db

Una imagen



El codigo

Código: perl

#!usr/bin/perl
#Exploit DB Helper 0.5
#Version Tk
#Coded By Doddy H

use Tk;
use Tk::Dialog;
use LWP::UserAgent;
use Cwd;

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"
);

#if ($^O eq 'MSWin32') {
#use Win32::Console;
#Win32::Console::Free();
#}

my $color_texto = "yellow";
my $color_fondo = "black";

my $newdaxz =
  MainWindow->new( -background => $color_fondo, -foreground => $color_texto );

$newdaxz->title("Exploit DB Helper 0.5");
$newdaxz->geometry("345x350+50+50");
$newdaxz->resizable( 0, 0 );

$menula = $newdaxz->Frame(
    -relief     => "sunken",
    -bd         => 1,
    -background => $color_fondo,
    -foreground => $color_texto
);
my $menulnowaxm = $menula->Menubutton(
    -text             => "Options",
    -underline        => 1,
    -background       => $color_fondo,
    -foreground       => $color_texto,
    -activebackground => $color_texto
)->pack( -side => "left" );
my $aboutnowaxm = $menula->Menubutton(
    -text             => "About",
    -underline        => 1,
    -background       => $color_fondo,
    -foreground       => $color_texto,
    -activebackground => $color_texto
)->pack( -side => "left" );
my $exitnowaxm = $menula->Menubutton(
    -text             => "Exit",
    -underline        => 1,
    -background       => $color_fondo,
    -foreground       => $color_texto,
    -activebackground => $color_texto
)->pack( -side => "left" );
$menula->pack( -side => "top", -fill => "x" );

$menulnowaxm->command(
    -label      => "Find",
    -background => $color_fondo,
    -foreground => $color_texto,
    -command    => \&findnow
);
$menulnowaxm->command(
    -label      => "Logs",
    -background => $color_fondo,
    -foreground => $color_texto,
    -command    => \&openlogs
);

$aboutnowaxm->command(
    -label      => "About",
    -background => $color_fondo,
    -foreground => $color_texto,
    -command    => \&aboutxa
);

$exitnowaxm->command(
    -label      => "Exit",
    -background => $color_fondo,
    -foreground => $color_texto,
    -command    => \&exitnow
);

$newdaxz->Label(
    -text       => "String : ",
    -font       => "Impact",
    -background => $color_fondo,
    -foreground => $color_texto
)->place( -x => 20, -y => 40 );
my $string = $newdaxz->Entry(
    -width      => 40,
    -background => $color_fondo,
    -foreground => $color_texto
)->place( -x => 75, -y => 45 );

$newdaxz->Label(
    -text       => "Exploits Found",
    -font       => "Impact",
    -background => $color_fondo,
    -foreground => $color_texto
)->place( -x => 120, -y => 80 );
my $exploits = $newdaxz->Listbox(
    -width      => 40,
    -height     => 10,
    -background => $color_fondo,
    -foreground => $color_texto
)->place( -x => 50, -y => 130 );

$newdaxz->Label(
    -text       => "Status : ",
    -font       => "Impact",
    -background => $color_fondo,
    -foreground => $color_texto
)->place( -x => 63, -y => 300 );
my $tatus = $newdaxz->Entry(
    -width      => 25,
    -background => $color_fondo,
    -foreground => $color_texto
)->place( -x => 120, -y => 305 );

MainLoop;

sub openlogs {
    my $cosa = $string->get;
    if ( -d $cosa ) {
        system("start $cosa");
    }
    else {
        $newdaxz->Dialog(
            -title            => "Error",
            -buttons          => ["OK"],
            -text             => "Error",
            -background       => $color_fondo,
            -foreground       => $color_texto,
            -activebackground => $color_texto
        )->Show();
    }
}

sub findnow {
    $exploits->delete( "0.0", "end" );
    my $cosa = $string->get;
    $tatus->configure( -text => "Searching ..." );
    my %found = buscar($cosa);
    $total = int( keys %found ) - 1;
    $tatus->configure( -text => "$total exploits found" );
    unless ( -d $cosa ) {
        mkdir( $cosa, "777" );
    }
    $tatus->configure( -text => "Downloading exploits ..." );
    for my $da ( keys %found ) {
        my $tata = $da;
        $tata =~ s/\<//;
        $tata =~ s/(\s)+$//;
        if ( download( $found{$da}, $cosa . "/" . $tata . ".txt" ) ) {
            $newdaxz->update;
            $exploits->insert( "end", $da );
        }
    }
    $tatus->configure( -text => " " );
}

sub buscar {
    for my $n ( 1 .. 666 ) {
        $newdaxz->update;
        my $code =
          toma( "http://www.exploit-db.com/search/?action=search&filter_page="
              . $n
              . "&filter_description="
              . $_[0]
              . "&filter_exploit_text=&filter_author=&filter_platform=0&filter_type=0&filter_lang_id=0&filter_port=&filter_osvdb=&filter_cve="
          );
        chomp $code;
        if ( $code =~ /No results/ig ) {
            return %busca;
        }
        %busca = getlinks($code);
    }
}

sub getlinks {

    my $test = HTML::Parser->new(
        start_h => [ \&start, "tagname,attr" ],
        text_h  => [ \&text,  "dtext" ],
    );
    $test->parse( $_[0] );

    sub start {
        my ( $a, $b ) = @_;
        my %e = %$b;
        unless ( $a ne "a" ) {
            $d = $e{href};
            $c = $a;
        }
    }

    sub text {
        my $title = shift;
        chomp $title;
        unless ( $c ne "a" ) {
            if ( $d =~ /www.exploit-db.com\/exploits\/(.*)/ ) {
                my $id  = $1;
                my $url = "http://www.exploit-db.com/download/" . $id;
                $links{$title} = $url;
            }
            $d = "";
        }
    }
    return %links;
}

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

sub repes {
    my @limpio;
    foreach $test (@_) {
        push @limpio, $test unless $repe{$test}++;
    }
    return @limpio;
}

sub download {
    if ( $nave->mirror( $_[0], $_[1] ) ) {
        if ( -f $_[1] ) {
            return true;
        }
    }
}

sub aboutxa {
    $newdaxz->Dialog(
        -title            => "About",
        -buttons          => ["OK"],
        -text             => "Coded By Doddy H",
        -background       => $color_fondo,
        -foreground       => $color_texto,
        -activebackground => $color_texto
    )->Show();
}

sub exitnow {
    exit 1;
}

#The End ?