
show variables like '%secure%'; 
secure_file_priv绝对文件读取的功能 null:不允许任何导入导出 ./[url]:导入/导出操作只可以在./[url]路径下进行 :空内容;导入导出无限制 在my.ini文件中,修改secure_file_priv属性值可以修改导入导出权限
确保具备文件导入导出权限后即可进行文件读写操作~~~
数据库表读取文件中的内容并保存~
load_file(<[./url/]file>);load_file 在指定的目录下创建文件
首先我们需要在/var/lib/mysql-files/创建一个文件user.txt $ vi /var/lib/mysql-files/user.txt user.txt: Hello,World!
create table file(
id int not null auto_increment primary key,
file_url text
)engine=innodb default charset=utf8; -- 创建表file
insert into file(file_url) values (load_file('/var/lib/mysql-files/user.txt'));mysql> select * from file;
+----+---------------+
| id | file_url |
+----+---------------+
| 1 | NULL |
| 2 | Hello,World! |
+----+---------------+
2 rows in set (0.00 sec)文件中的数据内容就这样写入了数据表中!
load data infile '/var/lib/mysql-files/name.txt' into table file(file_url);mysql> mysql> select * from file;
+----+---------------+
| id | file_url |
+----+---------------+
| 1 | NULL |
| 2 | Hello,World! |
| 3 | Hello,World! |
+----+---------------+
3 rows in set (0.00 sec)我们可以通过前期的渗透手段和分析得知目标网站某处存在SQL注入漏洞;于是我们就可以利用SQL的文件读取的特性来读取目标系统中的某个文件的内容
MySQL在刚刚初始化后,默认有三个系统默认库:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)这些事MySQL数据库自带的三个基本的系统库
information_schema: 其中保存有MYSQL所维护的所有数据库信息,包括库名、表名、表列、权限……等信息 performance_schema: 用于收集数据库服务器的性能参数 mysql:s 保留mysql的账户信息、权限、存储过程、event、时区等配置信息
information_schema 库通常保存由数据库的元数据:
数据库名,表名,列的属性、类型、访问权限等等……
在information_schema库中有许多重要的系统表,可以为渗透过程中提供帮助!
提供了当前MySQL所有库的信息,show databases;的结果就是据此而显示~
information_schema.tables 表中提供了表的详细信息
select <列名> from information_schema.tables;table表中主要记录了数据库中所有表的元数据,例如表名、类型、引擎……
在渗透过程中,如果我们掌握到这张表就可以掌握数据库的大概的表

information_schema.COLUMNS表中提供了表中字段信息
select COLUMN_NAME,DATA_TYPE,IS_NULLABLE,COLUMN_DEFAULT
from information_schema.COLUMNS
where table_name = 'user';查询user表中的字段名信息

information_statistics表中提供表的索引信息内容
信息源自于mysql.user授权表;里面保存着数据库每个账户具备的权限信息
信息源自于mysql.db授权表,保存着数据库的权限的信息
信息源自于mysql.tables_prive授权表,保存所有表信息的权限
信息源自于mysql.columns_prives授权表,保存表列的权限信息
提供mysql所有相关的字符集信息
*在SQL注入中union联合注入是最为常见的

普遍的情况下,使用union语句实现联合注入(回显注入)……
' union <SQL语句>; # 现在简单的举例几条SQL语句实现核心的条件查询
select 1 , database();select schema_nam from information_schema.schemata;select table_name from information_schema.tables where table_schema = "<databases_name>";select columns_name from information_schema.columns where table_name = "<tables_name>";顺带一提~SQL盲注
上面说的SQL注入是基于页面有“回显”的注入(回显注入)
如果页面没有回显,那么就需要进行“盲注入”
select user,password from mysql.user;
推荐神器:hashcat
推荐网站:CMD5(本例使用CMD5网站破解)

成功解出密码……_!