Skip to content

Conversation

@h00die
Copy link
Contributor

@h00die h00die commented Jan 3, 2026

fixes #20828 by adding a new persistence technique via windows telemetry.

Verification

  1. Start msfconsole
  2. Get an admin level shell on windows
  3. Do: use exploit/windows/persistence/telemetry
  4. Do: set session #
  5. Do: run
  6. You should get a shell when the scheduled task runs.


def writable_dir
d = super
return session.sys.config.getenv(d) if d.start_with?('%')
Copy link
Contributor

Choose a reason for hiding this comment

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

not a blocker: Might be a pattern we could consolidate on behind the scenes in the library code

Copy link
Contributor

Choose a reason for hiding this comment

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

Potentially we'll need expand_path if this needs to handle the scenario of %TMP%/some/path

Did this scenario come up in your real user testing? 👀


def writable_dir
d = super
return session.sys.config.getenv(d) if d.start_with?('%')
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 need any additional guard clause to ensure this isn't calling session.sys on non-meterpreter sessions, or potentially the core post file mixin that has the expand path method available 🤞

vprint_status("Checking registry write access to: #{regkey}\\#{rand}")
return Msf::Exploit::CheckCode::Safe("Unable to write to registry path #{regkey}\\#{rand}") if registry_createkey("#{regkey}\\#{rand}").nil?

registry_deletekey("#{regkey}\\#{rand}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be popped into an ensure block to make sure it's cleaned up afterwards (with a rescue wrapper) 👀

    Msf::Exploit::CheckCode::Vulnerable('Registry writable')
  ensure
    begin
      registry_deletekey("#{regkey}\\#{rand}")
    rescue
      vprint ... etc ..
    end
  end

' or CompatTelRunner.exe (user)'
print_line(" or wait till #{@next_run_time} (SYSTEM)")

@clean_up_rc = %(execute -f cmd.exe -a "/c reg delete \\\"#{regkey}\\#{telemetry}\\\" /f" -H\n)
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: Do we need to handle the scenario of clean_up_rc already having values in it?

@clean_up_rc ||= +""
@clean_up_rc << %(execute -f cmd.exe -a "/c reg delete \\\"#{regkey}\\#{telemetry}\\\" /f" -H\n)

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.

New Persistence Technique: Windows Telemetry

2 participants