Advertisement
Guest User

Untitled

a guest
May 26th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.02 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Diagnostics;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Runtime.InteropServices;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12.  
  13. namespace BadInjector
  14. {
  15. public partial class Form1 : Form
  16. {
  17. [DllImport("kernel32.dll")]
  18. public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
  19.  
  20. [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
  21. public static extern IntPtr GetModuleHandle(string lpModuleName);
  22.  
  23. [DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
  24. static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
  25.  
  26. [DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
  27. static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress,
  28. uint dwSize, uint flAllocationType, uint flProtect);
  29.  
  30. [DllImport("kernel32.dll", SetLastError = true)]
  31. static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, uint nSize, out UIntPtr lpNumberOfBytesWritten);
  32.  
  33. [DllImport("kernel32.dll")]
  34. static extern IntPtr CreateRemoteThread(IntPtr hProcess,
  35. IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId);
  36.  
  37.  
  38. const uint MEM_COMMIT = 0x00001000;
  39. const uint PAGE_READWRITE = 4;
  40. const uint MEM_RESERVE = 0x00002000;
  41.  
  42. const int PROCESS_CREATE_THREAD = 0x0002;
  43. const int PROCESS_VM_READ = 0x0010;
  44. const int PROCESS_QUERY_INFORMATION = 0x0400;
  45. const int PROCESS_VM_WRITE = 0x0020;
  46. const int PROCESS_VM_OPERATION = 0x0008;
  47. public Form1()
  48. {
  49. InitializeComponent();
  50. }
  51.  
  52. public void bunifuThinButton21_Click(object sender, EventArgs e)
  53. {
  54. Textbox1.Visible = false;
  55. Dropdown1.Visible = false;
  56. Button1.Visible = false;
  57. Label1.Visible = true;
  58. button2.Visible = true;
  59. button3.Visible = true;
  60. }
  61.  
  62. private void button2_Click(object sender, EventArgs e)
  63. {
  64. Textbox1.Visible = true;
  65. Dropdown1.Visible = true;
  66. Button1.Visible = true;
  67. Label1.Visible = false;
  68. button2.Visible = false;
  69. button3.Visible = false;
  70. if (Dropdown1.selectedValue == "FiveM")
  71. {
  72. label2.Text = "FiveM";
  73. }
  74. Process targetProcess = Process.GetProcessesByName(label2.Text)[0];
  75.  
  76. IntPtr procHandle = OpenProcess(PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ, false, targetProcess.Id);
  77.  
  78. IntPtr loadLibraryAddr = GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA");
  79.  
  80. string where = AppDomain.CurrentDomain.BaseDirectory;
  81.  
  82. string dllName = Textbox1.Text;
  83.  
  84. IntPtr allocMemAddress = VirtualAllocEx(procHandle, IntPtr.Zero, (uint)((dllName.Length + 1) * Marshal.SizeOf(typeof(char))), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
  85.  
  86. UIntPtr bytesWritten;
  87. WriteProcessMemory(procHandle, allocMemAddress, Encoding.Default.GetBytes(dllName), (uint)((dllName.Length + 1) * Marshal.SizeOf(typeof(char))), out bytesWritten);
  88.  
  89. CreateRemoteThread(procHandle, IntPtr.Zero, 0, loadLibraryAddr, allocMemAddress, 0, IntPtr.Zero);
  90.  
  91. MessageBox.Show("Injected");
  92. }
  93.  
  94. private void button3_Click(object sender, EventArgs e)
  95. {
  96. Textbox1.Visible = true;
  97. Dropdown1.Visible = true;
  98. Button1.Visible = true;
  99. Label1.Visible = false;
  100. button2.Visible = false;
  101. button3.Visible = false;
  102. }
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement