Smag Grotto

Date: 11, June, 2021

Author: Dhilip Sanjay S


Click Herearrow-up-right to go to the TryHackMe room.

Enumeration

Nmap

$ nmap -sC -sV -p- 10.10.140.17 -oN nmap.out
Starting Nmap 7.91 ( https://nmap.org ) at 2021-06-11 11:30 IST

Nmap scan report for 10.10.140.17
Host is up (0.17s latency).
Not shown: 65533 closed ports
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.8 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 74:e0:e1:b4:05:85:6a:15:68:7e:16:da:f2:c7:6b:ee (RSA)
|   256 bd:43:62:b9:a1:86:51:36:f8:c7:df:f9:0f:63:8f:a3 (ECDSA)
|_  256 f9:e7:da:07:8f:10:af:97:0b:32:87:c9:32:d7:1b:76 (ED25519)
80/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: Smag
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 561.05 seconds

Gobuster

Home Page

Smag Grotto - Home

Mail Page

Smag Grotto - Mail

Initial Access

Analyzing the PCAP

Smag Grotto - Wireshark
  • There is a login.php page at development.smag.thm

  • Add development.smag.thm to /etc/hosts file

Smag Grotto - development

Accessing Admin Panel

  • Login using the credentials found in the pcap file:

Smag Grotto - Admin

Reverse Shell

  • Now that we have a web shell, we can get a reverse shell using:

  • Once you get a reverse shell, upgrade it:


User Flag

  • To access the User flag, we need to login as jake.

Jake's public key

  • Looking around the file system, I found jake's public key backup.

  • But wait, public keys are useless. We need private key to login using ssh.

  • May be we need to look for something else!

Cron Jobs

  • There was a cron job which was copying the backup key to jake's authorized keys:

Jake's Login

  • Now generate a key pair and replace the public key with the newly generated key.

  • Login using the private key:


Root Flag

Check for SUID bit

  • Nothing interesting here!

Check sudo permissions

  • Jake can run apt-get as as root without password!

Root Access

  • Check gtfobins for privilege escalation using apt-get binary:


Last updated