Join Malcolm Shore for an in-depth discussion in this video A Netcat refresher, part of Penetration Testing Essential Training.
- [Instructor] Netcat is often referred to as the Swiss Army knife of networking, because it has so many features and so many uses. Fundamentally, it operates as either a sender or a receiver of arbitrary data across the network. Netcat is installed by default in Kali. Let's check the IP address of my Kali system. Okay, we're 10.0.2.11. Let's use Netcat to set up a chat line across the internet.
I'll set up a Netcat listener on Kali by specifying the -l option and a port number with the -p option. Netcat is now listening for data to come in on port 4545. I'm on my Windows system, which also has Netcat installed. I can now type nc 10.0.2.11 4545 and press enter.
This establishes a raw data connection. I'll type hello universe. Back in Kali, we can see, the same text has appeared. Again if I type hi, how are you, it appears immediately on Kali. To terminate the connection, I can press control-C. The next thing I'll do with Netcat is to copy a file from one system to the other.
I've got a text file on my Kali system called myfile.txt, and I want to set up Netcat to receive the file in Windows. Firstly, I'll check my IP address. You can see the address is 10.0.2.6. Now I'll set up Netcat to listen and receive into the file incoming.txt. Now when the data is received, it will be sent, not to standard out, but instead, to a new file called incoming.txt.
To transfer the file, I type nc -w3 10.0.2.6 4545 myfile.txt. This command tells Netcat to take data from myfile.txt instead of standard in. Netcat makes the connection, takes the input and sends it through to the network, and then after three seconds, terminates.
Okay, let's have a look at what we've got. Sure enough, we have a file called incoming.txt, and it contains the text that was in myfile.txt. Netcat can also be used as a client for services on another host. For example, we can use Netcat to connect to a work server. I'll type nc -v google.com 80.
The -v switch tells Netcat to be verbose and provide me with status messages, and 80 is the standard port for accessing a website. When the connection is made, I can type the http command get index.html http/1.1 and press enter twice. And the web server will deliver its response and the web page code.
Similarly, I can connect to an ftp server. I'll type nc -v 10.0.2.8 21. This will connect to my metasploitable ftp server. And the ftp server will wait for me to log in. I'll do that. First I'll type user anonymous and press enter. And then I'll type pass firstname.lastname@example.org.
The server accepts my anonymous login. I'll type help. And I get a list of the ftp commands on the server. I can now type quit and exit. Netcat is indeed a Swiss knife for networking. And it's another tool you need to be very familiar with.
Cybersecurity expert Malcolm Shore reviews popular pen testing tools, as well as the Bash and Python scripting skills required to be able to acquire, modify, and re-use exploit code. He also provides a refresher on Kali Linux and introduces techniques for testing web services. At the end of this course, you'll be prepared to take more advanced training, and to pursue the popular Offensive Security Certified Professional (OSCP) certification.
- Pen testing overview
- Pen testing tools
- Bash scripting
- Python scripting
- Kali and Metasploit
- Web testing
- Finding exploit code