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

Add windows memory search support #18585

Closed

Conversation

sjanusz-r7
Copy link
Contributor

@sjanusz-r7 sjanusz-r7 commented Nov 29, 2023

This PR is needed to correctly support null-bytes in the Windows memory search implementation using regex. The PR for that functionality is here: rapid7/metasploit-payloads#686
By explicitly specifying the needle length, the needle can contain null bytes (to support searching for wide chars, e.g. "\x41\x00") and they will not be treated as the end of the string. The same approach was used to search over null bytes in the memory buffers.

Verification

  • Start msfconsole
  • Read memory using a needle such as "publickey,password\x00.*" or "p\x00u\x00b\x00{more_bytes_here}"
  • Confirm the response contains the correct TLV result value
  • Confirm that Mettle isn't broken by these changes

needles.each { | needle | request.add_tlv(TLV_TYPE_MEMORY_SEARCH_NEEDLE, needle) }
needles.each do | needle |
request.add_tlv(TLV_TYPE_MEMORY_SEARCH_NEEDLE, needle)
request.add_tlv(TLV_TYPE_MEMORY_SEARCH_NEEDLE_LEN, needle.bytesize)
Copy link
Contributor

@adfoster-r7 adfoster-r7 Nov 30, 2023

Choose a reason for hiding this comment

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

It seems odd that we need this additional information, when the length value is already baked into the TLV itself (Type Length Value)

I wonder if this is being added as a workaround for your current Meterpreter implementation? 🤔

@sjanusz-r7
Copy link
Contributor Author

Closing this in favour of the approach specified in the above comment 👍

@sjanusz-r7 sjanusz-r7 closed this Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants