312-50V13 · Question #140
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 redirects the contents of /etc/passwd as input, which will be sent to the first client that connects.
Question
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
(67 responses)- A12% (8)
- B6% (4)
- C81% (54)
- D1% (1)
Why each option
This netcat command sets up a UDP listener on port 55555 and redirects the contents of `/etc/passwd` as input, which will be sent to the first client that connects.
The command redirects the *content* of `/etc/passwd` *out* over the network to a client, not incoming connections *to* the file.
While it involves UDP port 55555, it doesn't 'load' the file to the port as if storing it; it streams its content *through* the port to a connecting client.
The `nc -l -u -p55555` part establishes netcat in listen mode, using UDP, on port 55555. The input redirection `< /etc/passwd` pipes the content of the `/etc/passwd` file into netcat's standard input, so when a remote client connects, netcat will send this file's content to them.
The command uses input redirection (`<`), which reads from the file, it does not modify or delete it.
Concept tested: Netcat input redirection and listener mode for file transfer
Source: https://linux.die.net/man/1/nc
Topics
Community Discussion
No community discussion yet for this question.