Sunday, August 23, 2015

Ncat - Swiss Army Knife - Summary

Its been a while, I haven't written any blog due to my busy job schedule + client side projects.I was just furnishing knowledge so decided to practice netcat. So this is single tutorial for netcat which includes all necessary information about it.

You can Google about nc. I will directly jump into it's practical use.

Netcat as simple chat server.
Open a port to listen. Allow firewall access.
Connect from another machine on that port. Once connected type any message and press enter.

From kali, sent text appeared here. Now type something and send to kali.

 Binding Linux shell to windows

Open port and bind Linux shell on it.

Windows can access Linux shell on that open port since shell is bind on that port via Linux machine itself.

 Binding Windows shell to Linux

Open port and bind windows command shell to it.

Access Windows Shell via Linux machine on that particular port.
Reverse Shell Scenario and Need
Consider Person A using Linux
             Person B using Windows

Person A has no control over router. Hence he can not forward traffic from it to his local machine. Thus how person A can not bind a port to local machine and he needs help.

Any way to connect? Yes
Instead binding port with shell locally, he will send his shell control to person B directly. Then person B will able to access person A's shell. This scenario is called reverse shell.

Reverse Shell Scenario

Windows needs help from Linux. Windows can not bind port on its local machine then follow below steps for reverse shell scenario.

1. Find which port is open on Linux machine. Port 1337 is opened for this activity.

2. IP address of linux is Windows will send its shell control directly to Linux with the help of Linux's IP address as shown below.

3. Getting upon connected, you can see that Linux can use windows's shell and provide help to windows. This is reverse shell scenario in which you do not bind shell on port and let others connect to you. You simply give control of your shell to another person and thus how reverse shell gets executed.

File transfer using NC

Windows expects to welcome chintan.txt file
Linux sends chintan.txt to windows on that open port.
Windows successfully receives chintan.txt file.
Thus how nc (Netcat) works.

No comments: