精易论坛
标题:
C# HOOK / DLL Inject(注入)
[打印本页]
作者:
stillness
时间:
2015-6-7 17:10
标题:
C# HOOK / DLL Inject(注入)
原帖子:http://blog.csdn.net/u012395622/article/details/46401877
满屏幕都是“你好,你已被注入”是不是感到很好玩呢?
HOOK注入不是一个新技术 但是呢 有时候你还真
需要求助它 虽然我一般注入不使用HOOK方式但它却是最简便的一个方式 下面我就来介绍一下代码吧
首先我们使用一个可以编写标准Win32 DLL的语言(C++/E/Delphi)等。
下面为C++的一个示例代码:
这里只是娱乐的说说它还没有真正的注入 但是你可以在这里编写自己的DLL注入代码
[cpp]
view plain
copy
print
?
#include "stdafx.h"
extern "C" __declspec(dllexport) void Inject()
{
MessageBox(NULL, TEXT("你好,你已被注入"), NULL, MB_ICONINFORMATION);
}
#include "stdafx.h"extern "C" __declspec(dllexport) void Inject(){ MessageBox(NULL, TEXT("你好,你已被注入"), NULL, MB_ICONINFORMATION);}C#怎么写 我想你看见代码的时候 一定会大吓一跳
[csharp]
view plain
copy
print
?
public const int WH_GETMESSAGE = 3;
[DllImport("User32.dll", CharSet = CharSet.Auto)]
public extern static void UnhookWindowsHookEx(int handle);
[DllImport("User32.dll", CharSet = CharSet.Auto)]
public extern static int SetWindowsHookEx(int idHook, int lpfn, int hinstance, int threadID);
[DllImport("kernel32.dll", SetLastError = true)]
public extern static int LoadLibraryA(string lpLibFileName);
[DllImport("kernel32.dll", SetLastError = true)]
public extern static int FreeLibrary(int hModule);
[DllImport("kernel32.dll", SetLastError = true)]
public extern static int GetProcAddress(int hModule, string lpProcName);
private void Form1_Load(object sender, EventArgs e)
{
// base.Text = Process.GetCurrentProcess().Id.ToString();
int hModule = LoadLibraryA("dlltest.dll");
int lpMethod = GetProcAddress(hModule, "Inject");
int hHook = SetWindowsHookEx(WH_GETMESSAGE, lpMethod, hModule, 0);
}
感到简单是不是 嘿嘿 不过也只限HOOK方式了 如果换成另一种方式那会麻烦很
首先你需要操作令牌提权 然后再写对方进程的内存 在远程调用导入DLL函数 麻烦
作者:
一夜白头
时间:
2015-6-7 17:21
{:soso_e100:}转载的半精华篇目,不错不错
欢迎光临 精易论坛 (https://125.confly.eu.org/)
Powered by Discuz! X3.4