日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

c语言编写劫持dll,c语言-----劫持自己02

發布時間:2025/3/12 编程问答 16 豆豆
生活随笔 收集整理的這篇文章主要介紹了 c语言编写劫持dll,c语言-----劫持自己02 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

在上一節?c語言-----劫持原理01 已經敘述了劫持原理,下邊正式進入劫持實戰

1. 需要實現的功能

在c語言中

system("notepad") 可以打開一個記事本

system("mspaint") 可以打開畫圖工具

所以這次我們需要把 可以打開一個記事本? 這個功能更改為 在控制臺打印 "notepad"

可以打開畫圖工具????? 這個功能更改為 在控制臺打印 "mspaint"? ,即實現監控的日志功能

2. 需要的工具

vs2017

Detours

3.? 劫持原理實現

(1) 查看system()函數定義

_DCRTIMP int __cdecl system(

_In_opt_z_ char const* _Command

);

去掉一些不需要的符號

int system( char const* _Command );

(2) 獲取原system()的地址

int (*plodsystem)(char const* _Command) = system;

(3) 劫持后system()函數

int newsystem(char const* _Command){

printf("你執行的是:%s", _Command);

}

(4) 劫持函數

void hook(){

DetourRestoreAfterWith(); //恢復之前的狀態

DetourTransactionBegin(); //開始劫持

DetourUpdateThread(GetCurrentThread());//更新當前線程

DetourAttach((void **)&plodsystem, newsystem);//劫持

DetourTransactionCommit(); //提交

}

(5) 修改vs配置? Debug -> Release

(6) 完整源代碼

#include

#include

#include

#include "detours.h"

#pragma comment(lib,"detours.lib")

int (*plodsystem)(char const* _Command) = system;

int newsystem(char const* _Command){

printf("你執行的是:%s", _Command);

}

void hook(){

DetourRestoreAfterWith();

DetourTransactionBegin();

DetourUpdateThread(GetCurrentThread());

DetourAttach((void **)&plodsystem, newsystem);

DetourTransactionCommit();

}

int main(){

system("notepad");

hook();

system("notepad");

return 0;

}

3. 解釋說明

system()函數是一個int類型的函數?int system( char const*_Command );

所以需要一個一級函數指針plodsystem

獲取plodsystem的地址 &plodsystem,需要一個二級指針

總結

以上是生活随笔為你收集整理的c语言编写劫持dll,c语言-----劫持自己02的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。