• 注入(1)--注册表注入


    在Windows NT/2000/XP/3000操作系统中,当需要加载user32.dll的程序启动时,user32.dll会加载注册表键HKEY_LOCAL_MACHINESoftwareMicrosoftwindowsNTCurrentVresionWindowsAppInit_Dlls下边列出的所有模块,所以,可以将外挂模块写在AppInit_Dlls键下,待程序启动后,再将痕迹清除
    注:系统需要重启后才能实现

    // Reginject.cpp : 定义控制台应用程序的入口点。
    //
    
    #include "stdafx.h"
    #include <Windows.h>
    
    #define DSTKEY "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows"
    BOOL RegInject(char* DllFullPath);
    int _tmain(int argc, _TCHAR* argv[])
    {
    	char DllFullPath[MAX_PATH] = "D:\Hook.dll";
    	BOOL bOk = RegInject(DllFullPath);
    	if (bOk)
    	{
    		printf("/n Registry inject success!
    ");
    	}
    	else
    	{
    		printf("/n Registry inject fail!
    ");
    	}
    	getchar();
    	getchar();
    	return 0;
    }
    
    
    //
    //利用AppInit_Dlls键值会被user32.dll调用LoadLibrary所加载
    //
    BOOL RegInject(char* DllFullPath)
    {
    
    	BOOL bOk = FALSE; 
    	HKEY hKey = NULL;
    	LONG Return;
    	BYTE cDllPath[MAX_PATH] = {0};
    
    
    	OutputDebugString("[!] RegInject Enter...");
    	Return = RegOpenKeyEx(
    		HKEY_LOCAL_MACHINE, 
    		DSTKEY, 
    		0, 
    		KEY_ALL_ACCESS,
    		&hKey);
    
    	if(Return != ERROR_SUCCESS)
    	{
    		OutputDebugString("[-] RegOpenKeyEx Error!
    ");
    		goto Exit;
    	}
    
    	memcpy((void*)cDllPath, DllFullPath, strlen(DllFullPath)+1);
    
    	Return = RegSetValueEx(
    		hKey,
    		"AppInit_DLLs",
    		0,
    		REG_SZ,
    		cDllPath,
    		strlen((char*)cDllPath)+1
    		);
    
    	if(Return != ERROR_SUCCESS)
    	{
    		OutputDebugString("[-] RegSetKeyValue Error!
    ");
    		goto Exit;
    	}
    
    	OutputDebugString("[!] RegInject Exit...");
    	bOk = TRUE;
    Exit:
    	if(hKey)
    		RegCloseKey(hKey);
    	return bOk;
    
    }


  • 相关阅读:
    FCKeditor firefox Ajax提交,内容为空.解决.
    Javascript:Go to top of page
    js实现两级联动下拉列表
    php+mysql实现二级联动下拉列表
    ajax 实现两级级联下拉列表
    SharpDevelop_3.2.1.6466_Setup软件安装汉化
    c#拓展项目作业
    摇色子(两颗色子)
    C#编程实践51题目解答
    编程实践53
  • 原文地址:https://www.cnblogs.com/Toring/p/6628283.html
Copyright © 2020-2023  润新知