infosecfamily
← Back to catalog
TryHackMe  /  Medium  /  Linux

dogcat

Tested by: Testing performed by Nikolay Kravtsov, an aspiring information security specialist at 19:19 *(good room, right to move the gray matter)*

Testing scope and services used.

IP/domain Port Service Target Server Service
localhost 5901 WinKexServer -
localhost - Nmap Port Scanner -
localhost - Gobuster Directory Scanner -
localhost - Obsidian Notes -
localhost 1234 netcat listener -
localhost 7777 netcat listener 2 -
10.10.77.106 80 httpd Web Server +

Files used:

  • flag.php - first flag
  • flag2_QMW7JvaY2LvK.txt - second flag
  • flag3.txt - third flag
  • flag4.txt - 4 flag
  • backup.sh - file used to exit the container
  • /usr/bin/env - file used to escalate privileges.

    Procedure

1) Launch openvpn for access; kex to make Linux more convenient

  • kex --win && sudo openvpn Kolya080808.ovpn

    2) Scanning ports using nmap.

  • Results:

PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
|   2048 24:31:19:2a:b1:97:1a:04:4e:2c:36:ac:84:0a:75:87 (RSA)
|   256 21:3d:46:18:93:aa:f9:e7:c9:b5:4c:0f:16:0b:71:e1 (ECDSA)
|_  256 c1:fb:7d:73:2b:57:4a:8b:dc:d7:6f:49:bb:3b:d0:20 (ED25519)
80/tcp open  http    Apache httpd 2.4.38 ((Debian))
|_http-title: dogcat
|_http-server-header: Apache/2.4.38 (Debian)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

3) Launch Gobuster to search for directories.

  • Results:
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://10.10.19.55/
[+] Method:                  GET
[+] Threads:                 10
[+] Wordlist:                directory-list-2.3-medium.txt
[+] Negative Status codes:   404
[+] User Agent:              gobuster/3.6
[+] Timeout:                 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/cats                 (Status: 301) [Size: 309] [--> http://10.10.19.55/cats/]
/dogs                 (Status: 301) [Size: 309] [--> http://10.10.19.55/dogs/]
Progress: 29715 / 220561 (13.47%)^C
[!] Keyboard interrupt detected, terminating.
Progress: 29725 / 220561 (13.48%)
===============================================================
Finished
===============================================================   

4) On the site I found reading files (it was difficult, I’m not friendly with php :( )

  • Result:

    5) Trying to get reverse shell:

  • Result:

  • Conclusion: We need to do something different, or the same thing, but a little differently.

    6) I tried to do this through burp, while changing the user agent to a specific php code:

  • Result:

    7) Next I read flag.php:

  • Result:

8) I tried to see what is in /home, but there is nothing. So I increased the privileges with env:

  • Result:

    9) Then I looked in the nearest directories and directories where the flag is usually located, and I was right:

  • Result:

    10) Then I began to stupidly search for a mention of the flag, and again I was right:

  • Result:

11) You have to sweat here. Most likely we are in a container, because when I looked in the directory, I saw this:

  • Result:

    12) I also have this file available, which may mean that after a certain period of time another backup will be created:

  • Result:

    13) Then we try to somehow exit the container, getting another reverse shell using the same backup.sh:

  • Result:

    14) Well, we read the last flag:

  • Result:

Note: An excellent, well-designed room that makes you think. Fairly easy, but still worth completing! I advise you to go through it! Thanks TryHackMe for the room!

Vulnerabilities found

LFI and RCE

PoC:

(point 4) (point 6)

CVSSv3 Score: 7.9 (Critical)

Description:

In this case, RCE and LFI are related to incorrect configuration of queries in index.php.

Reproducing the vulnerability:

PoC compliant.

Remediation recommendations:

  • Change the code of the index.php page on the site.
  • OWASP.

    Video walkthrough

  • Original:

  • YouTube