组合nmap和lsof lsport.pl
发表于 : 2012-03-08 10:33
以前每次nmap后,都想看下端口跑的软件名。
代码: 全选
● cat lsport.perl
#!/usr/bin/perl
$_=$ARGV[0]//"localhost";
print "端口\t\t状态\t服务\t服务名\t 端口名\n";
@_=`/usr/bin/nmap $_`;
for (@_){
chomp;
if (/^\d+/){
@s=grep /IPv.*LISTEN/, `sudo lsof -i :$&`;
@n=split /\s+/, $s[0];
@l=split /\s+/, "$_\t$n[0]\t$n[8]\n";
format STDOUT=
^<<<<<<<<<<<<<<<^<<<<<<<^<<<<<<<^<<<<<<<<<<^<<<<<<<<<<<<<<<<<
$l[0],$l[1],$l[2],$l[3],$l[4]
.
write
}
}
代码: 全选
● lsport.perl
端口 状态 服务 服务名 端口名
22/tcp open ssh sshd *:ssh
631/tcp open ipp cupsd localhost:ipp
6667/tcp open irc bitlbee *:ircd