# Pandora

Nmap Scan

```
$ nmap -sC -sV -Pn -oN nmap 10.10.11.136
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-05-16 16:31 +08
Nmap scan report for 10.10.11.136
Host is up (0.040s latency).
Not shown: 998 closed tcp ports (conn-refused)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   3072 24:c2:95:a5:c3:0b:3f:f3:17:3c:68:d7:af:2b:53:38 (RSA)
|   256 b1:41:77:99:46:9a:6c:5d:d2:98:2f:c0:32:9a:ce:03 (ECDSA)
|_  256 e7:36:43:3b:a9:47:8a:19:01:58:b2:bc:89:f6:51:08 (ED25519)
80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))
|_http-title: Play | Landing
|_http-server-header: Apache/2.4.41 (Ubuntu)
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 8.21 seconds
```

```
$ sudo nmap -sU -sV -Pn -oN udp-nmap 10.10.11.136
[sudo] password for ranay:
Nmap scan report for panda.htb (10.10.11.136)
Host is up (0.042s latency).
Not shown: 999 closed udp ports (port-unreach)
PORT    STATE SERVICE VERSION
161/udp open  snmp    SNMPv1 server; net-snmp SNMPv3 server (public)
Service Info: Host: pandora

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

## Initial Access

### TCP Port 80

There is a website running on port 80.

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2FuIjAcxKL2VKw8ov7Pqzg%2Fimage.png?alt=media&#x26;token=03a6ee9d-e905-4a59-91ee-3e69930ad48a" alt=""><figcaption></figcaption></figure>

Upon further inspection, the website does not have anything that is very suspicious.

```
$ gobuster dir -u http://10.10.11.136 -w /usr/share/wordlists/dirb/common.txt -o dirb-gobuster -b 302,404 -k
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://10.10.11.136
[+] Method:                  GET
[+] Threads:                 10
[+] Wordlist:                /usr/share/wordlists/dirb/common.txt
[+] Negative Status codes:   404,302
[+] User Agent:              gobuster/3.6
[+] Timeout:                 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/.hta                 (Status: 403) [Size: 277]
/.htpasswd            (Status: 403) [Size: 277]
/.htaccess            (Status: 403) [Size: 277]
/assets               (Status: 301) [Size: 313] [--> http://10.10.11.136/assets/]
/index.html           (Status: 200) [Size: 33560]
/server-status        (Status: 403) [Size: 277]
Progress: 4614 / 4615 (99.98%)
===============================================================
Finished
===============================================================
```

```
ffuf -w /usr/share/wordlists/seclists/Discovery/DNS/namelist.txt -u http://10.10.11.136 -H "HOST:FUZZ.panda.htb" > vhost-result.txt

        /'___\  /'___\           /'___\       
       /\ \__/ /\ \__/  __  __  /\ \__/       
       \ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\      
        \ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/      
         \ \_\   \ \_\  \ \____/  \ \_\       
          \/_/    \/_/   \/___/    \/_/       

       v2.1.0-dev
________________________________________________

 :: Method           : GET
 :: URL              : http://10.10.11.136
 :: Wordlist         : FUZZ: /usr/share/wordlists/seclists/Discovery/DNS/namelist.txt
 :: Header           : Host: FUZZ.panda.htb
 :: Follow redirects : false
 :: Calibration      : false
 :: Timeout          : 10
 :: Threads          : 40
 :: Matcher          : Response status: 200-299,301,302,307,401,403,405,500
________________________________________________

:: Progress: [151265/151265] :: Job [1/1] :: 53 req/sec :: Duration: [0:05:58] :: Errors: 0 ::
                                                                                                                                                                                                                  
$ cat vhost-result.txt | grep 'FUZZ'

```

Even after trying to brute force the directory and virtual host give us no results or anything interesting to take a look.

### UDP Port 161

The first thing to try is to get the community string through brute-force.

```
$ hydra -P /usr/share/seclists/Discovery/SNMP/common-snmp-community-strings.txt 10.10.11.136 snmp   
Hydra v9.5 (c) 2023 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).

Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2024-05-16 17:20:15
[DATA] max 16 tasks per 1 server, overall 16 tasks, 118 login tries (l:1/p:118), ~8 tries per task
[DATA] attacking snmp://10.10.11.136:161/
[161][snmp] host: 10.10.11.136   password: public
[STATUS] attack finished for 10.10.11.136 (valid pair found)
1 of 1 target successfully completed, 1 valid password found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2024-05-16 17:20:15
```

So the community string is  `public`. By using this string, we can try to see if there is any information that can be leaked out.&#x20;

There is some information that is leaked by using `braa`.

```
$ braa public@10.10.11.136:.1.3.6.*
10.10.11.136:42ms:.0:Linux pandora 5.4.0-91-generic #102-Ubuntu SMP Fri Nov 5 16:31:28 UTC 2021 x86_64
10.10.11.136:41ms:.0:.10
10.10.11.136:42ms:.0:457069
10.10.11.136:41ms:.0:Daniel
10.10.11.136:42ms:.0:pandora
10.10.11.136:42ms:.0:Mississippi
```

However, the password is not mississippi.

After further enumeration with `snmpbulkwalk`, we can see the password for `daniel` in plaintext.

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2FuHZnHHrRktgQtMrFewbT%2Fimage.png?alt=media&#x26;token=857b53f0-65ee-41cd-bd0d-620acf3b41b5" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2F1gU4Z7zRIVnono5zQr8n%2Fimage.png?alt=media&#x26;token=97721a2f-211d-489c-92c5-783bddcd86bc" alt=""><figcaption></figcaption></figure>

After trying the password, we are able to login into ssh using `daniel` account.

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2FeIp3hxYuJO1Q8b1IIitH%2Fimage.png?alt=media&#x26;token=df181309-3805-4883-b3f7-e7011c698fef" alt=""><figcaption></figcaption></figure>

## Getting User

Through `linpeas.sh`, there is a VirtualHost at `localhost:80`.

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2F9CS7M948bTaGIpIO7FAK%2Fimage.png?alt=media&#x26;token=984c9ed3-f87d-4150-9b0e-60357326342e" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2F0PPOWHSLUdeeCnCgqZJT%2Fimage.png?alt=media&#x26;token=b46e6748-a689-4b15-b791-4d4bb26a9584" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2FbhQCmoqzd5wCuCiSndXT%2Fimage.png?alt=media&#x26;token=86d3cd02-dc76-404e-aacc-5bcc1fe7935b" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2FYJAlM5NXqxRW6S0onRrW%2Fimage.png?alt=media&#x26;token=fc752ce4-46f2-46e2-97cd-8f9034fe4eb3" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2FjsbVQmpaJ2eCu6nLHrYP%2Fimage.png?alt=media&#x26;token=a9603220-d7e7-4fb1-96d5-f927b2bc634c" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2FfT7sKvDTJx3UAj5Tn6ES%2Fimage.png?alt=media&#x26;token=d7a6f6f6-bc3e-408c-a09a-f8e7b7c007f9" alt=""><figcaption></figcaption></figure>

{% embed url="<https://github.com/shyam0904a/Pandora_v7.0NG.742_exploit_unauthenticated>" %}

### SQLi Vulnerability

However, it does not return a shell so we still need to use the SQLi method. After running sqlmap, we can see the the database name is `pandora` .

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2FglDzkMmbKNdAf38rvNuS%2Fimage.png?alt=media&#x26;token=bddb5a26-c858-4cbd-9398-7c7400c5dfd7" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2FR4Ry79c2pkQdMUJ2zFOH%2Fimage.png?alt=media&#x26;token=6b347d34-b80f-46f1-ad0a-fe6b41cd2abf" alt=""><figcaption></figcaption></figure>

Further enumeration using sqlmap will return us all the tables in the database but there is 1 table that stood out which is `tsessions_php`.

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2FSwr5Z2PR4KGy04IEVPu3%2Fimage.png?alt=media&#x26;token=6b26623a-56a4-477f-a679-8036e65cebfb" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2FcuDYuFjgtTU873VSsvnX%2Fimage.png?alt=media&#x26;token=0ae19842-cf77-4f4b-95d9-b8b922baa276" alt=""><figcaption></figcaption></figure>

Even further enumeration, we can see that this table contains all the session for the user account of `admin`.

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2FpakI6l9dCxbbqX8bLNHQ%2Fimage.png?alt=media&#x26;token=07297d61-3a5a-4bd9-97bd-5dae6c0374e5" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2F4Hf2WZHUM5o6Sf2aUP27%2Fimage.png?alt=media&#x26;token=cbe16222-5493-49a1-9558-fa78becab86f" alt=""><figcaption></figcaption></figure>

After adding the session to the web brower, we are able to log into the FMS. So the next step is to upload a webshell into the FMS.

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2F2jGEMWDmAlPIpaRCKrxP%2Fimage.png?alt=media&#x26;token=33332a4a-a35e-4a1f-aacc-1653527b6c5b" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2FhRSf1dMQQ5Dz6jadtf2u%2Fimage.png?alt=media&#x26;token=a6ae6f4f-324a-4330-8aa5-52f1c163aa8c" alt=""><figcaption></figcaption></figure>

After that, we can just call the reverse shell using the payload as shown in the image below.

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2Fm7miYNAwvdjwuD1cPN8s%2Fimage.png?alt=media&#x26;token=d61deaa1-2c54-4f57-b967-988bcc85f8ec" alt=""><figcaption></figcaption></figure>

This will return us a shell as the user `matt`.

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2FXlCFlJ6RHYVnHV30nAMt%2Fimage.png?alt=media&#x26;token=0da9ddfe-df65-42f5-aab5-78b0789f0273" alt=""><figcaption></figcaption></figure>

## Privilege Escalation

However, given that shell we are not able to do much so we will drop our own public key into the user and log in using `ssh`.

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2FKuxZaz0YLnXW0hU7Fsan%2Fimage.png?alt=media&#x26;token=461d142c-73c9-4c59-9ff2-861887d5b118" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2FTMdULUp0x8A2S5YjrvR6%2Fimage.png?alt=media&#x26;token=7aee0b7d-b234-499d-bd41-89333b9dcf55" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2FuJ9PXPWppTgK3aLanjsr%2Fimage.png?alt=media&#x26;token=0465c138-913e-4751-98c4-eeb6502633d5" alt=""><figcaption></figcaption></figure>

### Exploiting SUID binary for PATH variable injection

After doing some enumeration about which files that have the SUID bits enable, we realised that pandora\_backup is one of them. During the execution of the binary, we can also see that the binary is using tar.

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2FgAMGQ0rFz19ybAc8k5QY%2Fimage.png?alt=media&#x26;token=69484ad3-8228-45ea-9677-5fcc623899a8" alt=""><figcaption></figcaption></figure>

So we can just exploit the PATH and inject a malicious binary called `tar`

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2Fq04374vE2DMLnGmtqdb6%2Fimage.png?alt=media&#x26;token=a3f981b7-eab5-4130-864c-0a0d679c3557" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2F5QrFlEzQ0i5HQNf1YwsY%2Fimage.png?alt=media&#x26;token=cd13e9f7-5ae5-4d48-86c2-071faa729c02" alt=""><figcaption></figcaption></figure>

Ensures that the `tar` binary is an executable.

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2FrLHdaLulXbQSvCXnemPA%2Fimage.png?alt=media&#x26;token=8305c917-927d-46e7-9b60-57eb6e7ef45d" alt=""><figcaption></figcaption></figure>

After which after running the binary again, we are able to obtain the root shell and get the flag.

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2F1dHRUCKGCSTKEgzKJlTn%2Fimage.png?alt=media&#x26;token=74d6a724-24a4-426d-b73b-0d38bdf07223" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2790417739-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIXulVMkW3AbpCXfmoP1H%2Fuploads%2FhYiNvtiPXKLolqFdliCX%2Fimage.png?alt=media&#x26;token=f539b157-f91b-41bc-aa41-47f4d8b5cf6f" alt=""><figcaption></figcaption></figure>
