type
status
date
slug
summary
tags
category
icon
password
Catagory
Materials
Retired
Retired
Due date
Jan 16, 2024 05:30 AM
Status
Belong in
Background
UDF
UDF(User Defined Function),使用者可以自訂函數並讓mysql透過載入的方式來呼叫函數。
利用條件
- mysql允許導入導出檔案 ⇒ 找current_user() file_priv
- 高權限帳號需要有對資料庫table有insert和delete權限,為了要將payload先匯進table中
- 未
--skip-grand-tables
開啟的狀況下udf並不會被import
- mysql 5.1以上的版本,必須要把udf.dll或udf.so文件放在mysql plugin目錄下面才有辦法import函數並呼叫他 ⇒ 要找plugin路徑
Progress
判斷columns
枚舉資料庫版本及當前連線的資料庫名稱
枚舉當前使用者
枚舉os version及 architecture
枚舉data directory path
枚舉plugin directory path
確認當前使用者權限
File_Priv
确定用户是否可以执行SELECT INTO OUTFILE和LOAD DATA INFILE命令
Plugin
plugin值表示mysql用户的认证方式。当 plugin 的值为空时不可提权,为mysql_native_password
时可通过账户连接提权。默认为mysql_native_password
。另外,mysql用户还需对此plugin目录具有写权限。
secure_file_priv
secure_file_priv是用来限制load dumpfile、into outfile、load_file() 函数在哪个目录下拥有上传或者读取文件的权限。当 secure_file_priv 的值为 null ,表示限制 mysqld 不允许导入|导出,此时无法提权 当 secure_file_priv 的值为 /tmp/ ,表示限制 mysqld 的导入|导出只能发生在 /tmp/ 目录下,此时也无法提权 当 secure_file_priv 的值没有具体值时,表示不对 mysqld 的导入|导出做限制,此时可提权
Load_file()
Reference
- 作者:ji3g4gp
- 連結:https://gpblog.vercel.app//article/SQLi-mysql-UDF-RCE
- 著作權:本文採用 CC BY-NC-SA 4.0 許可協議,轉載請註明出處。