Jump to content
bebemic

[perl]multithread port scanner

Recommended Posts

Posted
#!/usr/bin/perl -w

#author Boolean

#codingworld.ru

use IO::Socket;

use threads;

use threads::shared;

my @threads;

my $ports = 65535;

my $threads = 10;

my $last_port:shared = 1;

my $ip = '127.0.0.1';

for my $t (1..$threads) {

push @threads, threads->create(\&Scan, $t);

}

foreach my $t (@threads) {

$t->join();

}

sub Scan{

while(1){

my $port = $last_port++;

if($port > $ports){

return;

}

print "Port $port is open\n" if IO::Socket::INET->new(PeerAddr=>"$ip:$port",Proto=>'tcp',Timeout=>1);

}

}

sper sa fie de folos..se poate modifica usor

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...