修改hook消息接口 close #5

This commit is contained in:
hugy 2023-02-01 17:01:53 +08:00
parent 2f1793b2b1
commit 911f87211c
4 changed files with 76 additions and 4 deletions

View File

@ -311,6 +311,38 @@ vcpkg
```
#### 10.取消hook消息**
###### 接口功能
> 取消hook消息
###### 接口地址
> [/api/?type=10](/api/?type=10)
###### HTTP请求方式
> POST JSON
###### 请求参数
|参数|必选|类型|说明|
|---|---|---|---|
###### 返回字段
|返回字段|字段类型|说明 |
|---|---|---|
|code|int|返回状态,1成功, 0失败|
|result|string|成功提示|
###### 接口示例
入参:
``` javascript
```
响应:
``` javascript
{"code":1,"result":"OK"}
```
#### 11.hook图片**
###### 接口功能
@ -348,6 +380,38 @@ vcpkg
```
#### 12.取消hook图片**
###### 接口功能
> 取消hook图片
###### 接口地址
> [/api/?type=12](/api/?type=12)
###### HTTP请求方式
> POST JSON
###### 请求参数
|参数|必选|类型|说明|
|---|---|---|---|
###### 返回字段
|返回字段|字段类型|说明 |
|---|---|---|
|code|int|返回状态,1成功, 0失败|
|result|string|成功提示|
###### 接口示例
入参:
``` javascript
```
响应:
``` javascript
{"code":1,"result":"OK"}
```
#### 17.删除好友**
###### 接口功能

View File

@ -267,7 +267,11 @@ void api_handle(mg_http_message *hm, struct mg_connection *c, string &ret) {
}
case WECHAT_MSG_START_HOOK: {
int port = get_http_req_param_int(hm, j_param, "port", is_post);
int success = HookRecvMsg(port);
wstring ip = get_http_req_param(hm, j_param, "ip", is_post);
string client_ip = Wstring2String(ip);
char ip_cstr[16];
strcpy_s(ip_cstr,client_ip.c_str());
int success = HookRecvMsg(ip_cstr,port);
json ret_data = {{"code", success}, {"result", "OK"}};
ret = ret_data.dump();
break;

View File

@ -20,6 +20,7 @@ using namespace std;
#define CLIENT_IP "127.0.0.1"
static int kServerPort = 0;
static int kMessageHooked = FALSE;
static char kServerIp[16]= "127.0.0.1";
static DWORD kWeChatWinBase = GetWeChatWinBase();
static char kOriginReceMsgAsmCode[5] = {0};
@ -59,10 +60,12 @@ BOOL SendBySocket(const char *buffer, size_t len) {
memset(&client_addr, 0, sizeof(client_addr));
client_addr.sin_family = AF_INET;
client_addr.sin_port = htons((u_short)kServerPort);
InetPtonA(AF_INET, CLIENT_IP, &client_addr.sin_addr.s_addr);
InetPtonA(AF_INET, kServerIp, &client_addr.sin_addr.s_addr);
if (connect(client_socket, reinterpret_cast<sockaddr *>(&client_addr),
sizeof(sockaddr)) < 0) {
#ifdef _DEBUG
cout << "kServerIp:" << kServerIp <<endl;
cout << "port:" << kServerPort <<endl;
cout << "connect error,"
<< " errno:" << errno << endl;
#endif
@ -190,8 +193,9 @@ _declspec(naked) void handle_sync_msg() {
/// @brief hook any address address+0x5
/// @param port 端口
/// @return 成功返回1,已经hook返回2,失败返回-1
int HookRecvMsg(int port) {
int HookRecvMsg(char* client_ip,int port) {
kServerPort = port;
strcpy_s(kServerIp,client_ip);
kWeChatWinBase = GetWeChatWinBase();
if (!kWeChatWinBase) {
return -1;

View File

@ -4,7 +4,7 @@
/// @brief hook any address address+0x5
/// @param port 端口
/// @return 成功返回1,已经hook返回2
int HookRecvMsg(int port);
int HookRecvMsg(char* client_ip,int port);
int UnHookRecvMsg();
#endif