nerdexam
GIAC

GCIH · Question #641

Which of the following netcat commands will connect to tcp port 2222 on a remote system (10.0.0.1)?

The correct answer is A. C:\>nc.exe 10.0.0.1 2222. The basic netcat syntax to initiate an outbound TCP connection is 'nc <host> <port>' with no additional flags. Flags like -l and -L put netcat into listen mode instead of connect mode.

Reconnaissance, Scanning, and Enumeration

Question

Which of the following netcat commands will connect to tcp port 2222 on a remote system (10.0.0.1)?

Options

  • AC:>nc.exe 10.0.0.1 2222
  • BC:>nc.exe 10.0.0.1 -l -p 2222
  • CC:>nc.exe 10.0.0.1 -L 2222
  • DC:>nc.exe 10.0.0.1 -p 2222

How the community answered

(70 responses)
  • A
    89% (62)
  • B
    4% (3)
  • C
    6% (4)
  • D
    1% (1)

Why each option

The basic netcat syntax to initiate an outbound TCP connection is 'nc <host> <port>' with no additional flags. Flags like -l and -L put netcat into listen mode instead of connect mode.

AC:\>nc.exe 10.0.0.1 2222Correct

The command 'nc.exe 10.0.0.1 2222' uses the correct netcat client syntax - specifying the target host followed by the destination port number initiates an outbound TCP connection to port 2222 on 10.0.0.1 with no additional flags required.

BC:\>nc.exe 10.0.0.1 -l -p 2222

The -l flag places netcat in listen (server) mode, so this command would attempt to bind and listen locally rather than connect outbound to the remote host.

CC:\>nc.exe 10.0.0.1 -L 2222

The -L flag (uppercase) in some netcat variants sets a persistent listen mode, not an outbound connection mode.

DC:\>nc.exe 10.0.0.1 -p 2222

The -p flag specifies the local source port to bind to on the client side, not the destination port, so this command does not correctly specify a remote destination port.

Concept tested: Netcat client syntax for outbound TCP connections

Source: https://nmap.org/ncat/guide/ncat-man.html

Topics

#netcat#TCP connection#command-line tools#port connection

Community Discussion

No community discussion yet for this question.

Full GCIH Practice