Nmap grepping结果

时间:2014-04-18 18:11:46

标签: tcp awk grep nmap port-scanning

$ ./nmap-banners -sV -vvvvv localhost |grep Banners

输出是:

Banner on 127.0.0.1:22/tcp matches ssh: SSH-2.0-OpenSSH_4.3p2 Debian-5ubuntu1.

Banner on 127.0.0.1:25/tcp matches smtp: 220 localhost ESMTP Exim 4.62 Wed, 14 Nov 2007 21:06:10

问题是我如何使用grep或awk只用SSH-2.0-OpenSSH_4.3p2 Debian-5ubuntu1打印IP地址

2 个答案:

答案 0 :(得分:0)

$ cat file
Banner on 127.0.0.1:22/tcp matches ssh: SSH-2.0-OpenSSH_4.3p2 Debian-5ubuntu1.

Banner on 127.0.0.1:25/tcp matches smtp: 220 localhost ESMTP Exim 4.62 Wed, 14 Nov 2007 21:06:10

$ awk -F'[ :]' '/SSH-2.0-OpenSSH_4.3p2/{print $3}' file
127.0.0.1

答案 1 :(得分:0)

如果您要查找包含字符串BannerSSH-2.0-OpenSSH_4.3p2 Debian-5ubuntu1的行,那么您也可以使用grep和cut。

带切割的Grep版

nmap-banners -sV -vvvvv localhost|
grep 'Banner.*SSH-2.0-OpenSSH_4.3p2 Debian-5ubuntu1'|
cut -d" " -f3|
cut -d":" -f1