$ ./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地址
答案 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)
如果您要查找包含字符串Banner
和SSH-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