该脚本我发现有点问题,就是当链接成功以后,不会自动断开,这个问题我一直都在想办法。。
这段时间可以好好看看。。当然,如果有哥们懂的,欢迎留言交流下。。。
#! /usr/bin/perluse threads;use IO::Socket::INET;use strict;my @openport;sub scan{ my ($host,@ports,$proto) = @_; foreach my $port (@ports){ my $socket = new IO::Socket::INET( PeerHost => $host,PeerPort => $port,Proto => $proto,); if($socket){ print $port,"is open!\n"; push(@openport,$port); $socket->close(); } }}sub thread{ my $host = shift; my @ports = (1..65535); my $length = 65535/4; my $thr0 = threads->new(\&scan,$host,@ports[1..$length],'tcp'); my $thr1 = threads->new(\&scan,@ports[$length+1..$length*2],'tcp'); my $thr2 = threads->new(\&scan,@ports[$length*2+1..$length*3],'tcp'); my $thr3 = threads->new(\&scan,@ports[$length*3+1..65535],'tcp'); $thr0->join(); $thr1->join(); $thr2->join(); $thr3->join();}thread('127.0.0.1');#scan('127.0.0.1',29,'tcp');foreach my $accessport (@openport){ print $accessport," is open!";}总结
以上是内存溢出为你收集整理的Perl 端口扫描全部内容,希望文章能够帮你解决Perl 端口扫描所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)