Closed molecula2788 closed 8 months ago
That's an interesting edgecase; Would you be able to put up a PR to fix that?
It might be better to fix the powershell obfuscation library to be case insensitive, but I'm not sure what edgecases there might be there if we make that change - so it might require a quick investigation. Alternatively - potentially updating the powershell script to have consistent casing would work too as an interim solution 👍
Yes, I'll come up with a PR as soon as possible.
Steps to reproduce
Expected behavior
On the victim machine, WMI
__EventFilter
,CommandLineEventConsumer
, and__FilterToConsumerBinding
objects should be created.Current behavior
The
__FilterToConsumerBinding
object is not created.Metasploit version
v6.3.56-dev
Additional Information
The script that will be executed comes from
metasploit-framework/embedded/framework/modules/exploits/windows/local/wmi_persistence.rb
:The actual powershell that gets executed looks like this:
Notice that the arguments for
__FilterToConsumerBinding
areFilter = $qA
andConsumer = $p3H
, instead of$fmj
and$xYkTM
respectively. That's because in the original script there is an inconsistent casing:$filter
/$consumer
and$Filter
/$Consumer
. Then, the obfuscation functionsub_vars
inmetasploit-framework/embedded/lib/ruby/gems/3.0.0/gems/rex-powershell-0.1.99/lib/rex/powershell/obfu.rb
sees them as 2 separate variables, because it doesn't take the casing into account.