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

The outputs is:

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

The question is how can I print only the IP Addresses with SSH-2.0-OpenSSH_4.3p2 Debian-5ubuntu1 using grep or awk

有帮助吗?

解决方案

If you are looking for lines that contain both strings Banner and SSH-2.0-OpenSSH_4.3p2 Debian-5ubuntu1 then you can also use grep and cut.

Grep version with cut

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

其他提示

$ 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
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top