Reconnaissance and Enumeration

A tester has Nmap grepable output in scan.gnmap and needs a unique list of IP addresses with TCP 445 open for the next script. Which Bash pipeline produces it?

Show the answer

Correct answerD. grep '445/open' scan.gnmap | awk '{print $2}' | sort -u

AWhy not this: This selects hosts where 445 is closed, the opposite of what is needed.

BWhy not this: The -v flag inverts the match and returns hosts that do not have 445 open.

CWhy not this: Field 1 on these lines is the literal word 'Host:', so every output line would be the same.

DWhy this is right: grep keeps lines with 445 open, awk field 2 is the IP, and sort -u removes duplicates.

In grepable output each line starts 'Host: <IP>', so awk field 2 is the address; grep selects lines with 445 open and sort -u removes duplicates. Printing field 1 returns only the word 'Host:'.