> For the complete documentation index, see [llms.txt](https://n000b3r.gitbook.io/oscp-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://n000b3r.gitbook.io/oscp-notes/htb/oscp-like-boxes/shoppy.md).

# Shoppy

### Scanning

Firstly, I started off with a full port scan on the target.&#x20;

<figure><img src="/files/UFruPr4SGlFqziOi43RT" alt=""><figcaption><p>Fig 1. Nmap full port scan</p></figcaption></figure>

From figure 1, it is evident that ports 22,80 and 9093 were open. Next, I ran an aggressive Nmap scan on all those open ports.

<figure><img src="/files/JZ4m2qY2Sh9dhLiyw4kv" alt=""><figcaption><p>Fig 2. Nmap aggressive scan part 1</p></figcaption></figure>

<figure><img src="/files/r3lbGmqOZF6BjhqkPOgL" alt=""><figcaption><p>Fig 3. Nmap aggressive scan part 2</p></figcaption></figure>

<figure><img src="/files/P2dZSUQTH7EWd1JNuQzC" alt=""><figcaption><p>Fig 4. Nmap aggressive scan part 3</p></figcaption></figure>

### Enumerating HTTP

From Fig 2, the target is likely to be a debain machine that runs a Nginx server. From the HTTP title shown in Fig 2, it suggests that we should add an entry for`shoppy.htb` to our `/etc/hosts` file with the corresponding IP address to be able to access this domain in our browser.

<figure><img src="/files/KhWPfLwu3DR7Vm7BbFV7" alt=""><figcaption><p>Fig 5. Adding domain to /etc/hosts</p></figcaption></figure>

Afterwards, I opened up `/etc/hosts` file and added in the target IP as well as the domain name `shoppy.htb`.

<figure><img src="/files/9PaIshNLTsedgd6T7Pf7" alt=""><figcaption><p>Fig 6. Landing page</p></figcaption></figure>

Heading over to `shoppy.htb`, I was greeted by a large countdown timer for the supposed launch of Shoppy Beta.

I ran dirsearch in the background to uncover subdirectories and I found the login page at `/login`.

<figure><img src="/files/o3pzVLlkGKHMWnj9Hb8F" alt=""><figcaption><p>Fig 7. Dirsearch results</p></figcaption></figure>

Heading over to the `/login` page, I was greeted by a simple login screen asking for my Username and Password.

<figure><img src="/files/Xlm76j4BT0PtxVaNG4cY" alt=""><figcaption><p>Fig 8. Admin login page</p></figcaption></figure>

Upon trying the default "admin:admin" credentials, I was redirected to `/login?error=WrongCredentials`.

<figure><img src="/files/GhoOmFLaKTtwP0XVeVL0" alt=""><figcaption><p>Fig 9. Wrong credentials</p></figcaption></figure>

The following burpsuite request and response depicts the scenario where incorrect credentials were used.

<figure><img src="/files/194fNO2WDWq7O1NuC5N5" alt=""><figcaption><p>Fig 10. Burpsuite request and response for incorrect credentials</p></figcaption></figure>

Fig 11 shows a simple test for the presence of SQLi in the login page by appending a single quote after the username string. However, as seen in the Response, the web server does not give us a valid response back.

<figure><img src="/files/QBnCGmbycSuNTDWlfNG4" alt=""><figcaption><p>Fig 11. No response when SQLi</p></figcaption></figure>

After facing a roadblock when testing for the presence of SQLi, I enumerated further, trying to uncover the underlying framework that built this web app. By going to a non-existent subdirectory, I was greeted by a "Cannot GET /subdirectory\_nam&#x65;*"* message.&#x20;

<figure><img src="/files/O4Yon1GqwdWvU2Sj782z" alt=""><figcaption><p>Fig 12. Error message when browsing non-existent subdirectories</p></figcaption></figure>

Searching for the error message online, I was able to find that it most likely belongs to a Node.js web app.

<figure><img src="/files/MiMyrUWPjTJ5MbfCqkSb" alt=""><figcaption><p>Fig 13. Google Search for error message</p></figcaption></figure>

Since most node.js web apps are powered by MongoDB, our SQLi needs to be tweaked for the NoSQL syntax.

The `Content-Type: x-www-form-urlencoded` can be changed to `Content-Type: application/json` and the post parameters could be passed as a JSON object.

<figure><img src="/files/TM6VLwFjAvKjapxLcgjL" alt=""><figcaption><p>Fig 14. Change Content-Type to application/json</p></figcaption></figure>

By omitting the `password` field, I obtained the following error message in Fig 15. From the error logs, it is evident that the the user `jaeger` was present on the target.

<figure><img src="/files/2oQRj7lwxwpLKE4oVI8k" alt=""><figcaption><p>Fig 15. User named jaeger</p></figcaption></figure>

Viewing for a Mongo SQLi [here](https://book.hacktricks.xyz/pentesting-web/nosql-injection#sql-mongo), I found the payload `' || 1==1`

<figure><img src="/files/VefMs44Fhcnp0KXoGqVI" alt=""><figcaption><p>Fig 16. Mongodb SQLi</p></figcaption></figure>

Taking reference to the above payload and contextualizing it, I used the payload `admin'||'1'='1` . From the burpsuite's response, I was able to authenticate into the admin console.

<figure><img src="/files/b6o9ocubGYuh5FTFhoH1" alt=""><figcaption><p>Fig 16. Successful SQLi</p></figcaption></figure>

Trying out the SQLi on the webpage itself, I managed to login.

<figure><img src="/files/cBwLZQqAYVdRDxQeKbkH" alt=""><figcaption><p>Fig 17: Trying out SQLi </p></figcaption></figure>

Fig 18 shows the admin console of the Shoppy web app. The `search for users` functionality on the top right caught my attention.

<figure><img src="/files/Tqx3zKPSc7vYDVyCSn7Y" alt=""><figcaption><p>Fig 18. Logged in to admin console</p></figcaption></figure>

Clicking on it and keying in `admin`, I obtained the database entry belonging that of the admin.

<figure><img src="/files/eP13WB1j9KP1WtEaNmxJ" alt=""><figcaption><p>Fig 19. Search "admin" and export details</p></figcaption></figure>

I decided to enumerate the database further in hopes of dumping all the records. I used the command `admin'||'1'=='1 to view all records of the Shoppy App.`

<figure><img src="/files/zpOvrFEaHR2LPTjBE7pG" alt=""><figcaption><p>Fig 20. Search for all users</p></figcaption></figure>

Now, I obtained the password hash of 2 users, namely the admin and the josh user.

<figure><img src="/files/7MTIouHAdwAM3eIb9Dgw" alt=""><figcaption><p>Fig 21. Database dump</p></figcaption></figure>

Using Crackstation, I managed to crack Josh's hash to be `remebermethisway`. Howerver, I was unable to login to the SSH server using`josh:remembermethisway.`

<figure><img src="/files/lO65yPUJS6BhYMiBsVZ6" alt=""><figcaption><p>Fig 22. Josh's password cracked</p></figcaption></figure>

Next, I decided to conduct further enumeration particularly on uncovering the subdomains on `shoppy.htb`. I used the ffuf command `ffuf -u http://shoppy.htb/ -H "Host: FUZZ.shoppy.htb" -w /usr/share/seclists/Discovery/DNS/bitquark-subdomains-top100000.txt -fw 5`

<figure><img src="/files/XYj5IeFCyZOel7o0VCpu" alt=""><figcaption><p>Fig 23. Enumerating subdomains</p></figcaption></figure>

From the figure above, I found the subdomain `mattermost`, which is an open-source, self-hostable online chat service that is mainly used internally within an organization.

<figure><img src="/files/Fo1TDAc6zxh5iV1fJkHb" alt=""><figcaption><p>Fig 24. Add subdomain to /etc/hosts</p></figcaption></figure>

Using Josh's credentials, I was able to login to his mattermost account. Viewing the `Deploy Machine` channel, I found the following.

<figure><img src="/files/4TGtQyMo7z2dteCbAfw9" alt=""><figcaption><p>Fig 25. Jaeger credentials</p></figcaption></figure>

After obtaining jaeger's credentials, I then proceeded to login to the SSH server and was able to obtain `user.txt`.

<figure><img src="/files/ghVwj23J5mz622Kxo3Bn" alt=""><figcaption><p>Fig 26. Obtained user flag</p></figcaption></figure>

### Privilege Escalation

Checking the `sudo -l` for jaeger, I can see that he was able to run `/home/deploy/password-manager` as the user `deploy`.

<figure><img src="/files/iexeQeIgNqijfTOZUZal" alt=""><figcaption><p>Fig 27. Jaeger able to run password-manager as user deploy</p></figcaption></figure>

Viewing the permissions inside the directory `/home/deploy`, I was not able to view the `creds.txt` and `password-manager.cpp` files.

<figure><img src="/files/TcPKr5RX6dIqwHCuNY0x" alt=""><figcaption><p>Fig 28. Permissions for files in /home/deploy</p></figcaption></figure>

Let's run the `/home/deploy/password-manager` file as the user `deploy`. It seems that I need the master password in order to view the passwords inside the Josh password manager.

<figure><img src="/files/IsxLwQmN5qEgeiVbMu8q" alt=""><figcaption><p>Fig 29. Running password-manager</p></figcaption></figure>

Using `strings` command and specifying the encoding as little endian, I obtained the string `Sample`.

<figure><img src="/files/7y13R66G5WrrDuzcWjQQ" alt=""><figcaption><p>Fig 30. Strings with little endian format</p></figcaption></figure>

Keying in `Sample` as the master password, I was able to obtain the credentials for the user `deploy`.

<figure><img src="/files/KQPxbMsmbv2PyUqGLjDV" alt=""><figcaption><p>Fig 31. Obtained deploy creds</p></figcaption></figure>

Switching to user `deploy` , I realised that it is not able to run `sudo` on the target machine.

<figure><img src="/files/bFthXP1y7nYZ9EVCznoX" alt=""><figcaption><p>Fig 32. Unable to run sudo on deploy</p></figcaption></figure>

Checking the `id` on `deploy`, we can see that it is in the `docker` group.

<figure><img src="/files/fJXYjCR66wqAWc5SEBAP" alt=""><figcaption><p>Fig 33. Deploy part of docker group</p></figcaption></figure>

I was then able to use docker to obtain root privileges and got `root.txt` file.

<figure><img src="/files/JaBClWGmmIahXEicL28H" alt=""><figcaption><p>Fig 34. Docker privilege Escalation</p></figcaption></figure>
