Postgres

Basics

postgres
su postgres  .. to get into his shell account
psql         .. to login to sql

Navigate the database:

\list     .... list the databases
\c [DB]   .... to select the database [DATABASE]
\d        .... to list the tables

select * from users;

File Traverse

  • You can read a file from psql, that you normally wouldnt be allowed!

CREATE TABLE demo(t text);
COPY demo from '[/var/lib/postgresql/9.4/key.txt]';
SELECT * FROM demo;

Find Creds

/var/www
cat /var/www/classes/db.php

dbname=photoblog 
user=photoblog 
password=photoblog
>> psql -U photoblog

Last updated