[Perl] DH ViewBot 0.2

  • 0 Respuestas
  • 7499 Vistas

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

Desconectado BigBear

  • *
  • Underc0der
  • Mensajes: 543
  • Actividad:
    0%
  • Reputación 3
    • Ver Perfil

[Perl] DH ViewBot 0.2

  • en: Enero 16, 2015, 12:59:59 pm
Un simple script que sirve como bot para hacer visitas con las siguientes opciones :

  • Visitar una sola pagina
  • Visitar paginas en un archivo marcado de forma ordenada
  • Visitar paginas en un archivo marcado de forma aleatoria
  • Opciones para timeout y cantidad de visitas


El codigo :

Código: (perl) You are not allowed to view links. Register or Login
#!usr/bin/perl
#DH ViewBot 0.2
#(C) Doddy Hackman 2015

use Getopt::Long;
use LWP::UserAgent;
use URI::Split qw(uri_split);
use IO::Socket;

my @agents = (
'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0',
    'Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14',
'Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36',
'Mozilla/5.0 (compatible; MSIE 10.6; Windows NT 6.1; Trident/5.0; InfoPath.2; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727) 3gpp-gba UNTRUSTED/1.0',
'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.8pre) Gecko/20070928 Firefox/2.0.0.7 Navigator/9.0RC1',
    'Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US))',
'Mozilla/5.0 (Windows NT 6.0; rv:2.0) Gecko/20100101 Firefox/4.0 Opera 12.14',
'Mozilla/5.0 (Windows; U; Windows NT 6.1; tr-TR) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27'
);

GetOptions(
    "single=s"     => \$single_opt,
    "file=s"       => \$file_opt,
    "randomfile=s" => \$randomfile_opt,
    "timeout=i"    => \$timeout_opt,
    "count=i"      => \$count_opt
);

head();

if ( $single_opt or $file_opt or $randomfile_opt ) {

    my $page = $single_opt;

    my $timeout = "";

    if ( $timeout_opt eq "" ) {
        $timeout = "5";
    }
    else {
        $timeout = $timeout_opt;
    }

    my $count = "";

    if ( $count_opt eq "" ) {
        $count = "10";
    }
    else {
        $count = $count_opt;
    }

    if ( $single_opt ne "" ) {

        my $page = $single_opt;

        print "\n[+] Configuration\n";

        print "\n--------------------------------------------------";
        print "\n[+] Page : " . $page . "\n";
        print "[+] Timeout : " . $timeout . "\n";
        print "[+] Visit Count  : " . $count . "\n";
        print "--------------------------------------------------";

        visitar( $page, $timeout, $count, "single" );

    }

    elsif ( $randomfile_opt ne "" ) {

        visitar_random( $randomfile_opt, $timeout, $count );

    }
    elsif ( $file_opt ne "" ) {

        if ( $file_opt ne "" ) {

            unless ( -f $file_opt ) {
                print "\n[-] File not exist\n";
                copyright();
                exit(1);
            }

            print "\n" . toma_fecha_y_hora("Started");

            my @paginas = repes( leer_archivo($file_opt) );

            for my $page (@paginas) {

                chomp $page;

                print "\n--------------------------------------------------";
                print "\n[+] Page : " . $page . "\n";
                print "[+] Timeout : " . $timeout . "\n";
                print "[+] Visit Count : " . $count . "\n";
                print "--------------------------------------------------";

                visitar( $page, $timeout, $count, "file" );

            }

            print "\n" . toma_fecha_y_hora("Finished");

        }
        else {
            print "\n[-] Option not selected\n";
            exit(1);
        }

    }

}
else {
    print qq(
[+] Options :

-single : Page to visit
-file : File with pages to visit
-randomfile : File with pages to visit as random
-timeout : Time for visit
-count : Count to visist

);
    print
"[+] Example : perl $0 -single http://www.supertangas.com/index.php -timeout 5 -count 50\n";
}
copyright();

# Functions

sub head {
    print "\n-- == DH ViewBot 0.2 == --\n";
}

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

sub visitar_random {

    my ( $file, $timeout, $count ) = @_;

    my @paginas     = repes( leer_archivo($file) );
    my $total_bueno = "";
    my $total_malo  = "";

    print "\n" . toma_fecha_y_hora("Started");

    for ( 1 .. $count ) {
        my $target = $paginas[ rand(@paginas) ];
        chomp $target;
        print "\n--------------------------------------------------";
        print "\n[+] Page : " . $target . "\n";
        print "[+] Timeout : " . $timeout . "\n";
        print "--------------------------------------------------";

        print "\n\n[+] Getting information ...\n\n";

        print toma_banner($target) . "\n";

        my ( $status, $control ) = toma_response($target);

        if ( $control eq "1" ) {
            $total_bueno++;
        }
        else {
            $total_malo++;
        }

        print "\n[+] Visit $_ : $target : " . $status . "\n";

        sleep($timeout);

    }

    print "\n[+] Successful Visits : " . $total_bueno . "\n";

    print "\n" . toma_fecha_y_hora("Finished");

}

sub visitar {

    my ( $page, $timeout, $count, $type ) = @_;

    print "\n\n[+] Getting information ...\n\n";

    print toma_banner($page);

    if ( $type eq "single" ) {
        print "\n\n" . toma_fecha_y_hora("Started") . "\n";
    }
    else {
        print "\n\n" . "[+] Working ..." . "\n\n";
    }

    my $total_bueno = "";
    my $total_malo  = "";

    for ( 1 .. $count ) {

        sleep($timeout);

        my ( $status, $control ) = toma_response($page);

        if ( $control eq "1" ) {
            $total_bueno++;
        }
        else {
            $total_malo++;
        }

        syswrite STDOUT, "[+] Visit $_ : $page : " . $status . "\r";

    }

    syswrite STDOUT,
      "[+] Successful Visits : " . $total_bueno . "\t\t\t\t\t\t\t\t\t\t\r";

    if ( $type eq "single" ) {
        print "\n" . toma_fecha_y_hora("Finished");
    }
    else {
        print "\n" . "[+] Finished\n";
    }

}

sub toma_response {
    my $control = "";
    my $nave    = LWP::UserAgent->new();
    $nave->agent( $agents[ rand @agents ] );
    $nave->timeout(5);
    my $code = $nave->get( $_[0] );
    if ( $code->is_success ) {
        $control = "1";
    }
    else {
        $control = "0";
    }
    my $status = $code->status_line();
    return ( $status, $control );
}

sub toma_banner {
    my $resultado = "";
    my $nave      = LWP::UserAgent->new();
    $nave->agent( $agents[ rand @agents ] );
    $nave->timeout(5);
    my $code = $nave->get( $_[0] );
    $resultado = $resultado
      . "--------------------------------------------------------------------------";
    $resultado = $resultado . "\n[+] IP : " . get_ip( $_[0] );
    $resultado = $resultado . "\n[+] Date : " . $code->header('date');
    $resultado = $resultado . "\n[+] Server : " . $code->header('server');
    $resultado =
      $resultado . "\n[+] Connection : " . $code->header('connection');
    $resultado =
      $resultado . "\n[+] Content-Type : " . $code->header('content-type');

    if ( $code->header("Set-Cookie") ne "" ) {
        $resultado =
          $resultado . "\n[+] Cookie : " . $code->header("Set-Cookie");
    }
    $resultado = $resultado
      . "\n--------------------------------------------------------------------------";
    return $resultado;
}

sub get_ip {
    my ( $nomesirve1, $host, $nomesirve2, $nomesirve3, $nomesirve4 ) =
      uri_split( $_[0] );
    my $get = gethostbyname($host);
    return inet_ntoa($get);
}

sub toma_fecha_y_hora {

    my (
        $segundos, $minutos,    $hora,       $dia, $mes,
        $anio,     $nomesirve1, $nomesirve2, $nomesirve3
    ) = localtime(time);

    $anio += 1900;
    $mes++;

    return "[+] $_[0] Time : " . "$dia/$mes/$anio $hora:$minutos:$segundos\n";

}

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

sub leer_archivo {
    my @r;
    my @words;
    open( FILE, $_[0] );
    @words = <FILE>;
    close FILE;
    for (@words) {
        push( @r, $_ );
    }
    return (@r);
}

#The End ?

Un ejemplo de uso :

Código: You are not allowed to view links. Register or Login

C:\Users\Doddy\Desktop\WarFactory\Warfactory X\perl\DH ViewBot>view.pl

-- == DH ViewBot 0.2 == --

[+] Options :

-single : Page to visit
-file : File with pages to visit
-randomfile : File with pages to visit as random
-timeout : Time for visit
-count : Count to visist

[+] Example : perl C:\Users\Doddy\Desktop\WarFactory\Warfactory X\perl\DH ViewBo
t\view.pl -single http://www.supertangas.com/index.php -timeout 5 -count 50

-- == (C) Doddy Hackman 2015 == --

C:\Users\Doddy\Desktop\WarFactory\Warfactory X\perl\DH ViewBot>view.pl -single h
ttp://www.petardas.com/index.php -timeout 5 -count 5

-- == DH ViewBot 0.2 == --

[+] Configuration

--------------------------------------------------
[+] Page : http://www.petardas.com/index.php
[+] Timeout : 5
[+] Visit Count  : 5
--------------------------------------------------

[+] Getting information ...

--------------------------------------------------------------------------
[+] IP : 5.135.178.142
[+] Date : Fri, 2 Jan 2015 16:44:10 GMT
[+] Server : Apache/2.2.3 (CentOS)
[+] Connection : close
[+] Content-Type : text/html; charset=latin1
[+] Cookie : pais=AR; expires=Sat, 07-Feb-2015 16:44:10 GMT; path=/; domain=www.
petardas.com, cookieconsent=1; expires=Sat, 07-Feb-2015 16:44:10 GMT; path=/; do
main=www.petardas.com, esmovil=0; expires=Mon, 2-Jan-2015 00:17:30 GMT; path=/;
 domain=www.petardas.com
--------------------------------------------------------------------------

[+] Started Time : 2/1/2015 13:44:31

[+] Successful Visits : 5

[+] Finished Time : 2/1/2015 13:45:2

-- == (C) Doddy Hackman 2015 == --