-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.cpp
64 lines (52 loc) · 1.86 KB
/
sample.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <fmt/format.h>
#include <chrono>
#include <iostream>
#include "ProcessHooker/Hook_Socket_TCP.h"
// for read process funcaddr to find hook addr
// Reader_FromMemory
#include "ProcessHooker/ControlBlockManager/ModuleFuncAddrReader/Reader_FromMemory.h"
bool funcRecv(HANDLE ProcessHandle, DataBuffer *DataBufferPtr) {
try {
fmt::println("from: 0x{:08X} "
"eax: 0x{:08X} "
"ebx: 0x{:08X} "
"ecx: 0x{:08X} "
"edx: 0x{:08X} "
"edi: 0x{:08X} "
"esi: 0x{:08X} "
"esp: 0x{:08X} "
"ebp: 0x{:08X}",
DataBufferPtr->whereFrom,
DataBufferPtr->eax,
DataBufferPtr->ebx,
DataBufferPtr->ecx,
DataBufferPtr->edx,
DataBufferPtr->edi,
DataBufferPtr->esi,
DataBufferPtr->esp,
DataBufferPtr->ebp);
} catch (std::exception &exception) {
fmt::println("occour a exception but catch: {}", exception.what());
return true;
}
return true;
}
int main() {
setbuf(stdout, nullptr);
try {
// Ñ»·²âÊÔÖ¡ÊýÓ°Ïì
while (1) {
Hook_Socket_TCP hookSocketUdp("notepad.exe");
fmt::println("start hook!");
hookSocketUdp.addHook(0x6B5B5120, 5);
hookSocketUdp.commitHook(funcRecv);
std::this_thread::sleep_for(std::chrono::seconds(2));
fmt::println("delete hook!");
hookSocketUdp.deleteHook(0x6B5B5120);
std::this_thread::sleep_for(std::chrono::seconds(2));
}
} catch (std::exception &exception) {
fmt::println("{}", exception.what());
}
return 0;
}