Saltar al contenido
Underc0de /foro

[Perl] Scan Port 0.6

Iniciado por BigBear, Mayo 19, 2012, 12:27:20 PM

Tema anterior - Siguiente tema

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

Avatar de BigBear
Mayo 19, 2012, 12:27:20 PM Ultima modificación: Marzo 14, 2015, 10:21:13 AM por Expermicid
Un simple scanner port hecho en Perl.

Código: perl

#!usr/bin/perl
#ScanPort 0.6
#Coded By Doddy H
#Examples
#perl scan.pl -target localhost -option fast
#perl scan.pl -target localhost -option full -parameters 1-100

use IO::Socket;
use Getopt::Long;

GetOptions(
    "-target=s"     => \$target,
    "-option=s"     => \$opcion,
    "-parameters=s" => \$parameters
);

head();
unless ($target) {
    sintax();
}
else {
    if ( $opcion eq "fast" ) {
        scanuno($target);
    }
    if ( $opcion eq "full" and $parameters ) {
        if ( $parameters =~ /(.*)-(.*)/ ) {
            my $start = $1;
            my $end   = $2;
            scandos( $target, $start, $end );
        }
    }
}

copyright();

sub scanuno {

    my %ports = (
        "21"   => "ftp",
        "22"   => "ssh",
        "25"   => "smtp",
        "80"   => "http",
        "110"  => "pop3",
        "3306" => "mysql"
    );

    print "\n[+] Scanning $_[0]\n\n\n";

    for my $port ( keys %ports ) {

        if (
            new IO::Socket::INET(
                PeerAddr => $_[0],
                PeerPort => $port,
                Proto    => "tcp",
                Timeout  => 0.5
            )
          )
        {
            print "[+] Port Found : "
              . $port
              . " [Service] : "
              . $ports{$port} . "\n";
        }
    }
    print "\n\n[+] Scan Finished\n";
}

sub scandos {

    print "\n[+] Scanning $_[0]\n\n\n";

    for my $port ( $_[1] .. $_[2] ) {

        if (
            new IO::Socket::INET(
                PeerAddr => $_[0],
                PeerPort => $port,
                Proto    => "tcp",
                Timeout  => 0.5
            )
          )
        {
            print "[+] Port Found : $port\n";
        }
    }
    print "\n\n[+] Scan Finished\n";
}

sub head {
    print "\n-- == ScanPort 0.6 == --\n\n";
}

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

sub sintax {
    print
"\n[+] sintax : $0 -target <target> -option fast/full -parameters <1-9999>\n";
}

# The End ?

WhatsApp Telegram

¿Te quedó una duda sobre Perl?

Preguntala y te responde la comunidad (y el asistente Underc0de IA si nadie llega antes). Es gratis y tarda un minuto.

Ya tengo cuenta
Guardamos tu pregunta en este navegador: después de entrar la publicás con un clic.
Grupo de WhatsApp