Poster

Date: 16, June, 2021

Author: Dhilip Sanjay S


Click Herearrow-up-right to go to the TryHackMe room.

Introduction

  • Depending on the EF Codd relational model, an RDBMS allows users to build, update, manage, and interact with a relational database, which stores data as a table.

  • Relational database can handle a wide range of data formats and process queries efficiently.

  • Most commercially available RDBMSs currently use Structured Query Language (SQL) to access the database.

  • RDBMS structures are most commonly used to perform CRUD operations (create, read, update, and delete), which are critical to support consistent data management.


Enumeration

Nmap Scan

$ nmap -sC -sV 10.10.181.37 -p- -oN nmap.out
Starting Nmap 7.91 ( https://nmap.org ) at 2021-06-16 14:54 IST
Nmap scan report for 10.10.181.37
Host is up (0.15s latency).
Not shown: 65532 closed ports
PORT     STATE SERVICE    VERSION
22/tcp   open  ssh        OpenSSH 7.2p2 Ubuntu 4ubuntu2.10 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 71:ed:48:af:29:9e:30:c1:b6:1d:ff:b0:24:cc:6d:cb (RSA)
|   256 eb:3a:a3:4e:6f:10:00:ab:ef:fc:c5:2b:0e:db:40:57 (ECDSA)
|_  256 3e:41:42:35:38:05:d3:92:eb:49:39:c6:e3:ee:78:de (ED25519)
80/tcp   open  http       Apache httpd 2.4.18 ((Ubuntu))
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: Poster CMS
5432/tcp open  postgresql PostgreSQL DB 9.5.8 - 9.5.10 or 9.5.17 - 9.5.21
| ssl-cert: Subject: commonName=ubuntu
| Not valid before: 2020-07-29T00:54:25
|_Not valid after:  2030-07-27T00:54:25
|_ssl-date: TLS randomness does not represent time
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 619.08 seconds
Poster Home

What is the rdbms installed on the server?

  • Answer: postgresql

What port is the rdbms running on?

  • Answer: 5432


Metasploit

  • Metasploit contains a variety of modules that can be used to enumerate in multiple rdbms, making it easy to gather valuable information.

After starting Metasploit, search for an associated auxiliary module that allows us to enumerate user credentials. What is the full path of the modules (starting with auxiliary)?

  • Answer: auxiliary/scanner/postgres/postgres_login

  • Steps to Reproduce: Search for Postgres

What are the credentials you found?

  • Answer: postgres:password

  • Steps to Reproduce:


What is the full path of the module that allows you to execute commands with the proper user credentials (starting with auxiliary)?

  • Answer: auxiliary/admin/postgres/postgres_sql

  • Steps to Reproduce: Search for Postgres

Based on the results of #6, what is the rdbms version installed on the server?

  • Answer: 9.5.21

  • Steps to Reproduce:


What is the full path of the module that allows for dumping user hashes (starting with auxiliary)?

  • Answer: auxiliary/scanner/postgres/postgres_hashdump

  • Steps to Reproduce: Search for postgres

How many user hashes does the module dump?

  • Answer: 6

  • Steps to Reproduce:


What is the full path of the module (starting with auxiliary) that allows an authenticated user to view files of their choosing on the server?

  • Answer: auxiliary/admin/postgres/postgres_readfile

What is the full path of the module that allows arbitrary command execution with the proper user credentials (starting with exploit)?

  • Answer: exploit/multi/postgres/postgres_copy_from_program_cmd_exec


Initial Access


Dark User

  • To read the user.txt, we need have access as alison

  • By searching through the file system, find a configuration file:


Alison user

  • Switch to alison to get access to user.txt


Privilege Escalation

  • Alison can run any command as any user!

  • So switch to root user and read root.txt:


Last updated