Integrate PowerShell Protections Bypass #17
Rex::Powershell has functionality to compose PowerShell code into Script objects using basic lexical parsing to identify functions, variables, etc. This functionality is intended to permit/leverage composition by consumers for maximum entropy. Concurrently, script modifiers are in place to clean up multiline blocks, replace names, and perform other obfuscation. Strip out the built-in uses of the new AMSI and log bypass methods. Remove textual cleanup to allow Rex to handle this as needed.
Passing the :prepend_protections_bypass to cmd_psh_payload will prepend the Ruby blocks for AMSI and log bypass to the payload text. The subsequent compression and encoding passes will perform the same textual substitution stripping out whitespace and may also substitute the hardcoded variable names if requested. This approach keeps string lengths predictable while permitting use of the evasion functionality. Not so much an issue for a full PSH payload, but can be handy when dealing with limited space (HID attacks, manual retyping over GUIs, etc).
I didn't expect the
empire includes https://github.com/danielbohannon/Invoke-Obfuscation but depends on PowerShell and that means adding it as optional? dependency or embedding it directly within the project with a ~50mb overhead of stuff.
writing a simpler, similar project in ruby may be an overkill.