GCIH · Question #263
You run the following bash script in Linux: for i in 'cat hostlist.txt' ;do nc -q 2 -v $i 80 < request.txt done Where, hostlist.txt file contains the list of IP addresses and request.txt is the…
The correct answer is B. You want to perform banner grabbing to the hosts given in the IP address list. The script uses netcat (nc) to connect to port 80 on each host in the list and sends an HTTP request, retrieving the server's response headers - a classic banner grabbing technique. Banner grabbing extracts service version and software information from server responses.
Question
You run the following bash script in Linux:
for i in 'cat hostlist.txt' ;do nc -q 2 -v $i 80 < request.txt done Where, hostlist.txt file contains the list of IP addresses and request.txt is the output file. Which of the following tasks do you want to perform by running this script?
Options
- AYou want to put nmap in the listen mode to the hosts given in the IP address list.
- BYou want to perform banner grabbing to the hosts given in the IP address list.
- CYou want to perform port scanning to the hosts given in the IP address list.
- DYou want to transfer file hostlist.txt to the hosts given in the IP address list.
How the community answered
(14 responses)- B86% (12)
- C7% (1)
- D7% (1)
Why each option
The script uses netcat (nc) to connect to port 80 on each host in the list and sends an HTTP request, retrieving the server's response headers - a classic banner grabbing technique. Banner grabbing extracts service version and software information from server responses.
Nmap listen mode (-l) is not invoked here; the script uses netcat to initiate outbound connections, not to place any tool in listening mode.
Netcat with the -v (verbose) flag connects to each host on port 80 and sends the contents of request.txt (an HTTP request), causing the server to respond with its HTTP headers including the Server banner that reveals web server type and version. This is the standard method for manual HTTP banner grabbing, gathering information about the target service without exploitation. The -q 2 flag tells netcat to wait 2 seconds after EOF before closing, allowing time to receive the full server response.
Port scanning enumerates open ports across a range, whereas this script specifically connects to a fixed port (80) and sends an HTTP request to retrieve service information.
The script reads from request.txt and sends it to remote hosts rather than transferring hostlist.txt itself; file transfer would require a different netcat syntax.
Concept tested: HTTP banner grabbing using netcat
Source: https://csrc.nist.gov/publications/detail/sp/800-115/final
Topics
Community Discussion
No community discussion yet for this question.