312-50V11 · 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 listens on UDP port 55555 and serves the contents of /etc/passwd to any client that connects to it.
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
(38 responses)- A11% (4)
- B3% (1)
- C82% (31)
- D5% (2)
Why each option
This netcat command listens on UDP port 55555 and serves the contents of /etc/passwd to any client that connects to it.
The `<` operator redirects /etc/passwd as input to netcat, not as an output log destination; logging to a file would require `>` or `>>` redirection.
The file is not 'loaded to' the port in a storage sense; it is streamed to a connecting client as output, which is a client-pull operation not a port-storage operation.
The flags break down as follows: `-l` puts netcat into listen mode, `-u` specifies UDP transport, and `-p55555` binds to port 55555. The shell redirection `< /etc/passwd` feeds the file contents as standard input to the netcat process. When a remote client connects to UDP port 55555, netcat transmits the contents of /etc/passwd to that client, effectively allowing the connecting party to grab the file over the network.
No part of the command performs a delete operation; the file is only read as input and transmitted, leaving it untouched on disk.
Concept tested: Netcat command flags and file exfiltration over UDP
Source: https://man7.org/linux/man-pages/man1/ncat.1.html
Topics
Community Discussion
No community discussion yet for this question.