Introduction
In this article, we are going to look at a command Injection exercise that uses Netcat. Command Injection is a malicious attack on a web application that allows a user to perform a nslookup, whois, ping, traceroute, and more from a webpage. This vulnerability can be tested using special characters such as “;” semi-colon, or “|” pipe or “| |”, or “&” or “&&” to append the end of the user expected input e.g. (www.mycompany.com) followed by a command e.g. (cat/here/pwd). These commands may be used to get confidential data or any malicious behavior the attacker may deem necessary using the host’s Operating System commands. If the input is not properly validated or sanitized, unintended commands are allowed to be executed.
An attacker may do anything including viewing configuration files, modifying, or deleting data but this all depends on the level of privilege the application has. Command Injection takes advantage of the functionality of the application in which system commands are executed. Command Injection builds upon the default behavior of the application to execute unintended commands.
Since we are going to be using a Netcat exercise in this article, it is good practice that we understand what it is and its uses before we dive into our primary exercise.
What is Netcat?
Netcat is a network utility that is used to READ/WRITE data across TCP and UDP network connections.it is also known as the Swiss Army Knife of Networking because of its versatility. Its features include debugging, port listening, port scanner, port redirector and it has backdoor capabilities. Netcat can be used to produce a reverse shell on the web server, given that is installed, and connected back to our machine yielding complete control over the system.
The following are some of the available Netcat Commands:
- Port scanning
- Scripting
- Shell Scripting
- TCP Server and TCP Client Commands
- Prevent DNS Lookup
- Create a Chat or Web Server
- ITEM with Netcat commands
- HTTP Requests with Netcat commands
- Verbose Scan with Netcat commands
- Launching Reverse (Backdoor) Shells
You can transfer files directly through Netcat or use it as a backdoor into other networked systems. It functions as a back-end tool that allows for port scanning and port listening.
Now that we know what Netcat is and its capabilities, let's now show how it can be used to execute certain commands.
First of all, let us find out how to download Netcat on our Windows machine:
- Visit this link
- Choose the safe download options Download nc111nt_safe.zip (password:nc) - Netcat for Windows (without -e)
- Extract the files to your chosen location, in this case, I will use Desktop.
- Open Command Prompt
- Navigate to the location of your extracted Folder
Run the following commands:
C:\Windows\system32>cd C:\Users\vicki\Desktop
C:\Users\vicki\Desktop>cd nc111nt
C:\Users\vicki\Desktop\nc111nt>nc
Cmd line: nc.exe –h

Join the conversation! Your thoughts help the community grow.