πŸ€–Lookup

License

The following post by anthonyjsaab is licensed under CC BY 4.0arrow-up-right

0 - Introduction

Machine Version: Lookup v1.2

"Lookup offers a treasure trove of learning opportunities for aspiring hackers. This intriguing machine showcases various real-world vulnerabilities, ranging from web application weaknesses to privilege escalation techniques. By exploring and exploiting these vulnerabilities, hackers can sharpen their skills and gain invaluable experience in ethical hacking. Through "Lookup," hackers can master the art of reconnaissance, scanning, and enumeration to uncover hidden services and subdomains. They will learn how to exploit web application vulnerabilities, such as command injection, and understand the significance of secure coding practices. The machine also challenges hackers to automate tasks, demonstrating the power of scripting in penetration testing.ο»Ώ"

Created by tryhackmearrow-up-right, and josemlwdfarrow-up-right

1 - Port Scans

1a - Discovery

1b - Versioning and OS fingerprinting

1c - Vulners

1z - What we know so far

  • No interesting CVEs

  • We have only 2 ports to investigate: 22 and 80

2 - Port 80

2a - Exploring

When browsing port 80 using the IP of the target machine as VHOST, we get a 302 Redirect to the Location http://lookup.thm.
Very uninteresting landing page. No internal links whatsoever.
Trying out random credentials would give us a generic error message. It does redirect us to the landing page. No query strings or cookies are used.

2b - Enumeration of lookup.thm

2bi - VHOST enum (dead-end)

Sample of a failed attempt, redirects to lookup.thm

2bii - Dirbusting (dead-end)

2biii - Username enumeration

Even if the login form returns a generic response when we submit random credentials, we could still find some clues if the username is correct:

Setting up bruteforcing using Turbo Intruder, a nice extension in Burp Suite Community. We are using the xato-net username wordlist
Results after a minute

As seen above, there are two specific usernames that, when used, return a different response compared to other usernames. Now the message specifies that the password is wrong, implying that 'admin' and 'jose' are valid usernames.

2biv - Password bruteforcing

Since admin is the more interesting username, we are going to bruteforce the password associated with admin:

Setting up bruteforcing using Turbo Intruder. We are using the xato-net passwords wordlist.
Results after a minute

A password X stands out. Even though we got the initial error, this password in particular did return a different response than the other attempts.

Since the attempt failed with admin, we will try it with jose:

Alright! We can see that the login is apparently successful since a special cookie was sent in return.

We now have valid credentials! However, attempting to login to SSH using these credentials will fail. We will stick with HTTP for now. The successful attempt in HTTP sends us to another VHOST. It seems that the absence of a valid cookie was the reason why we did not detect the 'files.lookup.thm' VHOST earlier.

2c - files.lookup.thm: Jackpot?

When logging in successfully in lookup.thm using the browser, we are redirected to this page:

All of these files have credentials in them. None of them are useful when bruteforcing SSH. These files are completely useless.

2d - Exploit & Foothold

Examining the source code, we can locate many instances were elFinder is mentioned. A comment even includes a link to its GitHub repo:

It turns out this file manager for Web is quite popular! With around 7K commits and 5K stars, maybe some exploit is out there?

We will try the 46481.py exploit. However, we need to tweak it. The Python script should include in the HTTP requests it sends the cookie obtained after a successful login to lookup.thm. The changes are on lines 26, 27, 40, 46, 51, 58

Running the above tweaked exploit gives us foothold! :

3 - Horizontal PrivEsc

3a - LinPEAS

We run LinPEAS on the target machine. In the output of LinPEAS, we can find the following:

-rwsr-sr-x 1 root root 17K Jan 11 2024 /usr/sbin/pwm (Unknown SUID binary!)

pwm is owned by root and has the SUID and SGID bits set! Running the mentioned binary gives the following output:

Exfiltrating this binary to my Kali for further analysis:

From the above output, we can see that the pwm binary prints the contents of /home/%s/.passwords, where %s is the output of the call to id . It happens that the user think does have this file, and we cannot read it using www-data:

We can also see from the ltrace output that the program tries to invoke id without specifying the absolute path (lines 5 & 6). We can abuse this ambiguity.

3b - Abusing SUID - Going for think's passwords

We write an executable that gives the same output as id when being run by think:

All is set up correctly. Moment of truth!

3c - Bruteforcing SSH

In the previous part, we effectively got a wordlist. We will use it to try and login to SSH using think as a username:

We got the password!

4 - Vertical PrivEsc

Right off the bat, the first try at manual enum got me this:

I also got lucky on how to use look :

We will save the private key of root@lookup to my kali in a file named root. We adjust its permission, and login to SSH using it:

Last updated