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

exploits: Set tftphost option for modules which use Windows TFTP stager #16727

Merged
merged 1 commit into from
Jul 12, 2022

Conversation

bcoles
Copy link
Contributor

@bcoles bcoles commented Jun 29, 2022

Windows exploit modules which use the TFTP command stager require a tftphost option to be set (rapid7/rex-exploitation#34 rapid7/rex-exploitation#31).

This PR adds this option to the following modules (all modules which force set 'CmdStagerFlavor' => 'tftp'):

  • modules/exploits/multi/http/struts_code_exec_exception_delegator.rb
  • modules/exploits/multi/http/struts_code_exec.rb
  • modules/exploits/windows/antivirus/ams_xfr.rb
  • modules/exploits/windows/http/ca_totaldefense_regeneratereports.rb
  • modules/exploits/windows/http/osb_uname_jlist.rb
  • modules/exploits/windows/iis/msadc.rb
  • modules/exploits/windows/misc/altiris_ds_sqli.rb
  • modules/exploits/windows/mssql/mssql_payload.rb

It does not patch modules/exploits/windows/iis/ms01_026_dbldecode.rb as this is addressed in #16724.

Note: Many of these modules likely won't work for other reasons (such as using a Meterpreter payload by default). Fixing the TFTP stager means at least one less thing is broken. set HttpTrace true can be used to show the before and after effect of this patch.

print_status("Sending request to #{datastore['RHOST']}:#{datastore['RPORT']}")
execute_cmdstager({ :temp => '.', :cgifname => exe_fname })
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cgifname does nothing. It is copy pasta from a couple of other Windows modules developed around the same time and use a similar code pattern. It has been removed.

@@ -344,7 +344,8 @@ def exploit
res = exec_cmd(y, "cmd /c copy cmd.exe \\inetpub\\scripts\\#{exe_fname}", z)

# Use the CMD stager to get a payload running
execute_cmdstager({ :temp => '.', :linemax => 1400, :cgifname => exe_fname })
tftphost = (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address : datastore['SRVHOST']
execute_cmdstager({ temp: '.', tftphost: tftphost, linemax: 1_400, cgifname: exe_fname, noconcat: true })
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This module, like ms01_026_dbldecode, expects the TFTP command stager to generate commands without concatenation as it needs to strip the start command. This is the default behavior for the stager; however, it won't be the default once rapid7/rex-exploitation#34 is merged. Thus noconcat was added.

@space-r7 space-r7 self-assigned this Jul 8, 2022
@space-r7 space-r7 merged commit ccef129 into rapid7:master Jul 12, 2022
@space-r7
Copy link
Contributor

Release Notes

Modules that use the tftp command stager fail due to a missing tftphost option. This ensures that the tftphost host is set and valid before proceeding with creating the command stager.

@space-r7 space-r7 added rn-fix release notes fix labels Jul 12, 2022
@bcoles bcoles deleted the exploit-tftp-cmdstager-tftphost branch July 13, 2022 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug module rn-fix release notes fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants