Scanner TCP/ping

Publicado por Iberê 21/10/2006

[ Hits: 7.128 ]

Homepage: null.worldnerds.com

Download scan.pl




Script que faz varredura de portas TCP e varreduras ping. Você pode escolher as portas a serem varridas ou deixar sem argumentos para varrer todas as portas. Também exibe os serviços da porta.

100% feito por mim! :)

Forma de uso:

$ perl scan.pl

  



Esconder código-fonte

#!/usr/bin/perl

use Socket;
#use strict;            LEMBRAR DE TERMINAR DE POR MY NAS VARIAVEIS

sub banner{
   print<<EOF;
   Usage: $0 args host
   Where 'args' is:
   -p <port1,port2...> (standard is all). Ex: 80,100,1-1024
   -sP host (ping scan)
EOF
   exit;
}
sub all{
   socket(SOCK,AF_INET,SOCK_STREAM,getprotobyname('tcp'));
   print "Scanning ports on $ARGV[0]...\n\n";
   print "$saida";
   my $hr=times;
   for(my $port=1;$port<=6000;$port++){
      my $host=inet_aton($ARGV[0]) || die "Impossivel resolver host\n\n";
      $host=sockaddr_in($port,$host);
      my $serv=getservbyport($port,'tcp') || 'UNKNOW';
      connect(SOCK,$host)?print"$port\t$serv\t\ttcp\t\topened\n":"";
   }
   my $hr1=times;
   $hr1-=$hr;
   print "\nAll ports of the $ARGV[0] scanned in $hr1 seconds\n";
   close(SOCK);
}
sub just{
   socket(SOCK,AF_INET,SOCK_STREAM,getprotobyname('tcp'));
   $port=$ARGV[1];
   my @ports = split(/,/,$port);
   my $cont=0;
   for $port (@ports){
      push(@range,split(/-/,$port)) if $port=~/-/;
      $ports[$cont]="" if $port=~/-/;
      $cont++;
   }
   print "Scanning port(s) on $ARGV[2]...\n\n";
   print "$saida";
   $hr=times;
   while(@range){
      my $in=shift(@range);
      my $out=shift(@range);
      my $res=$out-$in;
      if($in<$out){
         for($in..$out){
            $host=inet_aton($ARGV[2])|| die "Impossivel resolver host\n\n";
            $host=sockaddr_in($_,$host);
            $serv=getservbyport($_,'tcp') || 'UNKNOW';
            my $tam=length($serv);
            connect(SOCK,$host)?$tam>7?print"$_\t$serv\ttcp\t\topened\n":print"$_\t$serv\t\ttcp\t\topened\n":$tam>7?$res>14?"":print"$_\t$serv\ttcp\t\tclosed\n":$res>14?"":print"$_\t$serv\t\ttcp\t\tclosed\n";
         }
      }else{
         for($out..$in){
            $host=inet_aton($ARGV[2])|| die "Impossivel resolver host\n\n";
            $host=sockaddr_in($_,$host);
            $serv=getservbyport($_,'tcp') || 'UNKNOW';
            $tam=length($serv);
            connect(SOCK,$host)?$tam>7?print"$_\t$serv\ttcp\t\topened\n":print"$_\t$serv\t\ttcp\t\topened\n":$tam>7?$res>14?"":print"$_\t$serv\ttcp\t\tclosed\n":$res>14?"":print"$_\t$serv\t\ttcp\t\tclosed\n";
         }
      }
   }
      for $port(@ports){
         next if $port eq "";
         $host=inet_aton($ARGV[2]) || die "Impossivel resolver host\n\n";
         $host=sockaddr_in($port,$host);
         $serv=getservbyport($port,'tcp') || 'UNKNOW';
         $tam=length($serv);
         connect(SOCK,$host)?$tam>7?print"$port\t$serv\ttcp\t\topened\n":print"$port\t$serv\t\ttcp\t\topened\n":$tam>7?print"$port\t$serv\ttcp\t\tclosed\n":print"$port\t$serv\t\ttcp\t\tclosed\n";
      }
      $hr1=times;
      $hr1-=$hr;
      print "\n(The ports scanned but not shown below are in state closed)" if $res>14;
      print "\nPort(s) scanned in $hr1 seconds\n";
      close(SOCK);
}
sub ping{
   use Net::Ping;
   $p=Net::Ping->new;
   $p->ping($ARGV[1])?print "host $ARGV[1] is alive\n":print "host $ARGV[1] is unreachable\n";
   $p->close;
}
our $saida = "port\tservice\t\tprotocol\tstate\n"."-"x 46 . "\n";
$ARGC=@ARGV;
if($ARGC < 1){
   &banner;
}
if($ARGV[0] eq '-p'){
   &banner if $ARGC<3;
   &just;
}elsif($ARGV[0] eq '-sP'){
   &banner if $ARGC<2;
   &ping;
}elsif($ARGC == 1){
   &all;
}

Scripts recomendados

Testando multiplos servers a ataque DoS

Zend Framework application.ini vulnerability exploit

R4$T4 Scan - Portscan básico comentado

script para encontrar verificar a vulnera bilidade RFI

Brutal Force Attack


  

Comentários

Nenhum comentário foi encontrado.


Contribuir com comentário




Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts