privilege escalation

Listing passwd file

unifi@unified:/usr/lib/unifi$ whoami
whoami
unifi
unifi@unified:/usr/lib/unifi$ cat /etc/passwd
cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
_apt:x:100:65534::/nonexistent:/usr/sbin/nologin
unifi:x:999:999::/home/unifi:/bin/sh
mongodb:x:101:102::/var/lib/mongodb:/usr/sbin/nologin

We can see that there is mangodb user. This means that there is mangodb is running in backend.

We can see that basic SUID is set.

Try to connect to MongoDB locally.

It is not getting connected.

I noticed that the port number is different.

Got the connection.

triangle-exclamation

Now I will search in mangoDB.

I will now switch to ace database.

Now I will list collections [Table] in this DB.

Now, we can select the collection name and see its content using the below command:

I found an encoded administrator password along with other users' passwords.

Store these hashes in a file named hashes.txt

Type of hash, I found example hashes in the hashcat website.

It is taking lot of time in cracking.

I will update the password of administrator account using my custom password.

circle-info

Add mkpasswd command tool in cheat sheet tool.

TO make custom password hash I will use mkpasswd tool. I know the type of hash from hashcat site. it is "sha512crypt $6$, SHA512 (Unix) 2"

Now I will update the value of "x_shadow" of administrator using mandoDB console.

Go to login page and enter username as "Administrator" and password as "Password@123".

Then login.

Logged in as administrator.

When we got to setting then to site. We can see root password in clear text form.

I will ssh to root user.

Got access as root user.

Last updated

Was this helpful?