成功的dll注入函数_C/C++语言_黑客防线网安服务器维护基地--Powered by WWW.RONGSEN.COM.CN

成功的dll注入函数

作者:黑客防线网安C/C++教程基地 来源:黑客防线网安C/C++教程基地 浏览次数:0

本篇关键词:函数注入成功NULL
黑客防线网安网讯:    BOOL inject_dll( const char *dll_path, const DWORD remote_pro_id ) { HANDLE h_token; if ( OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &h_token ) ) { TOK...

    BOOL inject_dll( const char *dll_path, const DWORD remote_pro_id )

{


HANDLE h_token;

if ( OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &h_token ) )

{

TOKEN_PRIVILEGES tkp;


//修改进程权限

LookupPrivilegeValue( NULL,SE_DEBUG_NAME, &tkp.Privileges[0].Luid );

tkp.PrivilegeCount = 1;

tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

//通知系统修改进程权限

AdjustTokenPrivileges( h_token, FALSE, &tkp, sizeof( tkp ), NULL, NULL );

 

}


HANDLE h_remote_process;

//打开远程线程

if( ( h_remote_process = OpenProcess( PROCESS_CREATE_THREAD | //允许远程创建线程

PROCESS_VM_OPERATION | //允许远程VM操作

PROCESS_VM_WRITE, //允许远程VM写

FALSE, remote_pro_id ) )== NULL )

{

//AfxMessageBox("OpenProcess Error!");

return FALSE;

}

char *lib_func_buf;

//在远程进程的内存地址空间分配DLL文件名缓冲区

lib_func_buf = (char *) VirtualAllocEx( h_remote_process, NULL, lstrlen(dll_path) + 1,

MEM_COMMIT, PAGE_READWRITE);

if( lib_func_buf == NULL )

{

//AfxMessageBox("VirtualAllocEx error! ");

return FALSE;

}

//将DLL的路径名复制到远程进程的内存空间

if( WriteProcessMemory( h_remote_process,

lib_func_buf, ( void * )dll_path, lstrlen( dll_path ) + 1, NULL ) == 0 )

{

//AfxMessageBox("WriteProcessMemory Error");

return FALSE;

}

//计算LoadLibraryA的入口地址

PTHREAD_START_ROUTINE load_start_addr = ( PTHREAD_START_ROUTINE )

GetProcAddress( GetModuleHandle( TEXT("Kernel32") ), "LoadLibraryA");

if( load_start_addr == NULL )

{

//AfxMessageBox("GetProcAddress Error");

return FALSE;

}

HANDLE h_remote_thread;

if( (h_remote_thread = CreateRemoteThread( h_remote_process, NULL, 0,

load_start_addr, lib_func_buf, 0, NULL ) ) == NULL)

{

//AfxMessageBox("CreateRemoteThread Error");

return FALSE;

}

return TRUE;

}

    黑客防线网安服务器维护方案本篇连接:http://www.rongsen.com.cn/show-15226-1.html
网站维护教程更新时间:2012-04-04 22:51:59  【打印此页】  【关闭
我要申请本站N点 | 黑客防线官网 |  
专业服务器维护及网站维护手工安全搭建环境,网站安全加固服务。黑客防线网安服务器维护基地招商进行中!QQ:29769479

footer  footer  footer  footer