To perform all this techniques you can simply try them by typing "Invoke-Mimikatz" into your powershell terminal, you'll notice that even if you haven't imported Mimikatz it will detect that as malicious. But if the AMSI is off or you avoid it, it just will say that "it's not recognized as the name of a cmdlet", so you could say that you've bypassed the AMSI
The first and worst way to bypass AMSI is downgrading powershell version to 2.0.
Just execute this
powershell -version 2.0And now if you enter "Invoke-Mimikatz" it won't be flagged as malicious
¿Why is this method bad?
- Because a lot of scripts won't work with this version
You can use simple obfuscation like summing strings like this:
"In"+"vo"+"ke"+"-M"+"im"+"ik"+"at"+"z"And it also won't be detected
Here down you have a script which adds a "patch" in memory and deactivate the AMSI
The script hooks the AmsiScanBuffer() function to always return "no malware". Just execute it and it should work
With this:
$a='si';$b='Am';$Ref=[Ref].Assembly.GetType(('System.Management.Automation.{0}{1}Utils'-f $b,$a)); $z=$Ref.GetField(('am{0}InitFailed'-f$a),'NonPublic,Static');$z.SetValue($null,$true)You can deactivate the AMSI on the go without downloading any extra files (best technique)
https://www.hackingarticles.in/a-detailed-guide-on-amsi-bypass/
by D3Ext