共享内存+Shellcode实现跨进程调用3环函数
生活随笔
收集整理的這篇文章主要介紹了
共享内存+Shellcode实现跨进程调用3环函数
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
提供shellcode的程序
// 共享內(nèi)存調(diào)用Shellcode_Shellcode提供者.cpp : 定義控制臺(tái)應(yīng)用程序的入口點(diǎn)。 // 生成shellcode須關(guān)閉運(yùn)行時(shí)安全檢查選項(xiàng) // C/C++ -> 代碼生成 // 基本運(yùn)行時(shí)檢查:默認(rèn)值 // 緩沖區(qū)安全檢查:否#include "stdafx.h" #include <Windows.h>// 彈出對(duì)話框的shellcode unsigned char ShellCodebuff[] = {0x55, 0x8B, 0xEC, 0x81, 0xEC, 0x0C, 0x01, 0x00, 0x00, 0x53, 0x56, 0x57, 0xC7, 0x45, 0xFC, 0x00,0x00, 0x00, 0x00, 0xC7, 0x45, 0xF8, 0x00, 0x00, 0x00, 0x00, 0xC7, 0x45, 0xF4, 0x00, 0x00, 0x00,0x00, 0xC7, 0x45, 0xF0, 0x00, 0x00, 0x00, 0x00, 0xC7, 0x45, 0xEC, 0x00, 0x00, 0x00, 0x00, 0xC7,0x45, 0xE8, 0x00, 0x00, 0x00, 0x00, 0xC7, 0x45, 0xDC, 0x00, 0x00, 0x00, 0x00, 0xC6, 0x45, 0xC0,0x6B, 0xC6, 0x45, 0xC1, 0x00, 0xC6, 0x45, 0xC2, 0x65, 0xC6, 0x45, 0xC3, 0x00, 0xC6, 0x45, 0xC4,0x72, 0xC6, 0x45, 0xC5, 0x00, 0xC6, 0x45, 0xC6, 0x6E, 0xC6, 0x45, 0xC7, 0x00, 0xC6, 0x45, 0xC8,0x65, 0xC6, 0x45, 0xC9, 0x00, 0xC6, 0x45, 0xCA, 0x6C, 0xC6, 0x45, 0xCB, 0x00, 0xC6, 0x45, 0xCC,0x33, 0xC6, 0x45, 0xCD, 0x00, 0xC6, 0x45, 0xCE, 0x32, 0xC6, 0x45, 0xCF, 0x00, 0xC6,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, 0xEC, 0x6A, 0x00, 0x6A, 0x00, 0x8D, 0x85, 0x78,0xFF, 0xFF, 0xFF, 0x50, 0x6A, 0x00, 0xFF, 0x55, 0xEC, 0x33, 0xC0, 0x5F, 0x5E, 0x5B, 0x8B, 0xE5,0x5D, 0xC2, 0x04, 0x00 };#define ShellCodebuffLen 1268#define SHARE_MEMORY_NAME "sharedshellcode"BOOL SetShareShellCode(PVOID pShellcode, DWORD nSize, PCSTR pszMemoryName);int _tmain(int argc, _TCHAR* argv[]) {if (SetShareShellCode(ShellCodebuff, ShellCodebuffLen, SHARE_MEMORY_NAME)){printf("共享內(nèi)存內(nèi)核對(duì)象名:%s\n", SHARE_MEMORY_NAME);printf("共享內(nèi)存SHELLCODE準(zhǔn)備就緒,可以在其他進(jìn)程調(diào)用,敲任意鍵退出...\n");}else{printf("共享內(nèi)存申請(qǐng)失敗...\n");}getchar();return 0; }// 設(shè)置共享內(nèi)存函數(shù) BOOL SetShareShellCode(PVOID pShellcode, DWORD nSize, PCSTR pszMemoryName) {//創(chuàng)建FileMapping對(duì)象HANDLE hMapObject = CreateFileMappingA(INVALID_HANDLE_VALUE,NULL,PAGE_EXECUTE_READWRITE,0,nSize,pszMemoryName);if (NULL == hMapObject){printf("創(chuàng)建文件映像失敗\n");return FALSE;}//將FileMapping對(duì)象映射到自己的進(jìn)程PVOID hMapView = MapViewOfFile(hMapObject,FILE_MAP_WRITE,0,0,0);if (NULL == hMapView){printf("內(nèi)存映射失敗\n");return FALSE;}//寫入數(shù)據(jù)memset(hMapView,0,nSize);memcpy(hMapView, pShellcode, nSize);return TRUE; }調(diào)用shellcode的程序
// 共享內(nèi)存調(diào)用Shellcode_Shellcode調(diào)用者.cpp : 定義控制臺(tái)應(yīng)用程序的入口點(diǎn)。 //#include "stdafx.h" #include <Windows.h>#define SHARE_MEMORY_NAME "sharedshellcode"#define ShellCodebuffLen 1268int _tmain(int argc, _TCHAR* argv[]) {//創(chuàng)建FileMapping對(duì)象HANDLE hMapObject = CreateFileMappingA(INVALID_HANDLE_VALUE,NULL,PAGE_EXECUTE_READWRITE,0,ShellCodebuffLen,SHARE_MEMORY_NAME);if (NULL == hMapObject){printf("共享內(nèi)存失敗\n");getchar();return 1;} //將FileMapping對(duì)象映射到自己的進(jìn)程PVOID hMapView = MapViewOfFile(hMapObject,FILE_MAP_WRITE,0,0,0);if (NULL == hMapView){printf("內(nèi)存映射失敗\n");getchar();return 1;}//調(diào)用shellcodeprintf("獲取shellcode成功,開始調(diào)用...\n"); ((LPTHREAD_START_ROUTINE)hMapView)(0);return 0; }執(zhí)行結(jié)果(XP系統(tǒng))
總結(jié)
以上是生活随笔為你收集整理的共享内存+Shellcode实现跨进程调用3环函数的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: (43)内存装载驱动
- 下一篇: (44)MessageBoxA 监视器(