DEV Community

Cover image for What Is a Shell? Understanding Bind Shells and Reverse Shells
Arashad Dodhiya
Arashad Dodhiya

Posted on

What Is a Shell? Understanding Bind Shells and Reverse Shells

When people imagine hacking, they often picture a screen filled with green text and someone magically taking over a computer.

In reality, most attackers are trying to achieve something much simpler:

They want a shell.

A shell is one of the most important concepts in cybersecurity.

If you understand shells, you'll understand why attackers exploit vulnerabilities, why firewalls matter, and why terms like bind shell and reverse shell appear everywhere in penetration testing.

Let's break it down in simple words.


First, What Is a Shell?

Imagine you're sitting in front of your computer.

You open:

Terminal
Enter fullscreen mode Exit fullscreen mode

or on Windows:

Command Prompt
Enter fullscreen mode Exit fullscreen mode

You can type commands:

whoami
hostname
ipconfig
pwd
ls
Enter fullscreen mode Exit fullscreen mode

and the operating system executes them.

This interface is called a:

Shell
Enter fullscreen mode Exit fullscreen mode

A shell is simply a program that allows you to interact with the operating system using commands.


Why Is It Called a Shell?

Think of the operating system as a nut.

The valuable part is inside.

The shell is the outer layer that lets you interact with it.

User
  |
Shell
  |
Operating System
Enter fullscreen mode Exit fullscreen mode

Without the shell, you cannot easily tell the operating system what to do.


Local Shell vs Remote Shell

Normally:

You
 |
Your Computer
Enter fullscreen mode Exit fullscreen mode

You open a terminal and get a shell on your own machine.

This is a:

Local Shell
Enter fullscreen mode Exit fullscreen mode

Nothing special.

But what if you could execute commands on another computer?


Remote Shell

Suppose there is another machine:

Your Laptop
      |
      |
Remote Server
Enter fullscreen mode Exit fullscreen mode

Instead of controlling your own computer, you can run commands on the remote machine.

Example:

whoami
hostname
ipconfig
Enter fullscreen mode Exit fullscreen mode

The commands execute on the remote system.

This is called a:

Remote Shell
Enter fullscreen mode Exit fullscreen mode

And this is often the goal of an attacker.


Why Attackers Want a Shell

Imagine discovering a vulnerability.

That's useful.

But vulnerabilities don't magically give control.

A shell does.

Once an attacker obtains a shell, they may be able to:

Read files
Create files
Run programs
Explore the system
Move through networks
Enter fullscreen mode Exit fullscreen mode

A shell turns information into access.


The Door Analogy

Imagine a building.

Finding a vulnerability is like discovering an unlocked door.

Getting a shell is like stepping inside the building.

One gives opportunity.

The other gives access.


What Is a Bind Shell?

A bind shell is the simplest type of remote shell.

The target machine opens a port and waits for connections.

Victim Machine
      |
      |
 Port 4444 Open
Enter fullscreen mode Exit fullscreen mode

The attacker connects.

Attacker --------> Victim
Enter fullscreen mode Exit fullscreen mode

Once connected, the attacker receives a shell.


Visualizing a Bind Shell

Victim
   |
Listening Port
   |
4444
Enter fullscreen mode Exit fullscreen mode

Attacker:

Connect
   |
   v
4444
Enter fullscreen mode Exit fullscreen mode

Connection established.

Shell obtained.


Why Is It Called a Bind Shell?

Because the shell is bound to a network port.

Example:

Port 4444
       |
     Shell
Enter fullscreen mode Exit fullscreen mode

Anyone who connects to that port may receive the shell.


Real-Life Analogy

Imagine someone leaves their front door unlocked.

Victim
   |
Open Door
Enter fullscreen mode Exit fullscreen mode

The attacker walks in.

That's essentially how a bind shell works.

The victim waits.

The attacker connects.


The Problem With Bind Shells

At first glance, bind shells seem perfect.

But they have a major problem.

Modern firewalls often block incoming connections.

Example:

Internet
   |
Firewall
   X
Victim
Enter fullscreen mode Exit fullscreen mode

The attacker cannot reach the listening port.

The bind shell exists.

But nobody can connect to it.


Enter the Reverse Shell

This is where things get interesting.

Instead of the attacker connecting to the victim:

Attacker -----> Victim
Enter fullscreen mode Exit fullscreen mode

The victim connects to the attacker.

Victim -----> Attacker
Enter fullscreen mode Exit fullscreen mode

The direction is reversed.

That's why it's called a:

Reverse Shell
Enter fullscreen mode Exit fullscreen mode

How Reverse Shells Work

The attacker prepares a listener.

Attacker
     |
Listening
Port 4444
Enter fullscreen mode Exit fullscreen mode

Then the victim initiates the connection.

Victim --------> Attacker
Enter fullscreen mode Exit fullscreen mode

After the connection is established, the attacker receives a shell.


Why Reverse Shells Are So Popular

Because most networks allow outbound connections.

Think about your computer.

Every day it connects outward to:

Websites
Email servers
Cloud services
Updates
APIs
Enter fullscreen mode Exit fullscreen mode

Outbound traffic is normal.

Firewalls often allow it.


Visual Example

Bind Shell:

Attacker
     |
     |
     v
Victim
Enter fullscreen mode Exit fullscreen mode

Firewall may block it.


Reverse Shell:

Victim
     |
     |
     v
Attacker
Enter fullscreen mode Exit fullscreen mode

Often succeeds because outbound traffic is allowed.


The Phone Call Analogy

Imagine you want to talk to someone.

Bind Shell

You knock on their door.

You
 |
Their House
Enter fullscreen mode Exit fullscreen mode

If security guards stop you, the conversation never happens.


Reverse Shell

They call you.

Their House
      |
      |
      v
You
Enter fullscreen mode Exit fullscreen mode

Since they initiated the connection, security is less likely to interfere.

That's why reverse shells are much more common.


Why Penetration Testers Learn This

Understanding shells helps explain:

Remote Access
SSH
Port Forwarding
Pivoting
Post Exploitation
Firewalls
Network Security
Enter fullscreen mode Exit fullscreen mode

Many advanced cybersecurity concepts are simply different ways of obtaining, protecting, or controlling remote shells.


Bind Shell vs Reverse Shell

Bind Shell Reverse Shell
Victim listens Attacker listens
Attacker connects Victim connects
Requires inbound access Uses outbound connection
Often blocked by firewalls More likely to succeed
Less common today Most common approach

The One-Sentence Explanation

If you remember only one thing from this article, remember this:

A shell allows someone to execute commands on a system. A bind shell waits for the attacker to connect, while a reverse shell makes the target connect back to the attacker.

And once you understand that difference, a huge portion of penetration testing suddenly becomes much easier to understand.

Top comments (0)