HTB: Lightweight

May 11, 2019
2 min read
By pir4cy
HTBWriteupEasyMediumLinuxWeb

LightWeight

Info

  • IP : 10.10.10.119
  • OS : Linux
  • Diffculty: Easy/Medium

System Enumeration

NMAP

Nmap

Web App Enumeration

front page

user.php

user.php

status.php

status.php

So we see that we can log in to the box using our IP and SSH.
After logging in, there was nothing special to look for in the box, so I tried a tcpdump.
tcpdump -i lo -vv -nn -w capture.pcap

tcpdump

We see traffic being captured, when we open http://10.10.10.119/status.php

Using scp to transfer the captured pcap file to my local pc, I opened it up in wiresharkhttps://gist.github.com/bcoles/421cc413d07cd9ba7855

WireShark

Since, we know that this machine is related to LDAP, I directly checked the .pcap file for any LDAP requests and luckily enough

ldapcheck
Looking further, we find a possible authentication hash for ldapuser2
ldapuser2

User Exposed

Elevating to ldapuser2 using su and the hash as password, we log in easily. Thus, exposing user.txt

User found

Backup.7z

In the home folder of ldapuser2, there's a 7zip file named backup, which means it might contain some information for us.

Downloading the file and extracting it.
Backup.7z Denied

So it's locked and we have to decrypt it.
I found a simple and straightforward script on github to do the job for me.(https://gist.github.com/bcoles/421cc413d07cd9ba7855)

Backup PW Found

We got new files! Let's check them out.

Status.php

So, the status.php file reveals some more information to us

status reveal

Going for Root

We now have both the passwords for ldapuser1 and ldapuser2, but still no root access or root.txt

General Enumeration

SysInfo

SUID Info

Linux Capabilities

Since, there was nothing peculiar I checked for linux capabilities using getcap -r / 2>/dev/null
It seems openssl has empty capabilities, that means we can use it to access any file.

Linux Capabilities

So there are 2 ways we can go about this:

  • Get root.txt
  • Get root shell by changing sudoers

Getting root.txt

root.txt

Changing Sudoers

So we create our own sudoers using ./openssl enc -in "/etc/sudoers" -out sudoers

Editing this sudoers file to:
Sudoers

Changing the original sudoers file and getting root shell.

Rooted

Thank you for following!

Comments