Question

$ ./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

Était-ce utile?

La solution

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 

Autres conseils

$ 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
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top