312-50V10 · Question #86
What does the following command in netcat do? nc -l -u -p55555 < /etc/passwd
The correct answer is C. grabs the /etc/passwd file when connected to UDP port 55555. This netcat command sets up a UDP listener on port 55555 and pipes /etc/passwd as input, so any client connecting to that port receives the file contents. The correct answer describes what happens from the connecting client's perspective.
Question
What does the following command in netcat do? nc -l -u -p55555 < /etc/passwd
Options
- Alogs the incoming connections to /etc/passwd file
- Bloads the /etc/passwd file to the UDP port 55555
- Cgrabs the /etc/passwd file when connected to UDP port 55555
- Ddeletes the /etc/passwd file when connected to the UDP port 55555
How the community answered
(62 responses)- A3% (2)
- B6% (4)
- C77% (48)
- D13% (8)
Why each option
This netcat command sets up a UDP listener on port 55555 and pipes /etc/passwd as input, so any client connecting to that port receives the file contents. The correct answer describes what happens from the connecting client's perspective.
The redirection operator '<' feeds /etc/passwd as input to netcat, it does not write output to the file - logging would require the '>' or '>>' operators.
The file is not statically loaded to the port at bind time - it is streamed to a client only when an active connection is established to that port.
The flags -l (listen), -u (UDP), and -p55555 (bind to port 55555) create a UDP server, and the input redirection '< /etc/passwd' causes netcat to feed the file contents into the connection - meaning a connecting client receives (grabs) the /etc/passwd file data.
There is no delete operation in this command - netcat is only reading and transmitting the file contents, leaving the file on disk untouched.
Concept tested: Netcat UDP listener with file redirection
Topics
Community Discussion
No community discussion yet for this question.