劫持系统函数system

来源:互联网 发布:怎么关掉苹果电脑软件 编辑:程序博客网 时间:2024/06/07 10:00
#include "detours.h"#pragma comment(lib,"detours.lib")int(*poldsystem)(const char *_Command) = system;int newsystem(const char*_Command){ printf("你执行的是:%s\n", _Command); poldsystem(_Command);char *p = strstr(_Command, "notepad");if (NULL==p){printf("安全的,运行通过!\n");poldsystem(_Command);} else{printf("发现威胁,已被成功处理,禁止通过!\n");}}void hook(){DetourRestoreAfterWith();//恢复之前状态   避免反复拦截DetourTransactionBegin();//开始劫持DetourUpdateThread(GetCurrentThread());//刷新当前线程DetourAttach((void**)&poldsystem, newsystem);//拦截DetourTransactionCommit();//立即生效}void main(){system("mspaint");hook();system("notepad");printf("\n开始拦截:\n");system("notepad");system("title 黑鹰's-Blog");system("notepad");system("calc");system("notepad");getchar();}

0 0
原创粉丝点击