Search code examples
netcatnmap

nmap/netcat differentiate between open port with no service listening and open ports with a service listening


I'm pretty new with networks scanning and test tools (nmap and netcat). I want to know how to differentiate :

  • if a port is opened in a host with a service listening on this port
  • If a port is opened and in host without no service listening on this port

How to differentiate these two situations on results of nmap and/or nc commands ?

Thanks


Solution

  • If the service is not listening you'll get a connection refused message.

    Example

    # no service listening
    $ nc -vz 127.0.0.1 22
    Ncat: Version 7.80 ( https://nmap.org/ncat )
    Ncat: Connection refused.
    
    # service listening
    $ nc -vz 127.0.0.53 53
    Ncat: Version 7.80 ( https://nmap.org/ncat )
    Ncat: Connected to 127.0.0.53:53.
    Ncat: 0 bytes sent, 0 bytes received in 0.03 seconds.