Netcat is a simple, yet powerful tool to be present in any security analyst's toolkit. Mati Aharoni, one of the core developers of BackTrack(PenTesting OS), was quoted saying, “It’s not always the best tool for the job, but if I was stranded on an island, I’d take Netcat with me.” Some of the functionalities of Netcat include port scanning, transferring files, banner grabbing, port listening and redirection, and more nefariously, a backdoor.
This tool is available for both Windows & Linux operating systems, and comes pre-installed with BackTrack.
Modes of Operation:
Netcat has 2 modes of operation:
- Client Mode
- Server Mode
In the above screenshots, the two lines above "options", say :
connect to somewhere: nc [-options] hostname port[s] [ports] …
listen for inbound: nc –l –p port [options] [hostname] [port]
Connect to somewhere, indicates the syntax used for operating Netcat in client mode, while,
Listen for inbound, indicates the syntax used to operate Netcat in server mode. Notice the -l switch, which puts the Netcat into listening mode, also known as the server mode.
a.) File Transfer
Scenario: I have a file created in Windows, named "virus.txt", which needs to be transferred to the Linux machine.
- And then by using ls, command we are verifying that the successful transfer of that file.
b.) Port Scanning
Though Nmap is the most widely used and preferred port scanning utility, but Netcat can also come handy while scanning ports. Following is an example, in which we scan port numbers top 10 of 192.168.196.130:
Next, Let's scan for selective ports :
This is a line by line conversation that is happening, though it is quite difficult to see from a screenshot, therefore, try and perform it.
This here, concludes a bird's eye view of Netcat.