Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

252
Visualizações
How do I grep this nmap scan?

I'm using nmap to scan for SSH enabled servers. This is what nmap outputs from the scan:

SSH disabled server example:

Nmap scan report for 70.0.0.109.rev.sfr.net (109.0.0.70)
Host is up (0.15s latency).
PORT   STATE  SERVICE
22/tcp closed ssh

SSH Enabled server example:

Nmap scan report for 255.0.0.109.rev.sfr.net (109.0.0.255)
Host is up (0.12s latency).
PORT   STATE    SERVICE
22/tcp filtered ssh

I want to use grep to export all of the SSH enabled servers into a file. The file will only contain the IP addresses of the SSH enabled servers.

For example:

1.1.1.1
2.2.2.2
3.3.3.3
4.4.4.4
5.5.5.5

I couldn't find the grep command that will do this. I just need to export the SSH enabled IP addresses to a file using grep (or any other Linux command for that matter). Thanks, all help is appreciated. (By the way, I'm reading this nmap scan from a file)

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

First, you probably want to spend some time with the nmap man page, which will show you useful options like the -oG option, which produces "greppable output". For example, when run on my home network, like this:

$ nmap -p 22 -oG - 192.168.1.0/24

I get output like this:

Host: 192.168.1.1 (gw.house)    Status: Up
Host: 192.168.1.1 (gw.house)    Ports: 22/closed/tcp//ssh///
Host: 192.168.1.3 ()    Status: Up
Host: 192.168.1.3 ()    Ports: 22/closed/tcp//ssh///
Host: 192.168.1.20 (fileserver.house)   Status: Up
Host: 192.168.1.20 (fileserver.house)   Ports: 22/open/tcp//ssh///
Host: 192.168.1.29 ()   Status: Up
Host: 192.168.1.29 ()   Ports: 22/closed/tcp//ssh///
Host: 192.168.1.52 (laptop.house)   Status: Up
Host: 192.168.1.52 (laptop.house)   Ports: 22/open/tcp//ssh///

If I want a list of ip addresses with port 22 open, I can just run:

$ nmap -p 22 -oG - 192.168.1.24 | grep 22/open

Which would get me:

Host: 192.168.1.20 (arcadia.house)  Ports: 22/open/tcp//ssh///
Host: 192.168.1.52 (lkellogg-pk115wp.house) Ports: 22/open/tcp//ssh///

And if I wanted just the ip address, I would use awk:

$ nmap -p 22 -oG - 192.168.1.24 | awk '/22\/open/ {print $2}'

Which would get me:

192.168.1.20
192.168.1.52

...which is I think what you are looking for.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda