<aside>

Anatomy of a Shell

</aside>

Every operating system has a shell, and to interact with it, we must use an application known as a terminal emulator. Here are some of the most common terminal emulators:

Terminal Emulator Operating System
Windows Terminal Windows
cmder Windows
PuTTY Windows
kitty Windows, Linux and MacOS
Alacritty Windows, Linux and MacOS
xterm Linux
GNOME Terminal Linux
MATE Terminal Linux
Konsole Linux
Terminal MacOS
iTerm2 MacOS

Shell Validation From 'ps'

 ps

    PID TTY          TIME CMD
   4232 pts/1    00:00:00 bash
  11435 pts/1    00:00:00 ps

Shell Validation Using 'env'

env

SHELL=/bin/bash

<aside>

bind Shell

</aside>

image.png

No. 1: Server - Target starting Netcat listener

Target@server:~$ nc -lvnp 7777Listening on [0.0.0.0] (family 0, port 7777)

In this instance, the target will be our server, and the attack box will be our client. Once we hit enter, the listener is started and awaiting a connection from the client.

Back on the client (attack box), we will use nc to connect to the listener we started on the server.

No. 2: Client - Attack box connecting to target

0xWALY@htb[/htb]$ nc -nv 10.129.41.200 7777Connection to 10.129.41.200 7777 port [tcp/*] succeeded!

Notice how we are using nc on the client and the server. On the client-side, we specify the server's IP address and the port that we configured to listen on (7777). Once we successfully connect, we can see a succeeded! message on the client as shown above and a received! message on the server, as seen below.

No. 3: Server - Target receiving connection from client

Target@server:~$ nc -lvnp 7777Listening on [0.0.0.0] (family 0, port 7777)
Connection from 10.10.14.117 51872 received!