What is the purpose of -oG and how can you parse its output to extract open ports?

Prepare for the Nmap and ZenMap Tests. Access flashcards and multiple choice questions, with hints and explanations for each question. Ensure success in your exam!

Multiple Choice

What is the purpose of -oG and how can you parse its output to extract open ports?

Explanation:
Greppable output designed for text processing is what -oG provides. Because the format is tailored for tools like grep, awk, and sed, you can pull out open ports by filtering for the marker that appears in the Ports section when a port is open. For example, running a scan with grepable output and filtering with grep '/open/' yields lines such as: Host: 192.168.0.5 () Ports: 22/open/tcp//ssh///, 80/open/tcp//http///. From there, extracting just the port numbers is straightforward with standard text tools, e.g. pipe to cut -d'/' -f1 to grab the number before the first slash. This makes open-port data easy to access programmatically.

Greppable output designed for text processing is what -oG provides. Because the format is tailored for tools like grep, awk, and sed, you can pull out open ports by filtering for the marker that appears in the Ports section when a port is open. For example, running a scan with grepable output and filtering with grep '/open/' yields lines such as: Host: 192.168.0.5 () Ports: 22/open/tcp//ssh///, 80/open/tcp//http///. From there, extracting just the port numbers is straightforward with standard text tools, e.g. pipe to cut -d'/' -f1 to grab the number before the first slash. This makes open-port data easy to access programmatically.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy