吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 2575|回复: 3
收起左侧

[C&C++ 转载] 普通的Dll注入 没啥技术含量 分享给不会注入的初学者 没保护的进程还是没问题的

  [复制链接]
古月不傲 发表于 2019-11-19 05:25
本帖最后由 古月不傲 于 2019-11-28 03:38 编辑

[C] 纯文本查看 复制代码
#include <Windows.h>

#define DLL TEXT("C:\\Users\\25335\\Desktop\\11111111111111.dll")
#define EXE_TITLE TEXT("TraceMe 动态分析技术")
#define DEBUG 1

HMODULE g_hModule = NULL;

HANDLE GetProcessHANDLE()
{
	HWND hWnd = NULL;
	DWORD dwThreadProcessId = 0;
	HANDLE hProcess = NULL;

	hWnd = FindWindow(NULL, EXE_TITLE);
	if (hWnd == NULL && DEBUG)
	{
		return NULL;
	}
	GetWindowThreadProcessId(hWnd, &dwThreadProcessId);
	hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwThreadProcessId);
	if (hProcess == NULL && DEBUG)
	{
		return NULL;
	}
	return hProcess;
}

VOID InjectDll()
{
	HANDLE hProcess = NULL;
	LPVOID lpBaseAddress = NULL;
	ULONG uWirteBytes = 0;
	BOOL bWirteProcessMemory = FALSE;
	DWORD dwThreadId = 0;
	HANDLE hThread = NULL;
	DWORD dwThreadExitCode = 0;
	hProcess = GetProcessHANDLE();
	
	lpBaseAddress = VirtualAllocEx(hProcess, NULL, 4096, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
	bWirteProcessMemory = WriteProcessMemory(hProcess, lpBaseAddress, DLL, MAX_PATH, &uWirteBytes);
	
	hThread = CreateRemoteThread(hProcess, NULL, NULL, (LPTHREAD_START_ROUTINE)LoadLibrary, lpBaseAddress, NULL, &dwThreadId);

	if (hThread == NULL && DEBUG)
	{
		return;
	}
	WaitForSingleObject(hThread, INFINITE);

	GetExitCodeThread(hThread, &dwThreadExitCode);
	//Remarks
	/*This function returns immediately. If the specified thread has not terminated and the function succeeds, the status returned is STILL_ACTIVE. 
	If the thread has terminated and the function succeeds, the status returned is one of the following values:

	The exit value specified in the ExitThread or TerminateThread function.
		The return value from the thread function.
		The exit value of the thread's process.
		*/
	g_hModule = (HMODULE)dwThreadExitCode;
	BOOL bRet = VirtualFreeEx(hProcess, lpBaseAddress, 4096, MEM_DECOMMIT);
	CloseHandle(hThread);
	CloseHandle(hProcess);
}

VOID FreeDll()
{
	HANDLE hProcess = NULL;
	LPVOID lpBaseAddress = NULL;
	ULONG uWirteBytes = 0;
	BOOL bWirteProcessMemory = FALSE;
	DWORD dwThreadId = 0;
	HANDLE hThread = NULL;
	DWORD dwThreadExitCode = 0;
	hProcess = GetProcessHANDLE();

	lpBaseAddress = VirtualAllocEx(hProcess, NULL, 4096, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
	bWirteProcessMemory = WriteProcessMemory(hProcess, lpBaseAddress, DLL, MAX_PATH, &uWirteBytes);

	hThread = CreateRemoteThread(hProcess, NULL, NULL, (LPTHREAD_START_ROUTINE)FreeLibrary, g_hModule, NULL, &dwThreadId);

	if (hThread == NULL && DEBUG)
	{
		return;
	}
	WaitForSingleObject(hThread, INFINITE);

	GetExitCodeThread(hThread, &dwThreadExitCode);
	BOOL bRet = VirtualFreeEx(hProcess, lpBaseAddress, 4096, MEM_DECOMMIT);
	CloseHandle(hThread);
	CloseHandle(hProcess);
}

int main(void)
{
	InjectDll();
	FreeDll();

	system("pause");
	return 0;
}

免费评分

参与人数 1吾爱币 +1 收起 理由
Tonyヾ + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

Tonyヾ 发表于 2019-11-20 02:13
意思就是当系统缺少DII打开这个会自动检测然后自动下载补齐对吗?
 楼主| 古月不傲 发表于 2019-11-20 07:55
Tonyヾ 发表于 2019-11-20 02:13
意思就是当系统缺少DII打开这个会自动检测然后自动下载补齐对吗?

就是被注入的这个进程会 直接LoadLibray你写进去的这个DLL
lpBaseAddress就是你写进去的Dll名字
Tonyヾ 发表于 2019-11-20 20:06
古月不傲 发表于 2019-11-20 07:55
就是被注入的这个进程会 直接LoadLibray你写进去的这个DLL
lpBaseAddress就是你写进去的Dll名字

原来如此,谢谢大神
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-16 18:05

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表