Guest User

[Ajuda]

a guest
May 31st, 2012
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.44 KB | None | 0 0
  1. package RandoPort;
  2.  
  3. use common::sense;
  4. use IO::Socket::INET;
  5.  
  6. sub usage{
  7.     say 'Insert a Target';
  8. }
  9.  
  10. sub new{
  11.     my $class = shift;
  12.    
  13.     my $self = {};
  14.     $self->{target} = undef;
  15.     $self->{ini} = undef;
  16.     $self->{end} = undef;
  17.     bless ($self, $class);
  18.     return $self;
  19. }
  20.  
  21. sub target{
  22.     my $self = shift;
  23.     $self->{target} = shift if @_;
  24.     return $self->{target};
  25. }
  26.  
  27. sub ini{
  28.     my $self = shift;
  29.     $self->{ini} = shift if @_;
  30.     return $self->{ini};
  31. }
  32.  
  33. sub end{
  34.     my $self = shift;
  35.     $self->{end} = shift if @_;
  36.     return $self->{end};
  37. }
  38.  
  39. sub scan{
  40.     my $target = ⌖
  41.     my $p1 = &ini || 1;
  42.     my $p2 = &end || 50000;
  43.     print "Ping in ", $target, " ", $p1, "-", $p2, "\n"; #para debug
  44.     my $out;
  45.     for ($p1..$p2){
  46.         print "ping in $_\n";
  47.         my $t = $target . ":" . $_;
  48.         my $sock = IO::Socket::INET->new($t);
  49.         if ($sock){
  50.             $out .= $_ . ' ';
  51.         }
  52.         else{
  53.             print $_, " close\n";
  54.         }
  55.     }
  56.     #print $_ foreach (@self);
  57.     return $out;
  58. }
  59.  
  60. 1;
  61.  
  62.  
  63. ######################################################################################
  64. #
  65.  
  66. #!/usr/bin/env perl
  67.  
  68. use common::sense;
  69. use RandoPort;
  70.  
  71. my $n = RandoPort->new();
  72. $n->target('www.google.com.br');
  73. $n->ini('60');
  74. $n->end('80');
  75. $n->scan;
  76.  
  77. ######################################################################################
  78. #
  79.  
  80. # sai 'Print in www.google.com.br 1-50000
  81. # ou seja, ele não esta aceitando eu indicar as portas,
  82. #esta escaneando as que estão de default
Advertisement
Add Comment
Please, Sign In to add comment