Skip to content

Conversation

@h00die
Copy link
Contributor

@h00die h00die commented Nov 19, 2025

Updates the windows wmi persistence to the new mixin. The original persistence worked in several different and very cool ways, and I felt it would be best to split them out instead of complicating the datastore based on which technique was chosen. Part of #20374

@NickTyrer not sure if you are still around, but I love this module, its stealthy, the module was well written and easy to follow. Props from future!

As noted in the files:
wmic will be removed Windows 11, version 25H2 or Windows 11, version 24H2 in favor of powershell
source https://support.microsoft.com/en-us/topic/windows-management-instrumentation-command-line-wmic-removal-from-windows-e9e83c7f-4992-477f-ba1d-96f694b8665d

To Do:

Finish testing each module (only event_log is done)
Write docs
Make cleanup work (currently failing)

Verification

  • Start msfconsole
  • exploit the box somehow
  • use exploit/windows/persistence/wmi/<select a module>
  • set SESSION <id>
  • exploit
  • Verify persistence is created, and you get a new session if apt is run
  • Verify cleanup works
  • Document is updated and correct

# @clean_up_rc << "execute -H -f wmic -a \"/NAMESPACE:\\\"\\\\\\\\root\\\\subscription\\\" PATH CommandLineEventConsumer WHERE Name=\\\"#{name_class}\\\" DELETE\"\n"
# @clean_up_rc << "execute -H -f wmic -a \"/NAMESPACE:\\\"\\\\\\\\root\\\\subscription\\\" PATH __FilterToConsumerBinding WHERE Filter='__EventFilter.Name=\\\"#{name_class}\\\"' DELETE\""
name_class = datastore['CLASSNAME']
@clean_up_rc << "execute -H -f powershell -a \"Get-WmiObject -Namespace 'root\\subscription' -Query \\\"SELECT * FROM __EventFilter WHERE Name='Telemetrics'\\\" | ForEach-Object { $_.Delete() }\"\n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we write @clean_up_rc to disk automatically? The original module used:

    file_local_write(clean_rc, clean_up_rc)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, the mixin handles writing it to disk and printing the statement about it

@NickTyrer
Copy link
Contributor

Thanks for the kind words and updating the module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants