|
|
Регистрация Восстановить пароль |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
|
Опции темы | Поиск в этой теме |
02.11.2012, 17:54 | #1 |
Новичок
Джуниор
Регистрация: 02.11.2012
Сообщений: 1
|
Исправте код C#
Вот код для переделки dll в exe и его инжектирования
Код HTML:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; using System.Diagnostics.Process; using System.Runtime.InteropServices; using System.Diagnostics; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { string dll_name = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache) + "\\fgghrr.dll"; FileStream fs = new FileStream(dll_name, FileMode.Create); fs.Write(Properties.Resources.WallHack, 0, Properties.Resources.WallHack.Length); fs.Close(); } [DllImport("kernel32.dll")] public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId); public static bool InjectDLL(Process process, String strDLLName) { IntPtr hProcess = OpenProcess(ProcessAccessFlags.All, false, process.Id); if (hProcess == null) { return false; } IntPtr bytesout; // Length of string containing the DLL file name +1 byte padding Int32 LenWrite = strDLLName.Length + 1; // Allocate memory within the virtual address space of the target process IntPtr AllocMem = (IntPtr)VirtualAllocEx(hProcess, (IntPtr)null, (uint)LenWrite, 0x3000, (uint)Protection.PAGE_READWRITE); //allocation pour WriteProcessMemory uint tmp; VirtualProtect(AllocMem, (uint)LenWrite, (uint)Protection.PAGE_READWRITE, out tmp); // Write DLL file name to allocated memory in target process WriteProcessMemory(hProcess, AllocMem, strDLLName, (UIntPtr)LenWrite, out bytesout); // Function pointer "Injector" UIntPtr Injector = (UIntPtr)GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA"); if (Injector == null) { MessageBox.Show(" Injector Error! \n "); // return failed return false; } // Create thread in target process, and store handle in hThread UIntPtr tmpptr; IntPtr hThread = (IntPtr)CreateRemoteThread(hProcess, (IntPtr)null, 0, Injector, AllocMem, 0, out tmpptr); // Make sure thread handle is valid if (hThread == null) { //incorrect thread handle ... return failed // MessageBox.Show(" hThread [ 1 ] Error! \n "); return false; } // Time-out is 10 seconds... int Result = WaitForSingleObject(hThread, 3000); // Check whether thread timed out... if (Result == 0x00000080L || Result == 0x00000102L || Result == 0xFFFFFFFF) { /* Thread timed out... */ // MessageBox.Show(" hThread [ 2 ] Error! \n "); // Make sure thread handle is valid before closing... prevents crashes. if (hThread != null) { //Close thread in target process CloseHandle(hThread); } return false; } // Sleep thread for 1 second System.Threading.Thread.Sleep(100); // Clear up allocated space ( Allocmem ) VirtualFreeEx(hProcess, AllocMem, (UIntPtr)0, 0x8000); // Make sure thread handle is valid before closing... prevents crashes. if (hThread != null) { //Close thread in target process CloseHandle(hThread); } CloseHandle (hProcess); // return succeeded return true; } } } |
Похожие темы | ||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
исправте код | Screame | Microsoft Office Excel | 16 | 11.02.2016 23:30 |
исправте | 92Edik | Паскаль, Turbo Pascal, PascalABC.NET | 1 | 25.05.2011 08:47 |
Робота с файлами. Исправте код. | aerosm | Помощь студентам | 2 | 02.03.2011 18:05 |
исправте код( | basav1k | Помощь студентам | 1 | 20.05.2010 12:16 |