一份进程注入的代码
来源:互联网 发布:任务分配算法 编辑:程序博客网 时间:2024/05/16 19:55
// Injection.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "Injection.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// 唯一的应用程序对象
CWinApp theApp;
using namespace std;
typedef struct _RemotePara{//参数结构
char pMessageBox[12];
DWORD dwMessageBox;
}RemotePara;
//远程线程
DWORD __stdcall ThreadProc (RemotePara *lpPara){
typedef int (__stdcall *MMessageBoxA)(HWND,LPCTSTR,LPCTSTR,DWORD);//定义MessageBox函数
MMessageBoxA myMessageBoxA;
myMessageBoxA =(MMessageBoxA) lpPara->dwMessageBox ;//得到函数入口地址
myMessageBoxA(NULL,lpPara->pMessageBox ,lpPara->pMessageBox,0);//call
return 0;
}
void EnableDebugPriv();//提升应用级调试权限
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
const DWORD THREADSIZE=1024*4;
DWORD byte_write;
EnableDebugPriv();//提升权限
HANDLE hWnd = ::OpenProcess (PROCESS_ALL_ACCESS,FALSE,760);
if(!hWnd)return 0;
void *pRemoteThread =::VirtualAllocEx(hWnd,0,THREADSIZE,MEM_COMMIT| MEM_RESERVE,PAGE_EXECUTE_READWRITE);
if(!pRemoteThread)return 0;
if(!::WriteProcessMemory(hWnd,pRemoteThread,&ThreadProc,THREADSIZE,0))
return 0;
//再付值
RemotePara myRemotePara;
::ZeroMemory(&myRemotePara,sizeof(RemotePara));
HINSTANCE hUser32 = ::LoadLibrary ("user32.dll");
myRemotePara.dwMessageBox =(DWORD) ::GetProcAddress (hUser32 , "MessageBoxA");
strcat(myRemotePara.pMessageBox,"hello/0");
//写进目标进程
RemotePara *pRemotePara =(RemotePara *) ::VirtualAllocEx (hWnd ,0,sizeof(RemotePara),MEM_COMMIT,PAGE_READWRITE);//注意申请空间时的页面属性
if(!pRemotePara)return 0;
if(!::WriteProcessMemory (hWnd ,pRemotePara,&myRemotePara,sizeof myRemotePara,0))return 0;
//启动线程
HANDLE hThread = ::CreateRemoteThread (hWnd ,0,0,(DWORD (__stdcall *)(void *))pRemoteThread ,pRemotePara,0,&byte_write);
if(!hThread){
return 0;
}
return 0;
}
void EnableDebugPriv( void )
{
HANDLE hToken;
LUID sedebugnameValue;
TOKEN_PRIVILEGES tkp;
if ( ! OpenProcessToken( GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken ) )
return;
if ( ! LookupPrivilegeValue( NULL, SE_DEBUG_NAME, &sedebugnameValue ) ){
CloseHandle( hToken );
return;
}
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Luid = sedebugnameValue;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if ( ! AdjustTokenPrivileges( hToken, FALSE, &tkp, sizeof tkp, NULL, NULL ) )
CloseHandle( hToken );
}
转自:http://blog.csdn.net/kugou123/archive/2004/12/29/233499.aspx
- 一份进程注入的代码
- 一份进程注入的代码
- 一份进程注入的代码
- 一份进程注入的代码
- dll注入进程后卸载的代码
- Dll注入系统进程的部分代码
- Delphi进程注入的部分代码
- 一份有趣的代码
- 远程进程注入 - 把自己的代码注入explorer.exe
- Delphi进程注入的部分代码 (非DLL注入)
- 进程注入代码
- 游戏进程注入代码
- 进程代码注入
- c++ 进程注入代码
- 一份简单的轮播图代码
- 注入Winlogon进程示例代码
- 注入Winlogon进程示例代码
- 注入Winlogon进程示例代码
- 大学数学公式大全
- 测试 这篇是拿来测试51ditu的OpenAPI的
- 世界名牌大学课件
- SEH在驱动中的应用
- fedora 8 下安装mplayer(简洁版)
- 一份进程注入的代码
- 广告不能碰触的“五大铁律”
- fd df
- JSP脚本元素
- 利用stl的map判重poj3087
- BW-- BW项目的对象传输
- 项目管理的目标是什么?
- JSP中session对象的理解
- 轻松从零开始学 数码相机参数概念解读