-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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 adapted payload stage encoding #17721
Conversation
Excellent! Thank you - this will pay dividends when we upstream w^x stagers as stage encoding needs RWX which doesn't play well there. Should also let me clean up the RC4 x86 hackery - register pressure requires X on the memory region being decrypted whereas x64 handles decryption just fine with RW. |
Old and busted:
New and improved:
More testing:
|
Release NotesThis fixes an issue where payloads that were adapted failed when stage encoding was enabled because the stage encoding was based on the stager arch and platform values. These values were always the same until we introduced adapted payloads, which can vary. |
This fixes issue #17720 where payloads that were adapted were failing when stage encoding was enabled. This was due to the stage encoding assuming that the stage arch+platform were the same as the payload / stager. The adapters break this assumption by allowing them to be different values.
This update modifies the Stager mixin to use the new
stage_arch
andstage_platform
values for determining compatible encoders. These new attributes default to the payload values but are set to the adapted values by adapted payloads. This ensures that the stage is able to be encoded correctly by properly selecting a compatible encoder. TheEncodedPayload
class was also updated to allow an explicitArch
andPlatform
to be specified which is used by the stager to pass the stage information for use instead of the original payloads.This also updates the Windows shell stage to honor the
EnableStageEncoding
option by not overridingenable_stage?
. Instead theEnableStageEncoding
option is set as a default value since it makes sense but this way users can still turn it off if they'd like.Verification
Start msfconsole and try payloads in staged and unstaged configurations that are both adapted and not adapted.
run TARGET=Command PAYLOAD=cmd/windows/powershell/shell/reverse_tcp EnableStageEncoding=true
run TARGET=Command PAYLOAD=cmd/windows/powershell/shell/reverse_tcp EnableStageEncoding=false
run TARGET=Command PAYLOAD=cmd/windows/powershell/shell_reverse_tcp
run TARGET=Automatic PAYLOAD=windows/x64/meterpreter/reverse_tcp EnableStageEncoding=true