具有读写权限而且目标文件为可读内容html
目标内容具备完整路径且目录可访问mysql
目标内容是否具有文件读写操做权限git
查看是否有文件读写权限github
show variables like '%secure%';
secure_file_priv
绝对文件读取的功能sql
null
:不容许任何导入导出数据库
./[url]
:导入/导出操做只能够在./[url]路径下进行服务器 ` `:空内容;导入导出无限制性能
在my.ini文件中,修改
secure_file_priv
属性值能够修改导入导出权限网站
确保具有文件导入导出权限后便可进行文件读写操做~~~url
数据库表读取文件中的内容并保存~
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_prive
s受权表,保存表列的权限信息
提供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网站破解)
**成功解出密码……^_^!**