Network - Privesc, Port Scanner and NTLM chanllenge response disclosure
Last updated
Last updated
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Find more information about these attacks in the original paper.
Since PostgreSQL 9.1, installation of additional modules is simple. Registered extensions like dblink
can be installed with CREATE EXTENSION
:
Once you have dblink loaded you could be able to perform some interesting tricks:
The file pg_hba.conf
could be bad configured allowing connections from localhost as any user without needing to know the password. This file could be typically found in /etc/postgresql/12/main/pg_hba.conf
and a bad configuration looks like:
Note that this configuration is commonly used to modify the password of a db user when the admin forget it, so sometimes you may find it. Note also that the file pg_hba.conf is readable only by postgres user and group and writable only by postgres user.
This case is useful if you already have a shell inside the victim as it will allow you to connect to postgresql database.
Another possible misconfiguration consist on something like this:
As it will allow everybody from the localhost to connect to the database as any user.
In this case and if the dblink
function is working, you could escalate privileges by connecting to the database through an already established connection and access data shouldn't be able to access:
Abusing dblink_connect
you could also search open ports. If that **function doesn't work you should try to use dblink_connect_u()
as the documentation says that dblink_connect_u()
is identical to dblink_connect()
, except that it will allow non-superusers to connect using any authentication method_.
Note that before being able to use dblink_connect
or dblink_connect_u
you may need to execute:
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)