nerdexam
EC-Council

312-50V9 · Question #588

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. The netcat command sets up a UDP listener on port 55555 that serves the contents of /etc/passwd to any client that connects.

System Hacking

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

(34 responses)
  • A
    6% (2)
  • C
    91% (31)
  • D
    3% (1)

Why each option

The netcat command sets up a UDP listener on port 55555 that serves the contents of /etc/passwd to any client that connects.

Alogs the incoming connections to /etc/passwd file

The `<` operator redirects file contents as input to netcat; it does not write or append incoming connection data to the file, which would require the `>` or `>>` operators.

Bloads the /etc/passwd file to the UDP port 55555

Netcat is listening (server mode) on the port, not pushing the file to the port as a client; the phrasing 'loads to the port' misrepresents the direction of the data flow.

Cgrabs the /etc/passwd file when connected to UDP port 55555Correct

The flags break down as follows: `-l` puts netcat in listen mode, `-u` specifies UDP transport, and `-p55555` binds to port 55555. The shell redirection `< /etc/passwd` feeds the file into netcat's standard input, so when a remote client connects to UDP port 55555, netcat transmits the contents of /etc/passwd back to that client - effectively exfiltrating the password file.

Ddeletes the /etc/passwd file when connected to the UDP port 55555

Shell input redirection (`<`) reads from a file and passes it as stdin; it has no mechanism to delete the source file, which would require a separate command like `rm`.

Concept tested: Netcat UDP listener with file redirection for exfiltration

Topics

#netcat#UDP listener#file retrieval#network commands

Community Discussion

No community discussion yet for this question.

Full 312-50V9 Practice