Golden Eye

Date: 26, June, 2021

Author: Dhilip Sanjay S


Click Herearrow-up-right to go to the TryHackMe room.

Enumeration

How many ports are open?

  • Answer: 4

  • Steps to Reproduce:

$ nmap -sC -sV -p- 10.10.251.158 -oN nmap.out
Starting Nmap 7.91 ( https://nmap.org ) at 2021-06-26 13:25 IST

Host is up (0.15s latency).
Not shown: 65531 closed ports
PORT      STATE SERVICE     VERSION
25/tcp    open  smtp        Postfix smtpd
|_smtp-commands: ubuntu, PIPELINING, SIZE 10240000, VRFY, ETRN, STARTTLS, ENHANCEDSTATUSCODES, 8BITMIME, DSN, 
|_ssl-date: TLS randomness does not represent time
80/tcp    open  http        Apache httpd 2.4.7 ((Ubuntu))
|_http-server-header: Apache/2.4.7 (Ubuntu)
|_http-title: GoldenEye Primary Admin Server
55006/tcp open  ssl/unknown
| ssl-cert: Subject: commonName=localhost/organizationName=Dovecot mail server
| Not valid before: 2018-04-24T03:23:52
|_Not valid after:  2028-04-23T03:23:52
|_ssl-date: TLS randomness does not represent time
55007/tcp open  pop3        Dovecot pop3d
|_pop3-capabilities: TOP UIDL AUTH-RESP-CODE USER PIPELINING STLS RESP-CODES SASL(PLAIN) CAPA
|_ssl-date: TLS randomness does not represent time

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 591.22 seconds

Take a look on the website, take a dive into the source code too and remember to inspect all scripts!

Golden Eye - Port 80

Who needs to make sure they update their default password?

  • Answer: Boris

  • Steps to Reproduce: In terminal.js:

What's their password?

  • Answer: InvincibleHack3r

  • Steps to Reproduce:

Now go use those credentials and login to a part of the site.

Golden Eye - Sev Home

It's Mail Time

Take a look at some of the other services you found using your nmap scan. Are the credentials you have re-usable?

  • Answer: No

  • Steps to Reproduce:

If those creds don't seem to work, can you use another program to find other users and passwords? Maybe Hydra? What's their new password?

  • Brute force the password of Boris:

  • Brute force the password of Natalya:

Inspect port 55007, what services is configured to use this port?

  • Answer: telnet

  • Steps to Reproduce: We can connect to this port using telnet

What can you find on this service?

  • Answer: emails

  • Steps to Reproduce:

  • Using Natalya's credentials:

  • Using Boris' credentials:

What user can break Boris' codes?

  • Answer: Natalya

Using the users you found on this service, find other users passwords

Keep enumerating users using this service and keep attempting to obtain their passwords via dictionary attacks.

  • Too long and boring!!


GoldenEye Operators Training

Try using the credentials you found earlier. Which user can you login as?

  • Answer: xenia

Golden Eye - Xenia's Login

Have a poke around the site. What other user can you find?

  • Answer: Doak

What was this users password?

  • Using Hydra over pop3:

Use this users credentials to go through all the services you have found to reveal more emails.

  • We can find doak's username and password

What is the next user you can find from doak?

  • Answer: dr_doak

What is this users password?

Take a look at their files on the moodle (severnaya-station.com)

  • There is a file name s3cret.txt - for James

Download the attachments and see if there are any hidden messages inside them?

  • Download the jpg image. Check for meta data:

  • Using base64 decode, we can find the passsword:

Using the information you found in the last task, login with the newly found user.

  • We know that admin user is available. So, we'll use the recently found password to login as admin:

Golden Eye - Admin

Take a look into Aspell, the spell checker plugin.

  • Change the spell engine (to PSpellShell)

  • Change the Path to aspell (add your ip address)

Golden Eye - Aspell

As this user has more site privileges, you are able to edit the moodles settings. From here get a reverse shell using python and netcat.

  • Now we need to trigger the Spell checker

  • Goto Navigation -> Site Pages -> Stie Blogs -> Add new

  • Now Toggle Spell Checker to get a reverse shell:


Privilege Escalation

Enumerate the machine manually.

  • Have a checklist and check them manually

Whats the kernel version?

  • Answer: 3.13.0-32-generic

  • Steps to Reproduce:

Overlayfs Exploit

  • This machine is vulnerable to the overlayfs exploit. The exploitation is technically very simple:

    • Create new user and mount namespace using clone with CLONE_NEWUSER|CLONE_NEWNS flags.

    • Mount an overlayfs using /bin as lower filesystem, some temporary directories as upper and work directory.

    • Overlayfs mount would only be visible within user namespace, so let namespace process change CWD to overlayfs, thus making the overlayfs also visible outside the namespace via the proc filesystem.

    • Make su on overlayfs world writable without changing the owner

    • Let process outside user namespace write arbitrary content to the file applying a slightly modified variant of the SetgidDirectoryPrivilegeEscalation exploit.

Fix the exploit to work with the system you're trying to exploit. Remember, enumeration is your key! What development tools are installed on the machine?

  • By checking inside /usr/bin, we can find clang is installed. So, we can use that to compile the code!

  • Make sure to modify a line inside the exploit which contains gcc to clang: lib = system("clang -fPIC -shared -o /tmp/ofs-lib.so /tmp/ofs-lib.c -ldl -w");

  • Transfer the exploit to the victim machine and compile it!

circle-info

cc was also installed on the machine!! That was the hint - one letter change!

Root flag

  • Run the exploit to get root access:

Golden Eye - Flag Captured

References

Last updated