nerdexam
EC-Council

312-50V10 · Question #313

What is the outcome of the comm"nc -l -p 2222 | nc 10.1.0.43 1234"?

The correct answer is B. Netcat will listen on port 2222 and output anything received to a remote connection on 10.1.0.43. This netcat command creates a simple relay: anything received on the local listening port 2222 is piped directly to a remote host at 10.1.0.43 on port 1234.

Scanning Networks

Question

What is the outcome of the comm"nc -l -p 2222 | nc 10.1.0.43 1234"?

Options

  • ANetcat will listen on the 10.1.0.43 interface for 1234 seconds on port 2222.
  • BNetcat will listen on port 2222 and output anything received to a remote connection on 10.1.0.43
  • CNetcat will listen for a connection from 10.1.0.43 on port 1234 and output anything received to
  • DNetcat will listen on port 2222 and then output anything received to local interface 10.1.0.43.

How the community answered

(41 responses)
  • A
    5% (2)
  • B
    80% (33)
  • C
    12% (5)
  • D
    2% (1)

Why each option

This netcat command creates a simple relay: anything received on the local listening port 2222 is piped directly to a remote host at 10.1.0.43 on port 1234.

ANetcat will listen on the 10.1.0.43 interface for 1234 seconds on port 2222.

Netcat does not interpret an IP address as a network interface binding in this syntax, and port numbers are not used as durations in seconds.

BNetcat will listen on port 2222 and output anything received to a remote connection on 10.1.0.43Correct

The '-l -p 2222' flags cause netcat to listen for an inbound connection on port 2222, and the pipe character '|' redirects all data received on that listener to the second netcat process. The second 'nc 10.1.0.43 1234' acts as a client, initiating an outbound connection to 10.1.0.43 on port 1234 and forwarding the piped data to it. This effectively creates a unidirectional TCP relay between two endpoints.

CNetcat will listen for a connection from 10.1.0.43 on port 1234 and output anything received to

The '-l -p 2222' flag makes netcat listen on the local machine's port 2222, not wait for a connection originating specifically from 10.1.0.43.

DNetcat will listen on port 2222 and then output anything received to local interface 10.1.0.43.

10.1.0.43 in this command is a remote destination host for the second netcat process, not a local interface address; the output goes to a remote connection, not the local interface.

Concept tested: Netcat piped relay for traffic forwarding

Source: https://linux.die.net/man/1/nc

Topics

#Netcat#traffic relay#port piping#command syntax

Community Discussion

No community discussion yet for this question.

Full 312-50V10 Practice