Search code examples
securitytelnetnmap

What does -p- tag mean in Nmap


I am learning about Cybersecurity using TryHackMe and I have a couple of questions regarding Nmap:

  1. What does -p- mean in Nmap? For example when doing this: nmap -p- 10.10.57.197 --open

  2. What is the purpose of using it together with --open?

I just get different result when using and not using -p- and --open and I couldn't find anything on the internet (if you can share some nice docs I would be really grateful!).

Thanks!


Solution

  • -p is the option to define the port range to scan. the extra - is a shorthand way to describe the range 1-65535.

    I.E. -p- is equivalent to -p 1-65535 which is just scan all ports.

    The --open option is a filter. It filters out ports that are in any state that is not Open like closed or filtered ports. https://nmap.org/book/man-port-scanning-basics.html

    There's a good example about the --open option here: https://security.stackexchange.com/questions/227492/how-to-only-display-open-ports

    Given this, nmap -p- 10.10.57.197 --open is saying scan ports 1-65535 and only show me ports that are open.

    Please note that you can typically find what these options do by visiting the man pages for nmap or the official docs: https://nmap.org/book/port-scanning-options.html

    You can access the man page for nmap with this command:

    man nmap