# 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
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pentest.mxhx.org/03-getting-in/postgres.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
