[原创]tcpportscan.pl
信息来源:邪恶八进制信息安全团队([url]www.eviloctal.com[/url])文章作者:outstand
[language=perl]#ActivePerl 5.8.8 Build 822
#C:\>cd c:\perl
#C:\Perl>perl tcpportscan.pl 209.85.165.99 21-25
#C:\Perl>perl tcpportscan.pl 222.247.169.134-254 80-81
use IO::Socket;
use Socket;
#use strict;
#$|=1;
$ARGC = @ARGV;
if ($ARGC != 2) {
print "[+]Usage: perl $0 <ip-list> <port-list>\n";
print "[+]Usage: perl $0 192.168.1.1 21-25\n";
print "[+]Usage: perl $0 192.168.1.1-255 80-81\n";
exit;
}
#my ($ip) = $ARGV[0] if ($ARGV[0] !~ /-/);
if ($ARGV[0] !~ /-/)
{
$ip= $ARGV[0] ;
($a, $b, $c,$d) = split(/\./, $ip);
$start=$d;
$end=$d;
}
if($ARGV[0] =~ /-/)
{
$ip= $ARGV[0] ;
my ($ip2list)= $ARGV[0] ;
@ip2list= split("-",$ip2list);
$startip = shift @ip2list;
$endip= shift @ip2list;
($a, $b, $c,$d) = split(/\./, $startip);
$start=$d;
$end=$endip;
}
#my ($portlist)= $ARGV[1] if ($ARGV[1] =~ /-/);
if ($ARGV[1] =~ /-/)
{
my ($portlist)= $ARGV[1];
#print $portlist;
@portlist= split("-",$portlist);
$startport=$portlist[0];
$endport=$portlist[1];
}else{
$startport=$ARGV[1];
$endport=$ARGV[1];
}
for ($start=$d;$start<=$end;$start++)
{
$host = "$a.$b.$c.$start";
print "[+]scan host:$host port: $startport to $endport ...\n";
if(open LOG, ">>$ip logfile.txt"){
print LOG"[+]scan host:$host port: $startport to $endport ...\n";
}
for ($port=$startport;$port<=$endport;$port++)
{
socket(SOCKET, PF_INET, SOCK_STREAM, getprotobyname('tcp')) or die print "[-] Unable to Resolve Host\n";
$conn=connect(SOCKET, sockaddr_in($port, inet_aton($host)));
print " [-]$host:$port";
if($conn)
{
print " open ok..........!\n";
select LOG;
print LOG"[-]$host : $port open ok..........!\n";
select STDOUT;
close $conn;
}else
{
print " unfind!\n";
}
close $conn;
}
print " scan $host end! \r\n";
}
#close SOCKET;[/language] 谢谢楼主
知道了tcp 的端口扫描的本来面目
页:
[1]
