Attacks and Exploits
Several Nmap greppable files (*.gnmap) hold lines like "Host: 10.0.0.5 () Ports: 445/open/tcp//microsoft-ds///". A tester needs one sorted, duplicate-free list of IPs with port 445 open. Which pipeline produces it?
Show the answer
Correct answerD. grep -h '445/open' *.gnmap | awk '{print $2}' | sort -u
AWhy not this: Extracts the IP first, so the later grep for 445/open finds nothing.
BWhy not this: Field five is the port string, not the host IP.
CWhy not this: Splitting on colons yields " 10.0.0.5 () Ports", not a clean IP address.
DWhy this is right: Filters open-445 lines, prints the IP field, then sorts and removes duplicates.
Filter first with grep for 445/open, then print the second whitespace-delimited field (the IP), then sort -u for a sorted unique list. Extracting the IP before grepping discards the port text, so the filter matches nothing.