mirror of
https://github.com/ttttupup/wxhelper.git
synced 2025-04-29 16:29:52 +08:00
Compare commits
15 Commits
3.9.8.25-v
...
main
Author | SHA1 | Date | |
---|---|---|---|
|
fa90a0ea87 | ||
|
335a4771fe | ||
|
24bb7212fa | ||
|
1528b66b94 | ||
|
62a641d7f7 | ||
|
49188b7ef0 | ||
|
e4656e5139 | ||
|
0bd8b47da0 | ||
|
7a5a8a90df | ||
|
b5cc83be77 | ||
|
3b5f191bf2 | ||
|
dff024745c | ||
|
8b6e2d7160 | ||
|
5d7c1d1d48 | ||
|
d574af863a |
3
.gitignore
vendored
3
.gitignore
vendored
@ -32,5 +32,4 @@
|
||||
*.app
|
||||
CMakePresets.json
|
||||
.vscode
|
||||
out
|
||||
.vs
|
||||
out
|
7
.gitmodules
vendored
7
.gitmodules
vendored
@ -1,4 +1,3 @@
|
||||
[submodule "spdlog"]
|
||||
path = app/3rdparty/spdlog
|
||||
url = https://github.com/gabime/spdlog.git
|
||||
branch = v1.x
|
||||
[submodule "spdlog"]
|
||||
path = spdlog
|
||||
url = https://github.com/gabime/spdlog
|
||||
|
@ -1,6 +1,53 @@
|
||||
cmake_minimum_required(VERSION 3.10...3.27)
|
||||
project(app VERSION 1.0.0)
|
||||
cmake_minimum_required(VERSION 3.0.0)
|
||||
# include(ExternalProject)
|
||||
project(wxhelper VERSION 1.0.0)
|
||||
enable_language(ASM_MASM)
|
||||
|
||||
|
||||
add_subdirectory(app)
|
||||
|
||||
# SET(CMAKE_ASM_NASM_FLAGS "-w0")
|
||||
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
||||
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D '_UNICODE' /D 'UNICODE' ")
|
||||
|
||||
file(GLOB CPP_FILES ${PROJECT_SOURCE_DIR}/src/*.cc ${PROJECT_SOURCE_DIR}/src/*.cpp ${PROJECT_SOURCE_DIR}/src/*.c )
|
||||
|
||||
file(GLOB ASM_FILES ${PROJECT_SOURCE_DIR}/src/*.asm )
|
||||
|
||||
include_directories(${VCPKG_INSTALLED_DIR}/x64-windows/include ${PROJECT_SOURCE_DIR}/spdlog/include ${DETOURS_INCLUDE_DIRS})
|
||||
# include_directories(${VCPKG_INSTALLED_DIR}/x64-windows/include ${PROJECT_SOURCE_DIR}/spdlog/include )
|
||||
|
||||
|
||||
|
||||
add_subdirectory(spdlog)
|
||||
add_subdirectory(source)
|
||||
|
||||
# find_package(spdlog CONFIG REQUIRED)
|
||||
|
||||
find_package(nlohmann_json CONFIG REQUIRED)
|
||||
|
||||
find_path(DETOURS_INCLUDE_DIRS "detours/detours.h")
|
||||
find_library(DETOURS_LIBRARY detours REQUIRED)
|
||||
|
||||
|
||||
add_library(wxhelper SHARED ${CPP_FILES} ${ASM_FILES} )
|
||||
|
||||
|
||||
|
||||
target_link_libraries(wxhelper PRIVATE nlohmann_json::nlohmann_json)
|
||||
target_link_libraries(wxhelper PRIVATE spdlog::spdlog spdlog::spdlog_header_only)
|
||||
target_link_libraries(wxhelper PRIVATE ${DETOURS_LIBRARY})
|
||||
|
||||
|
||||
SET_TARGET_PROPERTIES(wxhelper PROPERTIES LINKER_LANGUAGE C
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
|
||||
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
|
||||
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
|
||||
OUTPUT_NAME "wxhelper"
|
||||
PREFIX "")
|
||||
|
203
README.md
203
README.md
@ -1,5 +1,5 @@
|
||||
# wxhelper
|
||||
wechat hook 。PC端微信逆向学习。
|
||||
wechat hook 。PC端微信逆向学习。支持3.8.0.41,3.8.1.26, 3.9.0.28, 3.9.2.23,3.9.2.26版本。
|
||||
#### 免责声明:
|
||||
本仓库发布的内容,仅用于学习研究,请勿用于非法用途和商业用途!如因此产生任何法律纠纷,均与作者无关!
|
||||
|
||||
@ -18,23 +18,26 @@ dll在注入成功时,创建了一个默认端口为19088的http服务端,
|
||||
|-------------------------- |----------------- -------------- --------
|
||||
|
||||
```
|
||||
#### 快速开始:
|
||||
#### 使用说明:
|
||||
支持的版本3.8.0.41、3.8.1.26、3.9.0.28、3.9.2.23、3.9.2.26 、3.9.5.81。
|
||||
源码和主要实现在相应的分支内。
|
||||
src:主要的dll代码
|
||||
tool:简单的注入工具,一个是控制台,一个是图形界面。
|
||||
python: tcpserver.py: 简单的服务器,用以接收消息内容。decrpty.py: 微信数据库解密工具。 http_server.py:http server端。
|
||||
source: 简单的命令行远程注入源码。
|
||||
其他目录:热心作者提供的一些客户端。
|
||||
|
||||
1.使用注入工具将wxhelper.dll注入到WeChat中。
|
||||
2.执行
|
||||
|
||||
```
|
||||
curl --location --request POST '127.0.0.1:19088/api/checkLogin'
|
||||
```
|
||||
即可检查登录状态。
|
||||
如果已经登录则执行获取登录用户信息
|
||||
```
|
||||
curl --location --request POST '127.0.0.1:19088/api/userInfo'
|
||||
```
|
||||
|
||||
3.其他更多接口参考相关文档。
|
||||
#### 0.首先安装对应的版本的微信,分支名称即代表的是微信对应的版本。dll的前缀都会带有微信版本。
|
||||
#### 1.使用注入工具注入wxhelper.dll,注入成功后,即可通过postman直接调用对应的接口。
|
||||
#### 2.可以使用python/clent.py进行简单测试。
|
||||
|
||||
|
||||
##### 特别注意:
|
||||
|
||||
##### 1.hook相关的接口都需要先调用对应的hook接口,server端才会收到相应消息。
|
||||
##### 2.注意个别接口在一些版本没有实现,功能预览里没有的功能就是没有实现。
|
||||
##### 3.如果注入不成功,请先检查注入工具,或者使用其他注入工具。
|
||||
##### 4.相关功能只在win11环境下进行简单测试,其他环境无法保证。
|
||||
|
||||
|
||||
#### 参与项目
|
||||
@ -51,7 +54,7 @@ curl --location --request POST '127.0.0.1:19088/api/userInfo'
|
||||
|
||||
#### 编译环境
|
||||
|
||||
Visual Studio 2022
|
||||
Visual Studio 2022(x86)
|
||||
|
||||
Visual Studio code
|
||||
|
||||
@ -60,6 +63,8 @@ cmake
|
||||
vcpkg
|
||||
#### 编译构建
|
||||
|
||||
先准备好编译环境。
|
||||
#### <font color= "#dd0000"> 以下是x86环境构建,3.9.5.81是x64环境,具体参考对应分支。</font>
|
||||
```
|
||||
cd wxhelper
|
||||
mkdir build
|
||||
@ -67,11 +72,173 @@ cd build
|
||||
cmake -DCMAKE_C_COMPILER=cl.exe \
|
||||
-DCMAKE_CXX_COMPILER=cl.exe \
|
||||
-DCMAKE_BUILD_TYPE=Debug \
|
||||
-DCMAKE_TOOLCHAIN_FILE:FILEPATH=${vcpkg install dir}/scripts/buildsystems/vcpkg.cmake \
|
||||
-DCMAKE_INSTALL_PREFIX=C:/other/codeSource/windows/wxhelper/out/install/x86-debug \
|
||||
-DCMAKE_TOOLCHAIN_FILE:FILEPATH=C:/vcpkg/scripts/buildsystems/vcpkg.cmake \
|
||||
-SC:/wxhelper \
|
||||
-BC:/wxhelper/build/x64-debug\
|
||||
-BC:/wxhelper/build/x86-debug\
|
||||
-G Ninja
|
||||
|
||||
cmake --build ..
|
||||
```
|
||||
|
||||
以下是在vscode中操作,vs中的操作类似。
|
||||
1.安装vcpkg,cmake,vscode
|
||||
|
||||
2.安装相应的库,如果安装的版本不同,则根据vcpkg安装成功后提示的find_package修改CMakeLists.txt内容即可。或者自己编译。
|
||||
```
|
||||
vcpkg install mongoose
|
||||
vcpkg install nlohmann-json
|
||||
```
|
||||
3.vscode 配置CMakePresets.json,主要设置CMAKE_C_COMPILER 和CMAKE_CXX_COMPILER 为cl.exe.参考如下
|
||||
```
|
||||
{
|
||||
"name": "x86-release",
|
||||
"displayName": "x86-release",
|
||||
"description": "Sets Ninja generator, build and install directory",
|
||||
"generator": "Ninja",
|
||||
"binaryDir": "${sourceDir}/out/build/${presetName}",
|
||||
"architecture":{
|
||||
"value": "x86",
|
||||
"strategy": "external"
|
||||
},
|
||||
"cacheVariables": {
|
||||
"CMAKE_C_COMPILER": "cl.exe",
|
||||
"CMAKE_CXX_COMPILER": "cl.exe",
|
||||
"CMAKE_BUILD_TYPE": "Release",
|
||||
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
|
||||
"CMAKE_TOOLCHAIN_FILE": {
|
||||
"value": "C:/soft/vcpkg/scripts/buildsystems/vcpkg.cmake",
|
||||
"type": "FILEPATH"
|
||||
}
|
||||
},
|
||||
"environment": {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
4.执行cmake build vscode中右键configure all projects,在Terminal中点击Run Task,如没有先配置build任务,然后运行即可
|
||||
|
||||
5.命令行注入工具,注入命令
|
||||
``` javascript
|
||||
//-i 注入程序名 -p 注入dll路径
|
||||
// -u 卸载程序名 -d 卸载dll名称
|
||||
// -m pid 关闭微信互斥体,多开微信
|
||||
// -P port 指定http端口,需要使用 specify-port 分支的生成的dll
|
||||
// -I 注入程序的pid
|
||||
//注入
|
||||
ConsoleInject.exe -i demo.exe -p E:\testInject.dll
|
||||
//卸载
|
||||
ConsoleInject.exe -u demo.exe -d testInject.dll
|
||||
//多开
|
||||
ConsoleInject.exe -m 1222
|
||||
// 注入并指定http端口
|
||||
ConsoleInject.exe -i demo.exe -p E:\testInject.dll -P 18888
|
||||
// 注入指定pid并关闭多开限制
|
||||
ConsoleInject.exe -I 15048 -p E:\testInject.dll -m 15048
|
||||
|
||||
```
|
||||
|
||||
6.如果想改变端口,可以在微信目录下创建config.ini配置文件,修改端口即可。不创建则默认端口19088。
|
||||
``` shell
|
||||
[config]
|
||||
port=19099
|
||||
|
||||
```
|
||||
|
||||
#### 更新说明
|
||||
2022-12-26 : 增加3.8.1.26版本支持。
|
||||
|
||||
2022-12-29 : 新增提取文字功能。
|
||||
|
||||
2023-01-02 : 退出微信登录。
|
||||
|
||||
2023-01-31 : 新增修改群昵称(仅支持3.8.1.26)。
|
||||
|
||||
2023-02-01 : 新增拍一拍(仅支持3.8.1.26)。
|
||||
|
||||
2023-02-04 : 新增群消息置顶和取消置顶。
|
||||
|
||||
2023-02-06 : 新增确认收款。
|
||||
|
||||
2023-02-08 : 新增朋友圈消息。
|
||||
|
||||
2023-02-09 : 新增3.9.0.28版本基础功能。
|
||||
|
||||
2023-02-13 : 新增群昵称和微信名称。
|
||||
|
||||
2023-02-17 : 新增通过wxid添加好友,搜索查找微信。
|
||||
|
||||
2023-03-02 : 新增发送@消息
|
||||
|
||||
2023-03-04 : 新增消息附件下载
|
||||
|
||||
2023-03-21 : 新增hook语音
|
||||
|
||||
2023-03-30 : 新增获取语音文件(推荐使用这个非hook接口)
|
||||
|
||||
2023-04-08 : 3.9.2.23版本功能更新
|
||||
|
||||
2023-06-05 :3.9.2.26版本更新
|
||||
|
||||
2023-07-07 :3.9.5.81版本更新
|
||||
|
||||
#### 功能预览:
|
||||
0.检查是否登录
|
||||
1.获取登录微信信息
|
||||
2.发送文本
|
||||
3.发送@文本
|
||||
5.发送图片
|
||||
6.发送文件
|
||||
9.hook消息
|
||||
10.取消hook消息
|
||||
11.hook图片
|
||||
12.取消hook图片
|
||||
13.hook语音
|
||||
14.取消hook语音
|
||||
17.删除好友
|
||||
19.通过手机或qq查找微信
|
||||
20.通过wxid添加好友
|
||||
23.通过好友申请
|
||||
25.获取群成员
|
||||
26.获取群成员昵称
|
||||
27.删除群成员
|
||||
28.增加群成员
|
||||
31.修改群昵称
|
||||
32.获取数据库句柄
|
||||
34.查询数据库
|
||||
35.hook日志
|
||||
36.取消hook日志
|
||||
40.转发消息
|
||||
44.退出登录
|
||||
45.确认收款
|
||||
46.联系人列表
|
||||
47.获取群详情
|
||||
48.获取解密图片
|
||||
49.图片提取文字ocr
|
||||
50.拍一拍
|
||||
51.群消息置顶消息
|
||||
52.群消息取消置顶
|
||||
53.朋友圈首页
|
||||
54.朋友圈下一页
|
||||
55.获取联系人或者群名称
|
||||
56.获取消息附件(图片,视频,文件)
|
||||
57.获取语音文件(silk3格式)
|
||||
58.登录二维码
|
||||
59.邀请入群
|
||||
60.获取群/群成员详情
|
||||
61.撤回消息
|
||||
62.发送公众号消息
|
||||
63.转发公众号消息
|
||||
64.发送小程序
|
||||
65.退款
|
||||
66.下载头像(勿用,没什么用)
|
||||
#### 感谢
|
||||
https://github.com/ljc545w/ComWeChatRobot
|
||||
|
||||
https://github.com/NationalSecurityAgency/ghidra
|
||||
|
||||
https://github.com/x64dbg/x64dbg
|
||||
|
||||
#### 讨论组
|
||||
https://t.me/+LmvAauweyUpjYzJl
|
||||
|
7
app/3rdparty/CMakeLists.txt
vendored
7
app/3rdparty/CMakeLists.txt
vendored
@ -1,7 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.10...3.27)
|
||||
|
||||
add_subdirectory(base64)
|
||||
add_subdirectory(lz4)
|
||||
add_subdirectory(mongoose)
|
||||
add_subdirectory(spdlog)
|
||||
add_subdirectory(tinyxml2)
|
6
app/3rdparty/base64/CMakeLists.txt
vendored
6
app/3rdparty/base64/CMakeLists.txt
vendored
@ -1,6 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.10...3.27)
|
||||
aux_source_directory(. BASE64_SOURCE)
|
||||
|
||||
add_library(base64 ${BASE64_SOURCE})
|
||||
|
||||
target_include_directories(base64 INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
|
6
app/3rdparty/lz4/CMakeLists.txt
vendored
6
app/3rdparty/lz4/CMakeLists.txt
vendored
@ -1,6 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.10...3.27)
|
||||
aux_source_directory(. LZ4_SOURCE)
|
||||
|
||||
add_library(lz4 ${LZ4_SOURCE})
|
||||
|
||||
target_include_directories(lz4 INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
|
862
app/3rdparty/lz4/lz4.h
vendored
862
app/3rdparty/lz4/lz4.h
vendored
@ -1,862 +0,0 @@
|
||||
/*
|
||||
* LZ4 - Fast LZ compression algorithm
|
||||
* Header File
|
||||
* Copyright (C) 2011-2020, Yann Collet.
|
||||
|
||||
BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
You can contact the author at :
|
||||
- LZ4 homepage : http://www.lz4.org
|
||||
- LZ4 source repository : https://github.com/lz4/lz4
|
||||
*/
|
||||
#if defined (__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef LZ4_H_2983827168210
|
||||
#define LZ4_H_2983827168210
|
||||
|
||||
/* --- Dependency --- */
|
||||
#include <stddef.h> /* size_t */
|
||||
|
||||
|
||||
/**
|
||||
Introduction
|
||||
|
||||
LZ4 is lossless compression algorithm, providing compression speed >500 MB/s per core,
|
||||
scalable with multi-cores CPU. It features an extremely fast decoder, with speed in
|
||||
multiple GB/s per core, typically reaching RAM speed limits on multi-core systems.
|
||||
|
||||
The LZ4 compression library provides in-memory compression and decompression functions.
|
||||
It gives full buffer control to user.
|
||||
Compression can be done in:
|
||||
- a single step (described as Simple Functions)
|
||||
- a single step, reusing a context (described in Advanced Functions)
|
||||
- unbounded multiple steps (described as Streaming compression)
|
||||
|
||||
lz4.h generates and decodes LZ4-compressed blocks (doc/lz4_Block_format.md).
|
||||
Decompressing such a compressed block requires additional metadata.
|
||||
Exact metadata depends on exact decompression function.
|
||||
For the typical case of LZ4_decompress_safe(),
|
||||
metadata includes block's compressed size, and maximum bound of decompressed size.
|
||||
Each application is free to encode and pass such metadata in whichever way it wants.
|
||||
|
||||
lz4.h only handle blocks, it can not generate Frames.
|
||||
|
||||
Blocks are different from Frames (doc/lz4_Frame_format.md).
|
||||
Frames bundle both blocks and metadata in a specified manner.
|
||||
Embedding metadata is required for compressed data to be self-contained and portable.
|
||||
Frame format is delivered through a companion API, declared in lz4frame.h.
|
||||
The `lz4` CLI can only manage frames.
|
||||
*/
|
||||
|
||||
/*^***************************************************************
|
||||
* Export parameters
|
||||
*****************************************************************/
|
||||
/*
|
||||
* LZ4_DLL_EXPORT :
|
||||
* Enable exporting of functions when building a Windows DLL
|
||||
* LZ4LIB_VISIBILITY :
|
||||
* Control library symbols visibility.
|
||||
*/
|
||||
#ifndef LZ4LIB_VISIBILITY
|
||||
# if defined(__GNUC__) && (__GNUC__ >= 4)
|
||||
# define LZ4LIB_VISIBILITY __attribute__ ((visibility ("default")))
|
||||
# else
|
||||
# define LZ4LIB_VISIBILITY
|
||||
# endif
|
||||
#endif
|
||||
#if defined(LZ4_DLL_EXPORT) && (LZ4_DLL_EXPORT==1)
|
||||
# define LZ4LIB_API __declspec(dllexport) LZ4LIB_VISIBILITY
|
||||
#elif defined(LZ4_DLL_IMPORT) && (LZ4_DLL_IMPORT==1)
|
||||
# define LZ4LIB_API __declspec(dllimport) LZ4LIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/
|
||||
#else
|
||||
# define LZ4LIB_API LZ4LIB_VISIBILITY
|
||||
#endif
|
||||
|
||||
/*! LZ4_FREESTANDING :
|
||||
* When this macro is set to 1, it enables "freestanding mode" that is
|
||||
* suitable for typical freestanding environment which doesn't support
|
||||
* standard C library.
|
||||
*
|
||||
* - LZ4_FREESTANDING is a compile-time switch.
|
||||
* - It requires the following macros to be defined:
|
||||
* LZ4_memcpy, LZ4_memmove, LZ4_memset.
|
||||
* - It only enables LZ4/HC functions which don't use heap.
|
||||
* All LZ4F_* functions are not supported.
|
||||
* - See tests/freestanding.c to check its basic setup.
|
||||
*/
|
||||
#if defined(LZ4_FREESTANDING) && (LZ4_FREESTANDING == 1)
|
||||
# define LZ4_HEAPMODE 0
|
||||
# define LZ4HC_HEAPMODE 0
|
||||
# define LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION 1
|
||||
# if !defined(LZ4_memcpy)
|
||||
# error "LZ4_FREESTANDING requires macro 'LZ4_memcpy'."
|
||||
# endif
|
||||
# if !defined(LZ4_memset)
|
||||
# error "LZ4_FREESTANDING requires macro 'LZ4_memset'."
|
||||
# endif
|
||||
# if !defined(LZ4_memmove)
|
||||
# error "LZ4_FREESTANDING requires macro 'LZ4_memmove'."
|
||||
# endif
|
||||
#elif ! defined(LZ4_FREESTANDING)
|
||||
# define LZ4_FREESTANDING 0
|
||||
#endif
|
||||
|
||||
|
||||
/*------ Version ------*/
|
||||
#define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */
|
||||
#define LZ4_VERSION_MINOR 9 /* for new (non-breaking) interface capabilities */
|
||||
#define LZ4_VERSION_RELEASE 4 /* for tweaks, bug-fixes, or development */
|
||||
|
||||
#define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE)
|
||||
|
||||
#define LZ4_LIB_VERSION LZ4_VERSION_MAJOR.LZ4_VERSION_MINOR.LZ4_VERSION_RELEASE
|
||||
#define LZ4_QUOTE(str) #str
|
||||
#define LZ4_EXPAND_AND_QUOTE(str) LZ4_QUOTE(str)
|
||||
#define LZ4_VERSION_STRING LZ4_EXPAND_AND_QUOTE(LZ4_LIB_VERSION) /* requires v1.7.3+ */
|
||||
|
||||
LZ4LIB_API int LZ4_versionNumber(void); /**< library version number; useful to check dll version; requires v1.3.0+ */
|
||||
LZ4LIB_API const char* LZ4_versionString(void); /**< library version string; useful to check dll version; requires v1.7.5+ */
|
||||
|
||||
|
||||
/*-************************************
|
||||
* Tuning parameter
|
||||
**************************************/
|
||||
#define LZ4_MEMORY_USAGE_MIN 10
|
||||
#define LZ4_MEMORY_USAGE_DEFAULT 14
|
||||
#define LZ4_MEMORY_USAGE_MAX 20
|
||||
|
||||
/*!
|
||||
* LZ4_MEMORY_USAGE :
|
||||
* Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB; )
|
||||
* Increasing memory usage improves compression ratio, at the cost of speed.
|
||||
* Reduced memory usage may improve speed at the cost of ratio, thanks to better cache locality.
|
||||
* Default value is 14, for 16KB, which nicely fits into Intel x86 L1 cache
|
||||
*/
|
||||
#ifndef LZ4_MEMORY_USAGE
|
||||
# define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT
|
||||
#endif
|
||||
|
||||
#if (LZ4_MEMORY_USAGE < LZ4_MEMORY_USAGE_MIN)
|
||||
# error "LZ4_MEMORY_USAGE is too small !"
|
||||
#endif
|
||||
|
||||
#if (LZ4_MEMORY_USAGE > LZ4_MEMORY_USAGE_MAX)
|
||||
# error "LZ4_MEMORY_USAGE is too large !"
|
||||
#endif
|
||||
|
||||
/*-************************************
|
||||
* Simple Functions
|
||||
**************************************/
|
||||
/*! LZ4_compress_default() :
|
||||
* Compresses 'srcSize' bytes from buffer 'src'
|
||||
* into already allocated 'dst' buffer of size 'dstCapacity'.
|
||||
* Compression is guaranteed to succeed if 'dstCapacity' >= LZ4_compressBound(srcSize).
|
||||
* It also runs faster, so it's a recommended setting.
|
||||
* If the function cannot compress 'src' into a more limited 'dst' budget,
|
||||
* compression stops *immediately*, and the function result is zero.
|
||||
* In which case, 'dst' content is undefined (invalid).
|
||||
* srcSize : max supported value is LZ4_MAX_INPUT_SIZE.
|
||||
* dstCapacity : size of buffer 'dst' (which must be already allocated)
|
||||
* @return : the number of bytes written into buffer 'dst' (necessarily <= dstCapacity)
|
||||
* or 0 if compression fails
|
||||
* Note : This function is protected against buffer overflow scenarios (never writes outside 'dst' buffer, nor read outside 'source' buffer).
|
||||
*/
|
||||
LZ4LIB_API int LZ4_compress_default(const char* src, char* dst, int srcSize, int dstCapacity);
|
||||
|
||||
/*! LZ4_decompress_safe() :
|
||||
* @compressedSize : is the exact complete size of the compressed block.
|
||||
* @dstCapacity : is the size of destination buffer (which must be already allocated),
|
||||
* is an upper bound of decompressed size.
|
||||
* @return : the number of bytes decompressed into destination buffer (necessarily <= dstCapacity)
|
||||
* If destination buffer is not large enough, decoding will stop and output an error code (negative value).
|
||||
* If the source stream is detected malformed, the function will stop decoding and return a negative result.
|
||||
* Note 1 : This function is protected against malicious data packets :
|
||||
* it will never writes outside 'dst' buffer, nor read outside 'source' buffer,
|
||||
* even if the compressed block is maliciously modified to order the decoder to do these actions.
|
||||
* In such case, the decoder stops immediately, and considers the compressed block malformed.
|
||||
* Note 2 : compressedSize and dstCapacity must be provided to the function, the compressed block does not contain them.
|
||||
* The implementation is free to send / store / derive this information in whichever way is most beneficial.
|
||||
* If there is a need for a different format which bundles together both compressed data and its metadata, consider looking at lz4frame.h instead.
|
||||
*/
|
||||
LZ4LIB_API int LZ4_decompress_safe(const char* src, char* dst, int compressedSize, int dstCapacity);
|
||||
|
||||
|
||||
/*-************************************
|
||||
* Advanced Functions
|
||||
**************************************/
|
||||
#define LZ4_MAX_INPUT_SIZE 0x7E000000 /* 2 113 929 216 bytes */
|
||||
#define LZ4_COMPRESSBOUND(isize) ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16)
|
||||
|
||||
/*! LZ4_compressBound() :
|
||||
Provides the maximum size that LZ4 compression may output in a "worst case" scenario (input data not compressible)
|
||||
This function is primarily useful for memory allocation purposes (destination buffer size).
|
||||
Macro LZ4_COMPRESSBOUND() is also provided for compilation-time evaluation (stack memory allocation for example).
|
||||
Note that LZ4_compress_default() compresses faster when dstCapacity is >= LZ4_compressBound(srcSize)
|
||||
inputSize : max supported value is LZ4_MAX_INPUT_SIZE
|
||||
return : maximum output size in a "worst case" scenario
|
||||
or 0, if input size is incorrect (too large or negative)
|
||||
*/
|
||||
LZ4LIB_API int LZ4_compressBound(int inputSize);
|
||||
|
||||
/*! LZ4_compress_fast() :
|
||||
Same as LZ4_compress_default(), but allows selection of "acceleration" factor.
|
||||
The larger the acceleration value, the faster the algorithm, but also the lesser the compression.
|
||||
It's a trade-off. It can be fine tuned, with each successive value providing roughly +~3% to speed.
|
||||
An acceleration value of "1" is the same as regular LZ4_compress_default()
|
||||
Values <= 0 will be replaced by LZ4_ACCELERATION_DEFAULT (currently == 1, see lz4.c).
|
||||
Values > LZ4_ACCELERATION_MAX will be replaced by LZ4_ACCELERATION_MAX (currently == 65537, see lz4.c).
|
||||
*/
|
||||
LZ4LIB_API int LZ4_compress_fast(const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
|
||||
|
||||
|
||||
/*! LZ4_compress_fast_extState() :
|
||||
* Same as LZ4_compress_fast(), using an externally allocated memory space for its state.
|
||||
* Use LZ4_sizeofState() to know how much memory must be allocated,
|
||||
* and allocate it on 8-bytes boundaries (using `malloc()` typically).
|
||||
* Then, provide this buffer as `void* state` to compression function.
|
||||
*/
|
||||
LZ4LIB_API int LZ4_sizeofState(void);
|
||||
LZ4LIB_API int LZ4_compress_fast_extState(void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
|
||||
|
||||
|
||||
/*! LZ4_compress_destSize() :
|
||||
* Reverse the logic : compresses as much data as possible from 'src' buffer
|
||||
* into already allocated buffer 'dst', of size >= 'targetDestSize'.
|
||||
* This function either compresses the entire 'src' content into 'dst' if it's large enough,
|
||||
* or fill 'dst' buffer completely with as much data as possible from 'src'.
|
||||
* note: acceleration parameter is fixed to "default".
|
||||
*
|
||||
* *srcSizePtr : will be modified to indicate how many bytes where read from 'src' to fill 'dst'.
|
||||
* New value is necessarily <= input value.
|
||||
* @return : Nb bytes written into 'dst' (necessarily <= targetDestSize)
|
||||
* or 0 if compression fails.
|
||||
*
|
||||
* Note : from v1.8.2 to v1.9.1, this function had a bug (fixed un v1.9.2+):
|
||||
* the produced compressed content could, in specific circumstances,
|
||||
* require to be decompressed into a destination buffer larger
|
||||
* by at least 1 byte than the content to decompress.
|
||||
* If an application uses `LZ4_compress_destSize()`,
|
||||
* it's highly recommended to update liblz4 to v1.9.2 or better.
|
||||
* If this can't be done or ensured,
|
||||
* the receiving decompression function should provide
|
||||
* a dstCapacity which is > decompressedSize, by at least 1 byte.
|
||||
* See https://github.com/lz4/lz4/issues/859 for details
|
||||
*/
|
||||
LZ4LIB_API int LZ4_compress_destSize(const char* src, char* dst, int* srcSizePtr, int targetDstSize);
|
||||
|
||||
|
||||
/*! LZ4_decompress_safe_partial() :
|
||||
* Decompress an LZ4 compressed block, of size 'srcSize' at position 'src',
|
||||
* into destination buffer 'dst' of size 'dstCapacity'.
|
||||
* Up to 'targetOutputSize' bytes will be decoded.
|
||||
* The function stops decoding on reaching this objective.
|
||||
* This can be useful to boost performance
|
||||
* whenever only the beginning of a block is required.
|
||||
*
|
||||
* @return : the number of bytes decoded in `dst` (necessarily <= targetOutputSize)
|
||||
* If source stream is detected malformed, function returns a negative result.
|
||||
*
|
||||
* Note 1 : @return can be < targetOutputSize, if compressed block contains less data.
|
||||
*
|
||||
* Note 2 : targetOutputSize must be <= dstCapacity
|
||||
*
|
||||
* Note 3 : this function effectively stops decoding on reaching targetOutputSize,
|
||||
* so dstCapacity is kind of redundant.
|
||||
* This is because in older versions of this function,
|
||||
* decoding operation would still write complete sequences.
|
||||
* Therefore, there was no guarantee that it would stop writing at exactly targetOutputSize,
|
||||
* it could write more bytes, though only up to dstCapacity.
|
||||
* Some "margin" used to be required for this operation to work properly.
|
||||
* Thankfully, this is no longer necessary.
|
||||
* The function nonetheless keeps the same signature, in an effort to preserve API compatibility.
|
||||
*
|
||||
* Note 4 : If srcSize is the exact size of the block,
|
||||
* then targetOutputSize can be any value,
|
||||
* including larger than the block's decompressed size.
|
||||
* The function will, at most, generate block's decompressed size.
|
||||
*
|
||||
* Note 5 : If srcSize is _larger_ than block's compressed size,
|
||||
* then targetOutputSize **MUST** be <= block's decompressed size.
|
||||
* Otherwise, *silent corruption will occur*.
|
||||
*/
|
||||
LZ4LIB_API int LZ4_decompress_safe_partial(const char* src, char* dst, int srcSize, int targetOutputSize, int dstCapacity);
|
||||
|
||||
|
||||
/*-*********************************************
|
||||
* Streaming Compression Functions
|
||||
***********************************************/
|
||||
typedef union LZ4_stream_u LZ4_stream_t; /* incomplete type (defined later) */
|
||||
|
||||
/**
|
||||
Note about RC_INVOKED
|
||||
|
||||
- RC_INVOKED is predefined symbol of rc.exe (the resource compiler which is part of MSVC/Visual Studio).
|
||||
https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros
|
||||
|
||||
- Since rc.exe is a legacy compiler, it truncates long symbol (> 30 chars)
|
||||
and reports warning "RC4011: identifier truncated".
|
||||
|
||||
- To eliminate the warning, we surround long preprocessor symbol with
|
||||
"#if !defined(RC_INVOKED) ... #endif" block that means
|
||||
"skip this block when rc.exe is trying to read it".
|
||||
*/
|
||||
#if !defined(RC_INVOKED) /* https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros */
|
||||
#if !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION)
|
||||
LZ4LIB_API LZ4_stream_t* LZ4_createStream(void);
|
||||
LZ4LIB_API int LZ4_freeStream(LZ4_stream_t* streamPtr);
|
||||
#endif /* !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION) */
|
||||
#endif
|
||||
|
||||
/*! LZ4_resetStream_fast() : v1.9.0+
|
||||
* Use this to prepare an LZ4_stream_t for a new chain of dependent blocks
|
||||
* (e.g., LZ4_compress_fast_continue()).
|
||||
*
|
||||
* An LZ4_stream_t must be initialized once before usage.
|
||||
* This is automatically done when created by LZ4_createStream().
|
||||
* However, should the LZ4_stream_t be simply declared on stack (for example),
|
||||
* it's necessary to initialize it first, using LZ4_initStream().
|
||||
*
|
||||
* After init, start any new stream with LZ4_resetStream_fast().
|
||||
* A same LZ4_stream_t can be re-used multiple times consecutively
|
||||
* and compress multiple streams,
|
||||
* provided that it starts each new stream with LZ4_resetStream_fast().
|
||||
*
|
||||
* LZ4_resetStream_fast() is much faster than LZ4_initStream(),
|
||||
* but is not compatible with memory regions containing garbage data.
|
||||
*
|
||||
* Note: it's only useful to call LZ4_resetStream_fast()
|
||||
* in the context of streaming compression.
|
||||
* The *extState* functions perform their own resets.
|
||||
* Invoking LZ4_resetStream_fast() before is redundant, and even counterproductive.
|
||||
*/
|
||||
LZ4LIB_API void LZ4_resetStream_fast(LZ4_stream_t* streamPtr);
|
||||
|
||||
/*! LZ4_loadDict() :
|
||||
* Use this function to reference a static dictionary into LZ4_stream_t.
|
||||
* The dictionary must remain available during compression.
|
||||
* LZ4_loadDict() triggers a reset, so any previous data will be forgotten.
|
||||
* The same dictionary will have to be loaded on decompression side for successful decoding.
|
||||
* Dictionary are useful for better compression of small data (KB range).
|
||||
* While LZ4 accept any input as dictionary,
|
||||
* results are generally better when using Zstandard's Dictionary Builder.
|
||||
* Loading a size of 0 is allowed, and is the same as reset.
|
||||
* @return : loaded dictionary size, in bytes (necessarily <= 64 KB)
|
||||
*/
|
||||
LZ4LIB_API int LZ4_loadDict(LZ4_stream_t* streamPtr, const char* dictionary, int dictSize);
|
||||
|
||||
/*! LZ4_compress_fast_continue() :
|
||||
* Compress 'src' content using data from previously compressed blocks, for better compression ratio.
|
||||
* 'dst' buffer must be already allocated.
|
||||
* If dstCapacity >= LZ4_compressBound(srcSize), compression is guaranteed to succeed, and runs faster.
|
||||
*
|
||||
* @return : size of compressed block
|
||||
* or 0 if there is an error (typically, cannot fit into 'dst').
|
||||
*
|
||||
* Note 1 : Each invocation to LZ4_compress_fast_continue() generates a new block.
|
||||
* Each block has precise boundaries.
|
||||
* Each block must be decompressed separately, calling LZ4_decompress_*() with relevant metadata.
|
||||
* It's not possible to append blocks together and expect a single invocation of LZ4_decompress_*() to decompress them together.
|
||||
*
|
||||
* Note 2 : The previous 64KB of source data is __assumed__ to remain present, unmodified, at same address in memory !
|
||||
*
|
||||
* Note 3 : When input is structured as a double-buffer, each buffer can have any size, including < 64 KB.
|
||||
* Make sure that buffers are separated, by at least one byte.
|
||||
* This construction ensures that each block only depends on previous block.
|
||||
*
|
||||
* Note 4 : If input buffer is a ring-buffer, it can have any size, including < 64 KB.
|
||||
*
|
||||
* Note 5 : After an error, the stream status is undefined (invalid), it can only be reset or freed.
|
||||
*/
|
||||
LZ4LIB_API int LZ4_compress_fast_continue(LZ4_stream_t* streamPtr, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
|
||||
|
||||
/*! LZ4_saveDict() :
|
||||
* If last 64KB data cannot be guaranteed to remain available at its current memory location,
|
||||
* save it into a safer place (char* safeBuffer).
|
||||
* This is schematically equivalent to a memcpy() followed by LZ4_loadDict(),
|
||||
* but is much faster, because LZ4_saveDict() doesn't need to rebuild tables.
|
||||
* @return : saved dictionary size in bytes (necessarily <= maxDictSize), or 0 if error.
|
||||
*/
|
||||
LZ4LIB_API int LZ4_saveDict(LZ4_stream_t* streamPtr, char* safeBuffer, int maxDictSize);
|
||||
|
||||
|
||||
/*-**********************************************
|
||||
* Streaming Decompression Functions
|
||||
* Bufferless synchronous API
|
||||
************************************************/
|
||||
typedef union LZ4_streamDecode_u LZ4_streamDecode_t; /* tracking context */
|
||||
|
||||
/*! LZ4_createStreamDecode() and LZ4_freeStreamDecode() :
|
||||
* creation / destruction of streaming decompression tracking context.
|
||||
* A tracking context can be re-used multiple times.
|
||||
*/
|
||||
#if !defined(RC_INVOKED) /* https://docs.microsoft.com/en-us/windows/win32/menurc/predefined-macros */
|
||||
#if !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION)
|
||||
LZ4LIB_API LZ4_streamDecode_t* LZ4_createStreamDecode(void);
|
||||
LZ4LIB_API int LZ4_freeStreamDecode(LZ4_streamDecode_t* LZ4_stream);
|
||||
#endif /* !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION) */
|
||||
#endif
|
||||
|
||||
/*! LZ4_setStreamDecode() :
|
||||
* An LZ4_streamDecode_t context can be allocated once and re-used multiple times.
|
||||
* Use this function to start decompression of a new stream of blocks.
|
||||
* A dictionary can optionally be set. Use NULL or size 0 for a reset order.
|
||||
* Dictionary is presumed stable : it must remain accessible and unmodified during next decompression.
|
||||
* @return : 1 if OK, 0 if error
|
||||
*/
|
||||
LZ4LIB_API int LZ4_setStreamDecode(LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize);
|
||||
|
||||
/*! LZ4_decoderRingBufferSize() : v1.8.2+
|
||||
* Note : in a ring buffer scenario (optional),
|
||||
* blocks are presumed decompressed next to each other
|
||||
* up to the moment there is not enough remaining space for next block (remainingSize < maxBlockSize),
|
||||
* at which stage it resumes from beginning of ring buffer.
|
||||
* When setting such a ring buffer for streaming decompression,
|
||||
* provides the minimum size of this ring buffer
|
||||
* to be compatible with any source respecting maxBlockSize condition.
|
||||
* @return : minimum ring buffer size,
|
||||
* or 0 if there is an error (invalid maxBlockSize).
|
||||
*/
|
||||
LZ4LIB_API int LZ4_decoderRingBufferSize(int maxBlockSize);
|
||||
#define LZ4_DECODER_RING_BUFFER_SIZE(maxBlockSize) (65536 + 14 + (maxBlockSize)) /* for static allocation; maxBlockSize presumed valid */
|
||||
|
||||
/*! LZ4_decompress_safe_continue() :
|
||||
* This decoding function allows decompression of consecutive blocks in "streaming" mode.
|
||||
* The difference with the usual independent blocks is that
|
||||
* new blocks are allowed to find references into former blocks.
|
||||
* A block is an unsplittable entity, and must be presented entirely to the decompression function.
|
||||
* LZ4_decompress_safe_continue() only accepts one block at a time.
|
||||
* It's modeled after `LZ4_decompress_safe()` and behaves similarly.
|
||||
*
|
||||
* @LZ4_streamDecode : decompression state, tracking the position in memory of past data
|
||||
* @compressedSize : exact complete size of one compressed block.
|
||||
* @dstCapacity : size of destination buffer (which must be already allocated),
|
||||
* must be an upper bound of decompressed size.
|
||||
* @return : number of bytes decompressed into destination buffer (necessarily <= dstCapacity)
|
||||
* If destination buffer is not large enough, decoding will stop and output an error code (negative value).
|
||||
* If the source stream is detected malformed, the function will stop decoding and return a negative result.
|
||||
*
|
||||
* The last 64KB of previously decoded data *must* remain available and unmodified
|
||||
* at the memory position where they were previously decoded.
|
||||
* If less than 64KB of data has been decoded, all the data must be present.
|
||||
*
|
||||
* Special : if decompression side sets a ring buffer, it must respect one of the following conditions :
|
||||
* - Decompression buffer size is _at least_ LZ4_decoderRingBufferSize(maxBlockSize).
|
||||
* maxBlockSize is the maximum size of any single block. It can have any value > 16 bytes.
|
||||
* In which case, encoding and decoding buffers do not need to be synchronized.
|
||||
* Actually, data can be produced by any source compliant with LZ4 format specification, and respecting maxBlockSize.
|
||||
* - Synchronized mode :
|
||||
* Decompression buffer size is _exactly_ the same as compression buffer size,
|
||||
* and follows exactly same update rule (block boundaries at same positions),
|
||||
* and decoding function is provided with exact decompressed size of each block (exception for last block of the stream),
|
||||
* _then_ decoding & encoding ring buffer can have any size, including small ones ( < 64 KB).
|
||||
* - Decompression buffer is larger than encoding buffer, by a minimum of maxBlockSize more bytes.
|
||||
* In which case, encoding and decoding buffers do not need to be synchronized,
|
||||
* and encoding ring buffer can have any size, including small ones ( < 64 KB).
|
||||
*
|
||||
* Whenever these conditions are not possible,
|
||||
* save the last 64KB of decoded data into a safe buffer where it can't be modified during decompression,
|
||||
* then indicate where this data is saved using LZ4_setStreamDecode(), before decompressing next block.
|
||||
*/
|
||||
LZ4LIB_API int
|
||||
LZ4_decompress_safe_continue(LZ4_streamDecode_t* LZ4_streamDecode,
|
||||
const char* src, char* dst,
|
||||
int srcSize, int dstCapacity);
|
||||
|
||||
|
||||
/*! LZ4_decompress_safe_usingDict() :
|
||||
* Works the same as
|
||||
* a combination of LZ4_setStreamDecode() followed by LZ4_decompress_safe_continue()
|
||||
* However, it's stateless: it doesn't need any LZ4_streamDecode_t state.
|
||||
* Dictionary is presumed stable : it must remain accessible and unmodified during decompression.
|
||||
* Performance tip : Decompression speed can be substantially increased
|
||||
* when dst == dictStart + dictSize.
|
||||
*/
|
||||
LZ4LIB_API int
|
||||
LZ4_decompress_safe_usingDict(const char* src, char* dst,
|
||||
int srcSize, int dstCapacity,
|
||||
const char* dictStart, int dictSize);
|
||||
|
||||
/*! LZ4_decompress_safe_partial_usingDict() :
|
||||
* Behaves the same as LZ4_decompress_safe_partial()
|
||||
* with the added ability to specify a memory segment for past data.
|
||||
* Performance tip : Decompression speed can be substantially increased
|
||||
* when dst == dictStart + dictSize.
|
||||
*/
|
||||
LZ4LIB_API int
|
||||
LZ4_decompress_safe_partial_usingDict(const char* src, char* dst,
|
||||
int compressedSize,
|
||||
int targetOutputSize, int maxOutputSize,
|
||||
const char* dictStart, int dictSize);
|
||||
|
||||
#endif /* LZ4_H_2983827168210 */
|
||||
|
||||
|
||||
/*^*************************************
|
||||
* !!!!!! STATIC LINKING ONLY !!!!!!
|
||||
***************************************/
|
||||
|
||||
/*-****************************************************************************
|
||||
* Experimental section
|
||||
*
|
||||
* Symbols declared in this section must be considered unstable. Their
|
||||
* signatures or semantics may change, or they may be removed altogether in the
|
||||
* future. They are therefore only safe to depend on when the caller is
|
||||
* statically linked against the library.
|
||||
*
|
||||
* To protect against unsafe usage, not only are the declarations guarded,
|
||||
* the definitions are hidden by default
|
||||
* when building LZ4 as a shared/dynamic library.
|
||||
*
|
||||
* In order to access these declarations,
|
||||
* define LZ4_STATIC_LINKING_ONLY in your application
|
||||
* before including LZ4's headers.
|
||||
*
|
||||
* In order to make their implementations accessible dynamically, you must
|
||||
* define LZ4_PUBLISH_STATIC_FUNCTIONS when building the LZ4 library.
|
||||
******************************************************************************/
|
||||
|
||||
#ifdef LZ4_STATIC_LINKING_ONLY
|
||||
|
||||
#ifndef LZ4_STATIC_3504398509
|
||||
#define LZ4_STATIC_3504398509
|
||||
|
||||
#ifdef LZ4_PUBLISH_STATIC_FUNCTIONS
|
||||
#define LZ4LIB_STATIC_API LZ4LIB_API
|
||||
#else
|
||||
#define LZ4LIB_STATIC_API
|
||||
#endif
|
||||
|
||||
|
||||
/*! LZ4_compress_fast_extState_fastReset() :
|
||||
* A variant of LZ4_compress_fast_extState().
|
||||
*
|
||||
* Using this variant avoids an expensive initialization step.
|
||||
* It is only safe to call if the state buffer is known to be correctly initialized already
|
||||
* (see above comment on LZ4_resetStream_fast() for a definition of "correctly initialized").
|
||||
* From a high level, the difference is that
|
||||
* this function initializes the provided state with a call to something like LZ4_resetStream_fast()
|
||||
* while LZ4_compress_fast_extState() starts with a call to LZ4_resetStream().
|
||||
*/
|
||||
LZ4LIB_STATIC_API int LZ4_compress_fast_extState_fastReset(void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
|
||||
|
||||
/*! LZ4_attach_dictionary() :
|
||||
* This is an experimental API that allows
|
||||
* efficient use of a static dictionary many times.
|
||||
*
|
||||
* Rather than re-loading the dictionary buffer into a working context before
|
||||
* each compression, or copying a pre-loaded dictionary's LZ4_stream_t into a
|
||||
* working LZ4_stream_t, this function introduces a no-copy setup mechanism,
|
||||
* in which the working stream references the dictionary stream in-place.
|
||||
*
|
||||
* Several assumptions are made about the state of the dictionary stream.
|
||||
* Currently, only streams which have been prepared by LZ4_loadDict() should
|
||||
* be expected to work.
|
||||
*
|
||||
* Alternatively, the provided dictionaryStream may be NULL,
|
||||
* in which case any existing dictionary stream is unset.
|
||||
*
|
||||
* If a dictionary is provided, it replaces any pre-existing stream history.
|
||||
* The dictionary contents are the only history that can be referenced and
|
||||
* logically immediately precede the data compressed in the first subsequent
|
||||
* compression call.
|
||||
*
|
||||
* The dictionary will only remain attached to the working stream through the
|
||||
* first compression call, at the end of which it is cleared. The dictionary
|
||||
* stream (and source buffer) must remain in-place / accessible / unchanged
|
||||
* through the completion of the first compression call on the stream.
|
||||
*/
|
||||
LZ4LIB_STATIC_API void
|
||||
LZ4_attach_dictionary(LZ4_stream_t* workingStream,
|
||||
const LZ4_stream_t* dictionaryStream);
|
||||
|
||||
|
||||
/*! In-place compression and decompression
|
||||
*
|
||||
* It's possible to have input and output sharing the same buffer,
|
||||
* for highly constrained memory environments.
|
||||
* In both cases, it requires input to lay at the end of the buffer,
|
||||
* and decompression to start at beginning of the buffer.
|
||||
* Buffer size must feature some margin, hence be larger than final size.
|
||||
*
|
||||
* |<------------------------buffer--------------------------------->|
|
||||
* |<-----------compressed data--------->|
|
||||
* |<-----------decompressed size------------------>|
|
||||
* |<----margin---->|
|
||||
*
|
||||
* This technique is more useful for decompression,
|
||||
* since decompressed size is typically larger,
|
||||
* and margin is short.
|
||||
*
|
||||
* In-place decompression will work inside any buffer
|
||||
* which size is >= LZ4_DECOMPRESS_INPLACE_BUFFER_SIZE(decompressedSize).
|
||||
* This presumes that decompressedSize > compressedSize.
|
||||
* Otherwise, it means compression actually expanded data,
|
||||
* and it would be more efficient to store such data with a flag indicating it's not compressed.
|
||||
* This can happen when data is not compressible (already compressed, or encrypted).
|
||||
*
|
||||
* For in-place compression, margin is larger, as it must be able to cope with both
|
||||
* history preservation, requiring input data to remain unmodified up to LZ4_DISTANCE_MAX,
|
||||
* and data expansion, which can happen when input is not compressible.
|
||||
* As a consequence, buffer size requirements are much higher,
|
||||
* and memory savings offered by in-place compression are more limited.
|
||||
*
|
||||
* There are ways to limit this cost for compression :
|
||||
* - Reduce history size, by modifying LZ4_DISTANCE_MAX.
|
||||
* Note that it is a compile-time constant, so all compressions will apply this limit.
|
||||
* Lower values will reduce compression ratio, except when input_size < LZ4_DISTANCE_MAX,
|
||||
* so it's a reasonable trick when inputs are known to be small.
|
||||
* - Require the compressor to deliver a "maximum compressed size".
|
||||
* This is the `dstCapacity` parameter in `LZ4_compress*()`.
|
||||
* When this size is < LZ4_COMPRESSBOUND(inputSize), then compression can fail,
|
||||
* in which case, the return code will be 0 (zero).
|
||||
* The caller must be ready for these cases to happen,
|
||||
* and typically design a backup scheme to send data uncompressed.
|
||||
* The combination of both techniques can significantly reduce
|
||||
* the amount of margin required for in-place compression.
|
||||
*
|
||||
* In-place compression can work in any buffer
|
||||
* which size is >= (maxCompressedSize)
|
||||
* with maxCompressedSize == LZ4_COMPRESSBOUND(srcSize) for guaranteed compression success.
|
||||
* LZ4_COMPRESS_INPLACE_BUFFER_SIZE() depends on both maxCompressedSize and LZ4_DISTANCE_MAX,
|
||||
* so it's possible to reduce memory requirements by playing with them.
|
||||
*/
|
||||
|
||||
#define LZ4_DECOMPRESS_INPLACE_MARGIN(compressedSize) (((compressedSize) >> 8) + 32)
|
||||
#define LZ4_DECOMPRESS_INPLACE_BUFFER_SIZE(decompressedSize) ((decompressedSize) + LZ4_DECOMPRESS_INPLACE_MARGIN(decompressedSize)) /**< note: presumes that compressedSize < decompressedSize. note2: margin is overestimated a bit, since it could use compressedSize instead */
|
||||
|
||||
#ifndef LZ4_DISTANCE_MAX /* history window size; can be user-defined at compile time */
|
||||
# define LZ4_DISTANCE_MAX 65535 /* set to maximum value by default */
|
||||
#endif
|
||||
|
||||
#define LZ4_COMPRESS_INPLACE_MARGIN (LZ4_DISTANCE_MAX + 32) /* LZ4_DISTANCE_MAX can be safely replaced by srcSize when it's smaller */
|
||||
#define LZ4_COMPRESS_INPLACE_BUFFER_SIZE(maxCompressedSize) ((maxCompressedSize) + LZ4_COMPRESS_INPLACE_MARGIN) /**< maxCompressedSize is generally LZ4_COMPRESSBOUND(inputSize), but can be set to any lower value, with the risk that compression can fail (return code 0(zero)) */
|
||||
|
||||
#endif /* LZ4_STATIC_3504398509 */
|
||||
#endif /* LZ4_STATIC_LINKING_ONLY */
|
||||
|
||||
|
||||
|
||||
#ifndef LZ4_H_98237428734687
|
||||
#define LZ4_H_98237428734687
|
||||
|
||||
/*-************************************************************
|
||||
* Private Definitions
|
||||
**************************************************************
|
||||
* Do not use these definitions directly.
|
||||
* They are only exposed to allow static allocation of `LZ4_stream_t` and `LZ4_streamDecode_t`.
|
||||
* Accessing members will expose user code to API and/or ABI break in future versions of the library.
|
||||
**************************************************************/
|
||||
#define LZ4_HASHLOG (LZ4_MEMORY_USAGE-2)
|
||||
#define LZ4_HASHTABLESIZE (1 << LZ4_MEMORY_USAGE)
|
||||
#define LZ4_HASH_SIZE_U32 (1 << LZ4_HASHLOG) /* required as macro for static allocation */
|
||||
|
||||
#if defined(__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
|
||||
# include <stdint.h>
|
||||
typedef int8_t LZ4_i8;
|
||||
typedef uint8_t LZ4_byte;
|
||||
typedef uint16_t LZ4_u16;
|
||||
typedef uint32_t LZ4_u32;
|
||||
#else
|
||||
typedef signed char LZ4_i8;
|
||||
typedef unsigned char LZ4_byte;
|
||||
typedef unsigned short LZ4_u16;
|
||||
typedef unsigned int LZ4_u32;
|
||||
#endif
|
||||
|
||||
/*! LZ4_stream_t :
|
||||
* Never ever use below internal definitions directly !
|
||||
* These definitions are not API/ABI safe, and may change in future versions.
|
||||
* If you need static allocation, declare or allocate an LZ4_stream_t object.
|
||||
**/
|
||||
|
||||
typedef struct LZ4_stream_t_internal LZ4_stream_t_internal;
|
||||
struct LZ4_stream_t_internal {
|
||||
LZ4_u32 hashTable[LZ4_HASH_SIZE_U32];
|
||||
const LZ4_byte* dictionary;
|
||||
const LZ4_stream_t_internal* dictCtx;
|
||||
LZ4_u32 currentOffset;
|
||||
LZ4_u32 tableType;
|
||||
LZ4_u32 dictSize;
|
||||
/* Implicit padding to ensure structure is aligned */
|
||||
};
|
||||
|
||||
#define LZ4_STREAM_MINSIZE ((1UL << LZ4_MEMORY_USAGE) + 32) /* static size, for inter-version compatibility */
|
||||
union LZ4_stream_u {
|
||||
char minStateSize[LZ4_STREAM_MINSIZE];
|
||||
LZ4_stream_t_internal internal_donotuse;
|
||||
}; /* previously typedef'd to LZ4_stream_t */
|
||||
|
||||
|
||||
/*! LZ4_initStream() : v1.9.0+
|
||||
* An LZ4_stream_t structure must be initialized at least once.
|
||||
* This is automatically done when invoking LZ4_createStream(),
|
||||
* but it's not when the structure is simply declared on stack (for example).
|
||||
*
|
||||
* Use LZ4_initStream() to properly initialize a newly declared LZ4_stream_t.
|
||||
* It can also initialize any arbitrary buffer of sufficient size,
|
||||
* and will @return a pointer of proper type upon initialization.
|
||||
*
|
||||
* Note : initialization fails if size and alignment conditions are not respected.
|
||||
* In which case, the function will @return NULL.
|
||||
* Note2: An LZ4_stream_t structure guarantees correct alignment and size.
|
||||
* Note3: Before v1.9.0, use LZ4_resetStream() instead
|
||||
**/
|
||||
LZ4LIB_API LZ4_stream_t* LZ4_initStream(void* buffer, size_t size);
|
||||
|
||||
|
||||
/*! LZ4_streamDecode_t :
|
||||
* Never ever use below internal definitions directly !
|
||||
* These definitions are not API/ABI safe, and may change in future versions.
|
||||
* If you need static allocation, declare or allocate an LZ4_streamDecode_t object.
|
||||
**/
|
||||
typedef struct {
|
||||
const LZ4_byte* externalDict;
|
||||
const LZ4_byte* prefixEnd;
|
||||
size_t extDictSize;
|
||||
size_t prefixSize;
|
||||
} LZ4_streamDecode_t_internal;
|
||||
|
||||
#define LZ4_STREAMDECODE_MINSIZE 32
|
||||
union LZ4_streamDecode_u {
|
||||
char minStateSize[LZ4_STREAMDECODE_MINSIZE];
|
||||
LZ4_streamDecode_t_internal internal_donotuse;
|
||||
}; /* previously typedef'd to LZ4_streamDecode_t */
|
||||
|
||||
|
||||
|
||||
/*-************************************
|
||||
* Obsolete Functions
|
||||
**************************************/
|
||||
|
||||
/*! Deprecation warnings
|
||||
*
|
||||
* Deprecated functions make the compiler generate a warning when invoked.
|
||||
* This is meant to invite users to update their source code.
|
||||
* Should deprecation warnings be a problem, it is generally possible to disable them,
|
||||
* typically with -Wno-deprecated-declarations for gcc
|
||||
* or _CRT_SECURE_NO_WARNINGS in Visual.
|
||||
*
|
||||
* Another method is to define LZ4_DISABLE_DEPRECATE_WARNINGS
|
||||
* before including the header file.
|
||||
*/
|
||||
#ifdef LZ4_DISABLE_DEPRECATE_WARNINGS
|
||||
# define LZ4_DEPRECATED(message) /* disable deprecation warnings */
|
||||
#else
|
||||
# if defined (__cplusplus) && (__cplusplus >= 201402) /* C++14 or greater */
|
||||
# define LZ4_DEPRECATED(message) [[deprecated(message)]]
|
||||
# elif defined(_MSC_VER)
|
||||
# define LZ4_DEPRECATED(message) __declspec(deprecated(message))
|
||||
# elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ * 10 + __GNUC_MINOR__ >= 45))
|
||||
# define LZ4_DEPRECATED(message) __attribute__((deprecated(message)))
|
||||
# elif defined(__GNUC__) && (__GNUC__ * 10 + __GNUC_MINOR__ >= 31)
|
||||
# define LZ4_DEPRECATED(message) __attribute__((deprecated))
|
||||
# else
|
||||
# pragma message("WARNING: LZ4_DEPRECATED needs custom implementation for this compiler")
|
||||
# define LZ4_DEPRECATED(message) /* disabled */
|
||||
# endif
|
||||
#endif /* LZ4_DISABLE_DEPRECATE_WARNINGS */
|
||||
|
||||
/*! Obsolete compression functions (since v1.7.3) */
|
||||
LZ4_DEPRECATED("use LZ4_compress_default() instead") LZ4LIB_API int LZ4_compress(const char* src, char* dest, int srcSize);
|
||||
LZ4_DEPRECATED("use LZ4_compress_default() instead") LZ4LIB_API int LZ4_compress_limitedOutput(const char* src, char* dest, int srcSize, int maxOutputSize);
|
||||
LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") LZ4LIB_API int LZ4_compress_withState(void* state, const char* source, char* dest, int inputSize);
|
||||
LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") LZ4LIB_API int LZ4_compress_limitedOutput_withState(void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") LZ4LIB_API int LZ4_compress_continue(LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize);
|
||||
LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") LZ4LIB_API int LZ4_compress_limitedOutput_continue(LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||
|
||||
/*! Obsolete decompression functions (since v1.8.0) */
|
||||
LZ4_DEPRECATED("use LZ4_decompress_fast() instead") LZ4LIB_API int LZ4_uncompress(const char* source, char* dest, int outputSize);
|
||||
LZ4_DEPRECATED("use LZ4_decompress_safe() instead") LZ4LIB_API int LZ4_uncompress_unknownOutputSize(const char* source, char* dest, int isize, int maxOutputSize);
|
||||
|
||||
/* Obsolete streaming functions (since v1.7.0)
|
||||
* degraded functionality; do not use!
|
||||
*
|
||||
* In order to perform streaming compression, these functions depended on data
|
||||
* that is no longer tracked in the state. They have been preserved as well as
|
||||
* possible: using them will still produce a correct output. However, they don't
|
||||
* actually retain any history between compression calls. The compression ratio
|
||||
* achieved will therefore be no better than compressing each chunk
|
||||
* independently.
|
||||
*/
|
||||
LZ4_DEPRECATED("Use LZ4_createStream() instead") LZ4LIB_API void* LZ4_create(char* inputBuffer);
|
||||
LZ4_DEPRECATED("Use LZ4_createStream() instead") LZ4LIB_API int LZ4_sizeofStreamState(void);
|
||||
LZ4_DEPRECATED("Use LZ4_resetStream() instead") LZ4LIB_API int LZ4_resetStreamState(void* state, char* inputBuffer);
|
||||
LZ4_DEPRECATED("Use LZ4_saveDict() instead") LZ4LIB_API char* LZ4_slideInputBuffer(void* state);
|
||||
|
||||
/*! Obsolete streaming decoding functions (since v1.7.0) */
|
||||
LZ4_DEPRECATED("use LZ4_decompress_safe_usingDict() instead") LZ4LIB_API int LZ4_decompress_safe_withPrefix64k(const char* src, char* dst, int compressedSize, int maxDstSize);
|
||||
LZ4_DEPRECATED("use LZ4_decompress_fast_usingDict() instead") LZ4LIB_API int LZ4_decompress_fast_withPrefix64k(const char* src, char* dst, int originalSize);
|
||||
|
||||
/*! Obsolete LZ4_decompress_fast variants (since v1.9.0) :
|
||||
* These functions used to be faster than LZ4_decompress_safe(),
|
||||
* but this is no longer the case. They are now slower.
|
||||
* This is because LZ4_decompress_fast() doesn't know the input size,
|
||||
* and therefore must progress more cautiously into the input buffer to not read beyond the end of block.
|
||||
* On top of that `LZ4_decompress_fast()` is not protected vs malformed or malicious inputs, making it a security liability.
|
||||
* As a consequence, LZ4_decompress_fast() is strongly discouraged, and deprecated.
|
||||
*
|
||||
* The last remaining LZ4_decompress_fast() specificity is that
|
||||
* it can decompress a block without knowing its compressed size.
|
||||
* Such functionality can be achieved in a more secure manner
|
||||
* by employing LZ4_decompress_safe_partial().
|
||||
*
|
||||
* Parameters:
|
||||
* originalSize : is the uncompressed size to regenerate.
|
||||
* `dst` must be already allocated, its size must be >= 'originalSize' bytes.
|
||||
* @return : number of bytes read from source buffer (== compressed size).
|
||||
* The function expects to finish at block's end exactly.
|
||||
* If the source stream is detected malformed, the function stops decoding and returns a negative result.
|
||||
* note : LZ4_decompress_fast*() requires originalSize. Thanks to this information, it never writes past the output buffer.
|
||||
* However, since it doesn't know its 'src' size, it may read an unknown amount of input, past input buffer bounds.
|
||||
* Also, since match offsets are not validated, match reads from 'src' may underflow too.
|
||||
* These issues never happen if input (compressed) data is correct.
|
||||
* But they may happen if input data is invalid (error or intentional tampering).
|
||||
* As a consequence, use these functions in trusted environments with trusted data **only**.
|
||||
*/
|
||||
LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe() instead")
|
||||
LZ4LIB_API int LZ4_decompress_fast(const char* src, char* dst, int originalSize);
|
||||
LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_continue() instead")
|
||||
LZ4LIB_API int LZ4_decompress_fast_continue(LZ4_streamDecode_t* LZ4_streamDecode, const char* src, char* dst, int originalSize);
|
||||
LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_usingDict() instead")
|
||||
LZ4LIB_API int LZ4_decompress_fast_usingDict(const char* src, char* dst, int originalSize, const char* dictStart, int dictSize);
|
||||
|
||||
/*! LZ4_resetStream() :
|
||||
* An LZ4_stream_t structure must be initialized at least once.
|
||||
* This is done with LZ4_initStream(), or LZ4_resetStream().
|
||||
* Consider switching to LZ4_initStream(),
|
||||
* invoking LZ4_resetStream() will trigger deprecation warnings in the future.
|
||||
*/
|
||||
LZ4LIB_API void LZ4_resetStream(LZ4_stream_t* streamPtr);
|
||||
|
||||
|
||||
#endif /* LZ4_H_98237428734687 */
|
||||
|
||||
|
||||
#if defined (__cplusplus)
|
||||
}
|
||||
#endif
|
6
app/3rdparty/mongoose/CMakeLists.txt
vendored
6
app/3rdparty/mongoose/CMakeLists.txt
vendored
@ -1,6 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.10...3.27)
|
||||
aux_source_directory(. MONGOOSE_SOURCE)
|
||||
|
||||
add_library(mongoose ${MONGOOSE_SOURCE})
|
||||
|
||||
target_include_directories(mongoose INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
|
8847
app/3rdparty/mongoose/mongoose.c
vendored
8847
app/3rdparty/mongoose/mongoose.c
vendored
File diff suppressed because it is too large
Load Diff
1760
app/3rdparty/mongoose/mongoose.h
vendored
1760
app/3rdparty/mongoose/mongoose.h
vendored
File diff suppressed because it is too large
Load Diff
1
app/3rdparty/spdlog
vendored
1
app/3rdparty/spdlog
vendored
@ -1 +0,0 @@
|
||||
Subproject commit 91807c2e718890ca2c0c88620326c6919ce041f4
|
15
app/3rdparty/tinyxml2/CMakeLists.txt
vendored
15
app/3rdparty/tinyxml2/CMakeLists.txt
vendored
@ -1,15 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.10...3.27)
|
||||
aux_source_directory(. TINYXML2_SOURCE)
|
||||
|
||||
|
||||
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
||||
set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)
|
||||
|
||||
#add_library(tinyxml2 tinyxml2.cpp tinyxml2.h)
|
||||
|
||||
|
||||
add_library(tinyxml2 ${TINYXML2_SOURCE})
|
||||
add_library(tinyxml2::tinyxml2 ALIAS tinyxml2)
|
||||
|
||||
|
||||
target_include_directories(tinyxml2 INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
|
@ -1,7 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.10...3.27)
|
||||
|
||||
|
||||
|
||||
add_subdirectory(injector)
|
||||
add_subdirectory(wxhelper)
|
||||
|
@ -1,14 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.10...3.27)
|
||||
aux_source_directory(./src BASE_SOURCE)
|
||||
aux_source_directory(./src/include BASE_HEADER_SOURCE)
|
||||
|
||||
add_library(base ${BASE_SOURCE} ${BASE_HEADER_SOURCE})
|
||||
|
||||
target_include_directories(base PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src/include)
|
||||
|
||||
|
||||
#target_include_directories(base PUBLIC C:/other/codeSource/windows/wxhelper/app/base/src/include)
|
||||
|
||||
#install(TARGETS base LIBRARY DESTINATION base)
|
||||
|
||||
|
@ -1,30 +0,0 @@
|
||||
#ifndef BASE_BASE_CONFIG_H_
|
||||
#define BASE_BASE_CONFIG_H_
|
||||
// Lib/Dll switch
|
||||
#if !defined(BASE_EXPORTS) && !defined(BASE_IMPORTS) && !defined(BASE_STATIC)
|
||||
#define BASE_STATIC
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
#ifndef COMPILER_MSVC
|
||||
#define COMPILER_MSVC 1
|
||||
#endif
|
||||
|
||||
#if defined(BASE_IMPORTS)
|
||||
#define BASE_API __declspec(dllimport)
|
||||
#elif defined(BASE_EXPORTS)
|
||||
#define BASE_API __declspec(dllexport)
|
||||
#else
|
||||
#define BASE_API
|
||||
#endif
|
||||
|
||||
#elif defined(__GNUC__)
|
||||
#define COMPILER_GCC
|
||||
#define BASE_API
|
||||
#else
|
||||
#error "Unknown or unsupported compiler"
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
@ -1,11 +0,0 @@
|
||||
#ifndef BASE_MEMORY_H_
|
||||
#define BASE_MEMORY_H_
|
||||
#include <windows.h>
|
||||
#include <vector>
|
||||
namespace base {
|
||||
namespace memory {
|
||||
std::vector<INT64> ScanAndMatchValue(INT64 value, INT64 start,int align);
|
||||
int sunday(const byte* total, int tlen, const byte* part, int plen);
|
||||
}
|
||||
} // namespace base
|
||||
#endif
|
@ -1,73 +0,0 @@
|
||||
#ifndef BASE_UTILS_H_
|
||||
#define BASE_UTILS_H_
|
||||
#include <windows.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
namespace base {
|
||||
|
||||
namespace utils {
|
||||
std::wstring Utf8ToWstring(const std::string &str);
|
||||
|
||||
std::string WstringToUtf8(const std::wstring &str);
|
||||
|
||||
std::wstring AnsiToWstring(const std::string &input, INT64 locale = CP_ACP);
|
||||
|
||||
std::string WstringToAnsi(const std::wstring &input, INT64 locale = CP_ACP);
|
||||
|
||||
std::string WcharToUtf8(wchar_t *wstr);
|
||||
|
||||
std::string StringToHex(const std::string &str);
|
||||
|
||||
std::string HexToString(const std::string &hex_str);
|
||||
|
||||
std::string BytesToHex(const BYTE *bytes, const int length);
|
||||
|
||||
void HexToBytes(const std::string &hex, BYTE *bytes);
|
||||
|
||||
template <typename T1, typename T2>
|
||||
std::vector<T1> split(T1 str, T2 letter) {
|
||||
std::vector<T1> arr;
|
||||
size_t pos;
|
||||
while ((pos = str.find_first_of(letter)) != T1::npos) {
|
||||
T1 str1 = str.substr(0, pos);
|
||||
arr.push_back(str1);
|
||||
str = str.substr(pos + 1, str.length() - pos - 1);
|
||||
}
|
||||
arr.push_back(str);
|
||||
return arr;
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
T1 replace(T1 source, T2 replaced, T1 replaceto) {
|
||||
std::vector<T1> v_arr = split(source, replaced);
|
||||
if (v_arr.size() < 2) return source;
|
||||
T1 temp;
|
||||
for (unsigned int i = 0; i < v_arr.size() - 1; i++) {
|
||||
temp += v_arr[i];
|
||||
temp += replaceto;
|
||||
}
|
||||
temp += v_arr[v_arr.size() - 1];
|
||||
return temp;
|
||||
}
|
||||
|
||||
bool CreateConsole();
|
||||
|
||||
void CloseConsole();
|
||||
|
||||
void HideModule(HMODULE module);
|
||||
|
||||
bool IsDigit(const std::string &str);
|
||||
|
||||
std::string Bytes2Hex(const BYTE *bytes, const int length);
|
||||
|
||||
bool IsTextUtf8(const char *str, INT64 length);
|
||||
|
||||
template <typename T>
|
||||
static T *WxHeapAlloc(size_t n) {
|
||||
return (T *)HeapAlloc(GetProcessHeap(), 0, n);
|
||||
}
|
||||
|
||||
} // namespace utils
|
||||
} // namespace base
|
||||
#endif
|
@ -1,5 +0,0 @@
|
||||
#ifndef BASE_WIN_HEADER_H_
|
||||
#define BASE_WIN_HEADER_H_
|
||||
#include <windows.h>
|
||||
|
||||
#endif
|
@ -1,64 +0,0 @@
|
||||
#include "include/memory.h"
|
||||
|
||||
namespace base {
|
||||
namespace memory {
|
||||
std::vector<INT64> ScanAndMatchValue(INT64 value, INT64 start, int align) {
|
||||
SYSTEM_INFO sys_info;
|
||||
GetSystemInfo(&sys_info);
|
||||
std::vector<INT64> result;
|
||||
INT64 min_addr =
|
||||
reinterpret_cast<INT64>(sys_info.lpMinimumApplicationAddress);
|
||||
INT64 max_addr =
|
||||
reinterpret_cast<INT64>(sys_info.lpMaximumApplicationAddress);
|
||||
const INT64 page_size = sys_info.dwPageSize;
|
||||
min_addr = min_addr > start ? min_addr : start;
|
||||
|
||||
auto current_addr = min_addr;
|
||||
MEMORY_BASIC_INFORMATION mem_info = {};
|
||||
HANDLE handle = GetCurrentProcess();
|
||||
while (current_addr < max_addr) {
|
||||
VirtualQueryEx(handle, reinterpret_cast<LPVOID>(current_addr), &mem_info,
|
||||
sizeof(MEMORY_BASIC_INFORMATION));
|
||||
|
||||
if ((INT64)mem_info.RegionSize <= 0) {
|
||||
break;
|
||||
}
|
||||
INT64 region_size = mem_info.RegionSize;
|
||||
if ((mem_info.State & MEM_COMMIT) == MEM_COMMIT &&
|
||||
(mem_info.Protect & PAGE_GUARD) != PAGE_GUARD &&
|
||||
(mem_info.Protect & PAGE_NOACCESS) != PAGE_NOACCESS) {
|
||||
for (INT64 i = 0; i < region_size; i += align) {
|
||||
if (value == *(INT64 *)current_addr) {
|
||||
result.push_back(current_addr);
|
||||
}
|
||||
current_addr += align;
|
||||
}
|
||||
} else {
|
||||
current_addr += region_size;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int sunday(const byte* total, int tlen, const byte* part, int plen) {
|
||||
byte move[128] = {0};
|
||||
for (int i = 0; i < plen; i++) {
|
||||
move[part[i]] = plen - i;
|
||||
}
|
||||
int s = 0;
|
||||
int j;
|
||||
while (s <= tlen - plen) {
|
||||
j = 0;
|
||||
while (total[s + j] == part[j]) {
|
||||
j++;
|
||||
if (j == plen) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
s += move[total[s + plen]];
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
} // namespace memory
|
||||
} // namespace base
|
@ -1,225 +0,0 @@
|
||||
#include "include/utils.h"
|
||||
|
||||
#include <winternl.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "utils.h"
|
||||
namespace base {
|
||||
namespace utils {
|
||||
const std::string hex_table = "0123456789abcdef";
|
||||
std::wstring Utf8ToWstring(const std::string &str) {
|
||||
return AnsiToWstring(str, CP_UTF8);
|
||||
}
|
||||
|
||||
std::string WstringToUtf8(const std::wstring &str) {
|
||||
return WstringToAnsi(str, CP_UTF8);
|
||||
}
|
||||
|
||||
std::wstring AnsiToWstring(const std::string &input, INT64 locale) {
|
||||
int wchar_len = MultiByteToWideChar(locale, 0, input.c_str(), -1, NULL, 0);
|
||||
if (wchar_len > 0) {
|
||||
std::vector<wchar_t> temp(wchar_len);
|
||||
MultiByteToWideChar(CP_UTF8, 0, input.c_str(), -1, &temp[0], wchar_len);
|
||||
return std::wstring(&temp[0]);
|
||||
}
|
||||
return std::wstring();
|
||||
}
|
||||
|
||||
std::string WstringToAnsi(const std::wstring &input, INT64 locale) {
|
||||
int char_len = WideCharToMultiByte(locale, 0, input.c_str(), -1, 0, 0, 0, 0);
|
||||
if (char_len > 0) {
|
||||
std::vector<char> temp(char_len);
|
||||
WideCharToMultiByte(locale, 0, input.c_str(), -1, &temp[0], char_len, 0, 0);
|
||||
return std::string(&temp[0]);
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::string WcharToUtf8(wchar_t *wstr) {
|
||||
int c_size = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, FALSE);
|
||||
if (c_size > 0) {
|
||||
char *buffer = new char[c_size];
|
||||
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, buffer, c_size, NULL, FALSE);
|
||||
std::string str(buffer);
|
||||
delete[] buffer;
|
||||
buffer = NULL;
|
||||
return str;
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::string StringToHex(const std::string &str) {
|
||||
std::string sb;
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
sb += hex_table.at((str[i] & 0xf0) >> 4);
|
||||
sb += hex_table.at((str[i] & 0x0f) >> 0);
|
||||
}
|
||||
return sb;
|
||||
}
|
||||
|
||||
std::string HexToString(const std::string &hex_str) {
|
||||
std::string ret;
|
||||
for (int i = 0; i < hex_str.length(); i += 2) {
|
||||
ret += BYTE(hex_table.find(hex_str.at(i)) << 4 |
|
||||
hex_table.find(hex_str.at(i + 1)));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string BytesToHex(const BYTE *bytes, const int length) {
|
||||
if (bytes == NULL) {
|
||||
return "";
|
||||
}
|
||||
std::string buff;
|
||||
const int len = length;
|
||||
for (int j = 0; j < len; j++) {
|
||||
int high = bytes[j] / 16, low = bytes[j] % 16;
|
||||
buff += (high < 10) ? ('0' + high) : ('a' + high - 10);
|
||||
buff += (low < 10) ? ('0' + low) : ('a' + low - 10);
|
||||
}
|
||||
return buff;
|
||||
}
|
||||
void HexToBytes(const std::string &hex, BYTE *bytes) {
|
||||
int byte_len = hex.length() / 2;
|
||||
std::string str;
|
||||
unsigned int n;
|
||||
for (int i = 0; i < byte_len; i++) {
|
||||
str = hex.substr(i * 2, 2);
|
||||
sscanf_s(str.c_str(), "%x", &n);
|
||||
bytes[i] = n;
|
||||
}
|
||||
}
|
||||
|
||||
bool CreateConsole() {
|
||||
if (AllocConsole()) {
|
||||
AttachConsole(GetCurrentProcessId());
|
||||
FILE *retStream;
|
||||
freopen_s(&retStream, "CONOUT$", "w", stdout);
|
||||
if (!retStream) throw std::runtime_error("Stdout redirection failed.");
|
||||
freopen_s(&retStream, "CONOUT$", "w", stderr);
|
||||
if (!retStream) throw std::runtime_error("Stderr redirection failed.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CloseConsole() {
|
||||
fclose(stdin);
|
||||
fclose(stdout);
|
||||
fclose(stderr);
|
||||
FreeConsole();
|
||||
}
|
||||
|
||||
void HideModule(HMODULE module) {
|
||||
#ifdef _WIN64
|
||||
PPEB peb = (PPEB)__readgsqword(0x60);
|
||||
PPEB_LDR_DATA ldr = peb->Ldr;
|
||||
|
||||
void *cur_ptr = *((void **)((unsigned char *)ldr + 0x18));
|
||||
void *next_ptr = cur_ptr;
|
||||
do {
|
||||
void *next = *((void **)((unsigned char *)next_ptr));
|
||||
void *last = *((void **)((unsigned char *)next_ptr + 0x8));
|
||||
void *base_addr = *((void **)((unsigned char *)next_ptr + 0x30));
|
||||
if (base_addr == module) {
|
||||
*((void **)((unsigned char *)last)) = next;
|
||||
*((void **)((unsigned char *)next + 0x8)) = last;
|
||||
cur_ptr = next;
|
||||
}
|
||||
next_ptr = *((void **)next_ptr);
|
||||
} while (cur_ptr != next_ptr);
|
||||
#else
|
||||
void *peb_ptr = nullptr;
|
||||
_asm {
|
||||
PUSH EAX
|
||||
MOV EAX, FS:[0x30]
|
||||
MOV peb_ptr, EAX
|
||||
POP EAX
|
||||
}
|
||||
void *ldr_ptr = *((void **)((unsigned char *)peb_ptr + 0xc));
|
||||
void *cur_ptr = *((void **)((unsigned char *)ldr_ptr + 0x0c));
|
||||
void *next_ptr = cur_ptr;
|
||||
do {
|
||||
void *next = *((void **)((unsigned char *)next_ptr));
|
||||
void *last = *((void **)((unsigned char *)next_ptr + 0x4));
|
||||
void *base_addr = *((void **)((unsigned char *)next_ptr + 0x18));
|
||||
if (base_addr == module) {
|
||||
*((void **)((unsigned char *)last)) = next;
|
||||
*((void **)((unsigned char *)next + 0x4)) = last;
|
||||
cur_ptr = next;
|
||||
}
|
||||
next_ptr = *((void **)next_ptr);
|
||||
} while (cur_ptr != next_ptr);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool IsDigit(const std::string &str) {
|
||||
if (str.length() == 0) {
|
||||
return false;
|
||||
}
|
||||
for (auto it : str) {
|
||||
if (it < '0' || it > '9') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string Bytes2Hex(const BYTE *bytes, const int length) {
|
||||
if (bytes == NULL) {
|
||||
return "";
|
||||
}
|
||||
std::string buff;
|
||||
const int len = length;
|
||||
for (int j = 0; j < len; j++) {
|
||||
int high = bytes[j] / 16, low = bytes[j] % 16;
|
||||
buff += (high < 10) ? ('0' + high) : ('a' + high - 10);
|
||||
buff += (low < 10) ? ('0' + low) : ('a' + low - 10);
|
||||
}
|
||||
return buff;
|
||||
}
|
||||
|
||||
bool IsTextUtf8(const char *str, INT64 length) {
|
||||
char endian = 1;
|
||||
bool littlen_endian = (*(char *)&endian == 1);
|
||||
|
||||
size_t i;
|
||||
int bytes_num;
|
||||
unsigned char chr;
|
||||
|
||||
i = 0;
|
||||
bytes_num = 0;
|
||||
while (i < length) {
|
||||
if (littlen_endian) {
|
||||
chr = *(str + i);
|
||||
} else { // Big Endian
|
||||
chr = (*(str + i) << 8) | *(str + i + 1);
|
||||
i++;
|
||||
}
|
||||
|
||||
if (bytes_num == 0) {
|
||||
if ((chr & 0x80) != 0) {
|
||||
while ((chr & 0x80) != 0) {
|
||||
chr <<= 1;
|
||||
bytes_num++;
|
||||
}
|
||||
if ((bytes_num < 2) || (bytes_num > 6)) {
|
||||
return false;
|
||||
}
|
||||
bytes_num--;
|
||||
}
|
||||
} else {
|
||||
if ((chr & 0xC0) != 0x80) {
|
||||
return false;
|
||||
}
|
||||
bytes_num--;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return (bytes_num == 0);
|
||||
}
|
||||
|
||||
} // namespace utils
|
||||
} // namespace base
|
@ -1,62 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.10...3.27)
|
||||
project(wxhelper VERSION 1.0.0)
|
||||
# enable_language(ASM_MASM)
|
||||
# add_compile_options("/experimental:module")
|
||||
|
||||
message(${CMAKE_VERSION})
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17 /MD /EHsc")
|
||||
file(GLOB CPP_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c )
|
||||
|
||||
file(GLOB ASM_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.asm )
|
||||
|
||||
include_directories(${VCPKG_INSTALLED_DIR}/x64-windows/include ${DETOURS_INCLUDE_DIRS})
|
||||
|
||||
|
||||
add_subdirectory(../3rdparty 3rdparty)
|
||||
|
||||
add_subdirectory(../base base)
|
||||
|
||||
|
||||
|
||||
find_path(DETOURS_INCLUDE_DIRS "detours/detours.h")
|
||||
find_library(DETOURS_LIBRARY detours REQUIRED)
|
||||
|
||||
find_package(nlohmann_json CONFIG REQUIRED)
|
||||
|
||||
add_library(wxhelper SHARED ${CPP_FILES} ${ASM_FILES})
|
||||
message(11233)
|
||||
message(${PROJECT_SOURCE_DIR})
|
||||
target_include_directories(wxhelper
|
||||
PRIVATE ${DETOURS_INCLUDE_DIRS}
|
||||
PRIVATE ../base/src/include
|
||||
PRIVATE ../3rdparty/spdlog/include
|
||||
PRIVATE ../3rdparty/base64
|
||||
PRIVATE ../3rdparty/lz4
|
||||
PRIVATE ../3rdparty/mongoose
|
||||
PRIVATE ../3rdparty/tinyxml2
|
||||
PRIVATE ../base/src/include
|
||||
)
|
||||
|
||||
target_link_libraries(wxhelper
|
||||
PRIVATE ${DETOURS_LIBRARY}
|
||||
PRIVATE spdlog::spdlog
|
||||
PRIVATE lz4
|
||||
PRIVATE base64
|
||||
PRIVATE mongoose
|
||||
PRIVATE nlohmann_json::nlohmann_json
|
||||
PRIVATE base
|
||||
PRIVATE tinyxml2
|
||||
)
|
||||
|
||||
SET_TARGET_PROPERTIES(wxhelper PROPERTIES LINKER_LANGUAGE C
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
|
||||
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
|
||||
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
|
||||
OUTPUT_NAME "wxhelper"
|
||||
PREFIX "")
|
||||
|
@ -1,30 +0,0 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "spdlog/sinks/daily_file_sink.h"
|
||||
#include "spdlog/sinks/rotating_file_sink.h"
|
||||
#include "spdlog/sinks/stdout_color_sinks.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "windows.h"
|
||||
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO
|
||||
namespace wxhelper {
|
||||
Config::Config(/* args */) {}
|
||||
|
||||
Config::~Config() {}
|
||||
|
||||
void Config::Initialize() {
|
||||
port_ = GetPrivateProfileInt("config", "Port", 19088, "./config.ini");
|
||||
hidden_dll_ =
|
||||
GetPrivateProfileInt("config", "HiddenDll", 1, "./config.ini");
|
||||
auto logger =
|
||||
spdlog::daily_logger_mt("daily_logger", "logs/daily.txt", 23, 59);
|
||||
logger->flush_on(spdlog::level::err);
|
||||
spdlog::set_default_logger(logger);
|
||||
spdlog::flush_every(std::chrono::seconds(3));
|
||||
spdlog::set_level(spdlog::level::debug);
|
||||
spdlog::set_pattern("%Y-%m-%d %H:%M:%S [%l] [%t] - <%s>|<%#>|<%!>,%v");
|
||||
}
|
||||
int Config::GetPort() { return port_; }
|
||||
|
||||
int Config::GetHideDll() { return hidden_dll_; }
|
||||
|
||||
} // namespace wxhelper
|
@ -1,59 +0,0 @@
|
||||
#include "global_manager.h"
|
||||
|
||||
#include "db.h"
|
||||
#include "http_url_handler.h"
|
||||
#include "thread_pool.h"
|
||||
#include "utils.h"
|
||||
#include "wechat_service.h"
|
||||
#include "wxutils.h"
|
||||
namespace wxhelper {
|
||||
|
||||
GlobalManager::~GlobalManager() {}
|
||||
|
||||
void GlobalManager::initialize(HMODULE module) {
|
||||
state = GlobalContextState::INITIALIZING;
|
||||
module_ = module;
|
||||
config = std::unique_ptr<Config>(new Config());
|
||||
config->Initialize();
|
||||
if (config->GetHideDll()) {
|
||||
base::utils::HideModule(module);
|
||||
}
|
||||
|
||||
UINT64 base = wxutils::GetWeChatWinBase();
|
||||
DB::GetInstance().init(base);
|
||||
WechatService::GetInstance().SetBaseAddr(base);
|
||||
http_server = std::unique_ptr<http::HttpServer>(
|
||||
new http::HttpServer(config->GetPort()));
|
||||
http_server->AddHttpApiUrl("/api/sendTextMsg", SendTextMsg);
|
||||
http_server->AddHttpApiUrl("/api/hookSyncMsg", HookSyncMsg);
|
||||
http_server->AddHttpApiUrl("/api/getContactList", GetContacts);
|
||||
http_server->AddHttpApiUrl("/api/unhookSyncMsg", UnHookSyncMsg);
|
||||
http_server->AddHttpApiUrl("/api/checkLogin", CheckLogin);
|
||||
http_server->AddHttpApiUrl("/api/userInfo", GetSelfInfo);
|
||||
http_server->AddHttpApiUrl("/api/getDBInfo", GetDBInfo);
|
||||
http_server->AddHttpApiUrl("/api/execSql", ExecSql);
|
||||
http_server->AddHttpApiUrl("/api/lockWeChat", LockWeChat);
|
||||
http_server->AddHttpApiUrl("/api/unlockWeChat", UnLockWeChat);
|
||||
http_server->AddHttpApiUrl("/api/clickEnterWeChat", EnterWeChat);
|
||||
http_server->AddHttpApiUrl("/api/forwardMsg", ForwardMsg);
|
||||
http_server->AddHttpApiUrl("/api/sendImagesMsg", SendImageMsg);
|
||||
http_server->AddHttpApiUrl("/api/sendFileMsg", SendFileMsg);
|
||||
http_server->AddHttpApiUrl("/api/sendAtText", SendAtText);
|
||||
http_server->AddHttpApiUrl("/api/sendMultiAtText", SendMultiAtText);
|
||||
http_server->AddHttpApiUrl("/api/getLoginUrl", GetLoginUrl);
|
||||
http_server->AddHttpApiUrl("/api/translateVoice", TranslateVoice);
|
||||
http_server->AddHttpApiUrl("/api/getTranslateVoiceText", GetTranslateVoiceText);
|
||||
|
||||
|
||||
http_server->Start();
|
||||
base::ThreadPool::GetInstance().Create(2, 8);
|
||||
|
||||
state = GlobalContextState::INITIALIZED;
|
||||
}
|
||||
|
||||
void GlobalManager::finally() {
|
||||
if (http_server) {
|
||||
http_server->Stop();
|
||||
}
|
||||
}
|
||||
} // namespace wxhelper
|
@ -1,73 +0,0 @@
|
||||
#include "http_client.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
void HttpClient::SendRequest(const std::string &content) {
|
||||
struct mg_mgr mgr;
|
||||
Data data;
|
||||
data.done = false;
|
||||
data.post_data = content;
|
||||
mg_mgr_init(&mgr);
|
||||
mg_http_connect(&mgr, kUrl.c_str(), OnHttpEvent, &data);
|
||||
while (!data.done) {
|
||||
mg_mgr_poll(&mgr, 500);
|
||||
}
|
||||
mg_mgr_free(&mgr);
|
||||
data.done = false;
|
||||
}
|
||||
|
||||
void HttpClient::SetConfig(std::string url, uint64_t timeout) {
|
||||
kUrl = url;
|
||||
kTimeout = timeout;
|
||||
}
|
||||
|
||||
void HttpClient::OnHttpEvent(struct mg_connection *c, int ev, void *ev_data,
|
||||
void *fn_data) {
|
||||
const char *s_url = kUrl.c_str();
|
||||
Data *data = (Data *)fn_data;
|
||||
if (ev == MG_EV_OPEN) {
|
||||
// Connection created. Store connect expiration time in c->data
|
||||
*(uint64_t *)c->data = mg_millis() + kTimeout;
|
||||
} else if (ev == MG_EV_POLL) {
|
||||
if (mg_millis() > *(uint64_t *)c->data &&
|
||||
(c->is_connecting || c->is_resolving)) {
|
||||
mg_error(c, "Connect timeout");
|
||||
}
|
||||
} else if (ev == MG_EV_CONNECT) {
|
||||
struct mg_str host = mg_url_host(s_url);
|
||||
if (mg_url_is_ssl(s_url)) {
|
||||
// no implement
|
||||
}
|
||||
// Send request
|
||||
size_t content_length = data->post_data.size();
|
||||
mg_printf(c,
|
||||
"POST %s HTTP/1.0\r\n"
|
||||
"Host: %.*s\r\n"
|
||||
"Content-Type: application/json\r\n"
|
||||
"Content-Length: %d\r\n"
|
||||
"\r\n",
|
||||
mg_url_uri(s_url), (int)host.len, host.ptr, content_length);
|
||||
mg_send(c, data->post_data.c_str(), content_length);
|
||||
} else if (ev == MG_EV_HTTP_MSG) {
|
||||
// Response is received. Print it
|
||||
#ifdef _DEBUG
|
||||
struct mg_http_message *hm = (struct mg_http_message *)ev_data;
|
||||
printf("%.*s", (int)hm->message.len, hm->message.ptr);
|
||||
#endif
|
||||
// c->is_closing = 1; // Tell mongoose to close this connection
|
||||
c->is_draining = 1;
|
||||
data->done = true; // Tell event loop to stops
|
||||
} else if (ev == MG_EV_ERROR) {
|
||||
data->done = true; // Error, tell event loop to stop
|
||||
} else if (ev == MG_EV_CLOSE) {
|
||||
if (!data->done) {
|
||||
data->done = true;
|
||||
}
|
||||
} else if (ev == MG_EV_HTTP_CHUNK) {
|
||||
mg_error(c, "http chunk no implement");
|
||||
c->is_closing = 1;
|
||||
data->done = true;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace http
|
@ -1,26 +0,0 @@
|
||||
#ifndef WXHELPER_HTTP_CLIENT_H_
|
||||
#define WXHELPER_HTTP_CLIENT_H_
|
||||
#include <string>
|
||||
|
||||
#include "mongoose.h"
|
||||
#include "singleton.h"
|
||||
|
||||
namespace http {
|
||||
static std::string kUrl = "http://127.0.0.1:8000";
|
||||
static uint64_t kTimeout = 3000;
|
||||
struct Data {
|
||||
bool done;
|
||||
std::string post_data;
|
||||
};
|
||||
|
||||
class HttpClient {
|
||||
public:
|
||||
static void SendRequest(const std::string &content);
|
||||
static void SetConfig(std::string url, uint64_t timeout);
|
||||
static void OnHttpEvent(struct mg_connection *c, int ev, void *ev_data,
|
||||
void *fn_data);
|
||||
|
||||
};
|
||||
|
||||
} // namespace http
|
||||
#endif
|
@ -1,148 +0,0 @@
|
||||
#include "http_server.h"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "utils.h"
|
||||
namespace http {
|
||||
|
||||
HttpServer::HttpServer(int port) {
|
||||
port_ = port;
|
||||
running_ = false;
|
||||
mg_mgr_init(&mgr_);
|
||||
}
|
||||
|
||||
HttpServer::~HttpServer() {
|
||||
if (thread_ != nullptr) {
|
||||
CloseHandle(thread_);
|
||||
}
|
||||
mg_mgr_free(&mgr_);
|
||||
}
|
||||
|
||||
bool HttpServer::Start() {
|
||||
if (running_) {
|
||||
return true;
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
base::utils::CreateConsole();
|
||||
#endif
|
||||
running_ = true;
|
||||
thread_ = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)StartHttpServer, this,
|
||||
NULL, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HttpServer::Stop() {
|
||||
if (!running_) {
|
||||
return true;
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
base::utils::CloseConsole();
|
||||
#endif
|
||||
running_ = false;
|
||||
if (thread_) {
|
||||
WaitForSingleObject(thread_, -1);
|
||||
CloseHandle(thread_);
|
||||
thread_ = NULL;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int HttpServer::GetPort() { return port_; }
|
||||
bool HttpServer::GetRunning() { return running_; }
|
||||
|
||||
const mg_mgr *HttpServer::GetMgr() { return &mgr_; }
|
||||
|
||||
void HttpServer::AddHttpApiUrl(const std::string &uri, HttpCbFunc func) {
|
||||
http_api_url_map_[uri] = func;
|
||||
}
|
||||
|
||||
void HttpServer::StartHttpServer(HttpServer *server) {
|
||||
int port = server->GetPort();
|
||||
std::string lsten_addr = "http://0.0.0.0:" + std::to_string(port);
|
||||
if (mg_http_listen(const_cast<mg_mgr *>(server->GetMgr()), lsten_addr.c_str(),
|
||||
EventHandler, server) == NULL) {
|
||||
SPDLOG_INFO("http server listen fail.port:{}", port);
|
||||
return;
|
||||
}
|
||||
for (;;) {
|
||||
mg_mgr_poll(const_cast<mg_mgr *>(server->GetMgr()), 100);
|
||||
}
|
||||
}
|
||||
|
||||
void HttpServer::EventHandler(struct mg_connection *c, int ev, void *ev_data,
|
||||
void *fn_data) {
|
||||
if (ev == MG_EV_OPEN) {
|
||||
} else if (ev == MG_EV_HTTP_MSG) {
|
||||
struct mg_http_message *hm = (struct mg_http_message *)ev_data;
|
||||
if (mg_http_match_uri(hm, "/websocket")) {
|
||||
mg_ws_upgrade(c, hm, NULL);
|
||||
} else if (mg_http_match_uri(hm, "/api/*")) {
|
||||
HandleHttpRequest(c, hm, fn_data);
|
||||
} else {
|
||||
nlohmann::json res = {{"code", 400},
|
||||
{"msg", "invalid url, please check url"},
|
||||
{"data", NULL}};
|
||||
std::string ret = res.dump();
|
||||
mg_http_reply(c, 200, "Content-Type: application/json\r\n", "%s\n",
|
||||
ret.c_str());
|
||||
}
|
||||
} else if (ev == MG_EV_WS_MSG) {
|
||||
HandleWebsocketRequest(c, ev_data, fn_data);
|
||||
}
|
||||
(void)fn_data;
|
||||
}
|
||||
|
||||
void HttpServer::HandleHttpRequest(struct mg_connection *c, void *ev_data,
|
||||
void *fn_data) {
|
||||
struct mg_http_message *hm = (struct mg_http_message *)ev_data;
|
||||
std::string ret = R"({"code":200,"msg":"success"})";
|
||||
try {
|
||||
ret = HttpDispatch(c, hm, fn_data);
|
||||
} catch (nlohmann::json::exception &e) {
|
||||
nlohmann::json res = {{"code", "500"}, {"msg", e.what()}, {"data", NULL}};
|
||||
ret = res.dump();
|
||||
}
|
||||
if (ret != "") {
|
||||
mg_http_reply(c, 200, "Content-Type: application/json\r\n", "%s\n",
|
||||
ret.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void HttpServer::HandleWebsocketRequest(struct mg_connection *c, void *ev_data,
|
||||
void *fn_data) {
|
||||
// Got websocket frame. Received data is wm->data. Echo it back!
|
||||
struct mg_ws_message *wm = (struct mg_ws_message *)ev_data;
|
||||
mg_ws_send(c, wm->data.ptr, wm->data.len, WEBSOCKET_OP_TEXT);
|
||||
}
|
||||
|
||||
std::string HttpServer::HttpDispatch(struct mg_connection *c,
|
||||
struct mg_http_message *hm,
|
||||
void *fn_data) {
|
||||
std::string ret;
|
||||
if (mg_vcasecmp(&hm->method, "GET") == 0) {
|
||||
nlohmann::json ret_data = {
|
||||
{"code", 200},
|
||||
{"data", {}},
|
||||
{"msg", "the get method is not supported.please use post method."}};
|
||||
ret = ret_data.dump();
|
||||
return ret;
|
||||
}
|
||||
std::string api_uri(hm->uri.ptr,hm->uri.len);
|
||||
HttpServer *server = (HttpServer *)fn_data;
|
||||
return server->ProcessHttpRequest(api_uri, hm);
|
||||
}
|
||||
|
||||
std::string HttpServer::ProcessHttpRequest(const std::string &url,
|
||||
mg_http_message *hm) {
|
||||
SPDLOG_INFO("http server process request url :{}", url);
|
||||
if (http_api_url_map_.find(url) != http_api_url_map_.end()) {
|
||||
return http_api_url_map_[url](hm);
|
||||
} else {
|
||||
nlohmann::json ret_data = {
|
||||
{"code", 200}, {"data", {}}, {"msg", "the url is not supported"}};
|
||||
return ret_data.dump();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace http
|
@ -1,49 +0,0 @@
|
||||
#ifndef WXHELPER_HTTP_SERVER_H_
|
||||
#define WXHELPER_HTTP_SERVER_H_
|
||||
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "mongoose.h"
|
||||
namespace http {
|
||||
typedef std::function<std::string(struct mg_http_message *)> HttpCbFunc;
|
||||
class HttpServer {
|
||||
public:
|
||||
explicit HttpServer(int port);
|
||||
HttpServer(const HttpServer &) = delete;
|
||||
HttpServer(HttpServer &&) = delete;
|
||||
HttpServer &operator=(const HttpServer &) = delete;
|
||||
~HttpServer();
|
||||
|
||||
bool Start();
|
||||
bool Stop();
|
||||
int GetPort();
|
||||
bool GetRunning();
|
||||
const mg_mgr *GetMgr();
|
||||
void AddHttpApiUrl(const std::string &uri, HttpCbFunc func);
|
||||
|
||||
private:
|
||||
int port_;
|
||||
bool running_;
|
||||
struct mg_mgr mgr_;
|
||||
HANDLE thread_;
|
||||
std::map<const std::string, HttpCbFunc> http_api_url_map_;
|
||||
|
||||
static void StartHttpServer(HttpServer *server);
|
||||
static void EventHandler(struct mg_connection *c, int ev, void *ev_data,
|
||||
void *fn_data);
|
||||
|
||||
static void HandleHttpRequest(struct mg_connection *c, void *ev_data,
|
||||
void *fn_data);
|
||||
static void HandleWebsocketRequest(struct mg_connection *c, void *ev_data,
|
||||
void *fn_data);
|
||||
static std::string HttpDispatch(struct mg_connection *c,
|
||||
struct mg_http_message *hm, void *fn_data);
|
||||
std::string ProcessHttpRequest(const std::string &url,
|
||||
struct mg_http_message *hm);
|
||||
};
|
||||
|
||||
} // namespace http
|
||||
|
||||
#endif
|
@ -1,324 +0,0 @@
|
||||
#include "http_url_handler.h"
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "db.h"
|
||||
#include "utils.h"
|
||||
#include "wechat_hook.h"
|
||||
#include "wechat_service.h"
|
||||
|
||||
#define STR2ULL(str) (base::utils::IsDigit(str) ? stoull(str) : 0)
|
||||
#define STR2LL(str) (base::utils::IsDigit(str) ? stoll(str) : 0)
|
||||
#define STR2I(str) (base::utils::IsDigit(str) ? stoi(str) : 0)
|
||||
namespace wxhelper {
|
||||
|
||||
std::wstring GetWStringParam(nlohmann::json data, std::string key) {
|
||||
return base::utils::Utf8ToWstring(data[key].get<std::string>());
|
||||
}
|
||||
|
||||
std::vector<std::wstring> GetArrayParam(nlohmann::json data, std::string key) {
|
||||
std::vector<std::wstring> result;
|
||||
std::wstring param = GetWStringParam(data, key);
|
||||
result = base::utils::split(param, L',');
|
||||
return result;
|
||||
}
|
||||
|
||||
int GetIntParam(nlohmann::json data, std::string key) {
|
||||
int result;
|
||||
try {
|
||||
result = data[key].get<int>();
|
||||
} catch (nlohmann::json::exception) {
|
||||
result = STR2I(data[key].get<std::string>());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool GetBoolParam(nlohmann::json data, std::string key) {
|
||||
return data[key].get<bool>();
|
||||
}
|
||||
|
||||
std::string GetStringParam(nlohmann::json data, std::string key) {
|
||||
return data[key].get<std::string>();
|
||||
}
|
||||
|
||||
INT64 GetInt64Param(nlohmann::json data, std::string key) {
|
||||
INT64 result;
|
||||
try {
|
||||
result = data[key].get<INT64>();
|
||||
} catch (nlohmann::json::exception) {
|
||||
result = STR2LL(data[key].get<std::string>());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string SendTextMsg(mg_http_message* hm) {
|
||||
nlohmann::json j_param = nlohmann::json::parse(
|
||||
hm->body.ptr, hm->body.ptr + hm->body.len, nullptr, false);
|
||||
std::wstring wxid = GetWStringParam(j_param, "wxid");
|
||||
std::wstring msg = GetWStringParam(j_param, "msg");
|
||||
INT64 success = WechatService::GetInstance().SendTextMsg(wxid, msg);
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"data", {}}, {"msg", "success"}};
|
||||
std::string ret = ret_data.dump();
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string HookSyncMsg(mg_http_message* hm) {
|
||||
nlohmann::json j_param = nlohmann::json::parse(
|
||||
hm->body.ptr, hm->body.ptr + hm->body.len, nullptr, false);
|
||||
int port = GetIntParam(j_param, "port");
|
||||
std::string ip = GetStringParam(j_param, "ip");
|
||||
bool enable = GetBoolParam(j_param, "enableHttp");
|
||||
std::string url = "http:://127.0.0.1:19088";
|
||||
uint64_t timeout = 3000;
|
||||
if (enable) {
|
||||
url = GetStringParam(j_param, "url");
|
||||
timeout = GetIntParam(j_param, "timeout");
|
||||
}
|
||||
hook::WechatHookParam param = {
|
||||
ip, url, port, enable, timeout,
|
||||
};
|
||||
hook::WechatHook::GetInstance().Init(param);
|
||||
INT64 success = hook::WechatHook::GetInstance().HookSyncMsg();
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"data", {}}, {"msg", "success"}};
|
||||
std::string ret = ret_data.dump();
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string GetContacts(mg_http_message* hm) {
|
||||
std::vector<common::ContactInner> vec;
|
||||
INT64 success = WechatService::GetInstance().GetContacts(vec);
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"data", {}}, {"msg", "success"}};
|
||||
for (unsigned int i = 0; i < vec.size(); i++) {
|
||||
nlohmann::json item = {
|
||||
{"customAccount", vec[i].custom_account},
|
||||
{"encryptName", vec[i].encrypt_name},
|
||||
{"type", vec[i].type},
|
||||
{"verifyFlag", vec[i].verify_flag},
|
||||
{"wxid", vec[i].wxid},
|
||||
{"nickname", vec[i].nickname},
|
||||
{"pinyin", vec[i].pinyin},
|
||||
{"pinyinAll", vec[i].pinyin_all},
|
||||
{"reserved1", vec[i].reserved1},
|
||||
{"reserved2", vec[i].reserved2},
|
||||
};
|
||||
ret_data["data"].push_back(item);
|
||||
}
|
||||
std::string ret = ret_data.dump();
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string UnHookSyncMsg(mg_http_message* hm) {
|
||||
INT64 success = hook::WechatHook::GetInstance().UnHookSyncMsg();
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"data", {}}, {"msg", "success"}};
|
||||
return ret_data.dump();
|
||||
}
|
||||
|
||||
std::string CheckLogin(mg_http_message* hm) {
|
||||
INT64 success = WechatService::GetInstance().CheckLogin();
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"data", {}}, {"msg", "success"}};
|
||||
return ret_data.dump();
|
||||
}
|
||||
|
||||
std::string GetSelfInfo(mg_http_message* hm) {
|
||||
common::SelfInfoInner self_info;
|
||||
INT64 success = WechatService::GetInstance().GetSelfInfo(self_info);
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"data", {}}, {"msg", "success"}};
|
||||
if (success) {
|
||||
nlohmann::json j_info = {
|
||||
{"name", self_info.name},
|
||||
{"city", self_info.city},
|
||||
{"province", self_info.province},
|
||||
{"country", self_info.country},
|
||||
{"account", self_info.account},
|
||||
{"wxid", self_info.wxid},
|
||||
{"mobile", self_info.mobile},
|
||||
{"headImage", self_info.head_img},
|
||||
{"signature", self_info.signature},
|
||||
{"dataSavePath", self_info.data_save_path},
|
||||
{"currentDataPath", self_info.current_data_path},
|
||||
{"dbKey", self_info.db_key},
|
||||
{"publicKey", self_info.public_key},
|
||||
{"privateKey", self_info.private_key},
|
||||
};
|
||||
ret_data["data"] = j_info;
|
||||
}
|
||||
return ret_data.dump();
|
||||
}
|
||||
|
||||
std::string GetDBInfo(mg_http_message* hm) {
|
||||
std::vector<void*> v_ptr = wxhelper::DB::GetInstance().GetWeChatDbHandles();
|
||||
nlohmann::json ret_data = {{"data", nlohmann::json::array()}};
|
||||
for (unsigned int i = 0; i < v_ptr.size(); i++) {
|
||||
nlohmann::json db_info;
|
||||
db_info["tables"] = nlohmann::json::array();
|
||||
common::DatabaseInfo* db =
|
||||
reinterpret_cast<common::DatabaseInfo*>(v_ptr[i]);
|
||||
db_info["handle"] = db->handle;
|
||||
std::wstring dbname(db->db_name);
|
||||
db_info["databaseName"] = base::utils::WstringToUtf8(dbname);
|
||||
for (auto table : db->tables) {
|
||||
nlohmann::json table_info = {{"name", table.name},
|
||||
{"tableName", table.table_name},
|
||||
{"sql", table.sql},
|
||||
{"rootpage", table.rootpage}};
|
||||
db_info["tables"].push_back(table_info);
|
||||
}
|
||||
ret_data["data"].push_back(db_info);
|
||||
}
|
||||
ret_data["code"] = 1;
|
||||
ret_data["msg"] = "success";
|
||||
return ret_data.dump();
|
||||
}
|
||||
|
||||
std::string ExecSql(mg_http_message* hm) {
|
||||
nlohmann::json j_param = nlohmann::json::parse(
|
||||
hm->body.ptr, hm->body.ptr + hm->body.len, nullptr, false);
|
||||
UINT64 db_handle = GetInt64Param(j_param, "dbHandle");
|
||||
std::string sql = GetStringParam(j_param, "sql");
|
||||
std::vector<std::vector<std::string>> items;
|
||||
int success =
|
||||
wxhelper::DB::GetInstance().Select(db_handle, sql.c_str(), items);
|
||||
nlohmann::json ret_data = {
|
||||
{"data", nlohmann::json::array()}, {"code", success}, {"msg", "success"}};
|
||||
if (success == 0) {
|
||||
ret_data["msg"] = "no data";
|
||||
return ret_data.dump();
|
||||
}
|
||||
for (auto it : items) {
|
||||
nlohmann::json temp_arr = nlohmann::json::array();
|
||||
for (size_t i = 0; i < it.size(); i++) {
|
||||
temp_arr.push_back(it[i]);
|
||||
}
|
||||
ret_data["data"].push_back(temp_arr);
|
||||
}
|
||||
return ret_data.dump();
|
||||
}
|
||||
|
||||
std::string LockWeChat(struct mg_http_message* hm) {
|
||||
INT64 success = WechatService::GetInstance().LockWeChat();
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"data", {}}, {"msg", "success"}};
|
||||
return ret_data.dump();
|
||||
}
|
||||
|
||||
std::string UnLockWeChat(struct mg_http_message* hm) {
|
||||
INT64 success = WechatService::GetInstance().UnLockWeChat();
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"data", {}}, {"msg", "success"}};
|
||||
return ret_data.dump();
|
||||
}
|
||||
|
||||
|
||||
std::string EnterWeChat(struct mg_http_message* hm) {
|
||||
INT64 success = WechatService::GetInstance().EnterWeChat();
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"data", {}}, {"msg", "success"}};
|
||||
return ret_data.dump();
|
||||
}
|
||||
|
||||
std::string ForwardMsg(struct mg_http_message* hm){
|
||||
nlohmann::json j_param = nlohmann::json::parse(
|
||||
hm->body.ptr, hm->body.ptr + hm->body.len, nullptr, false);
|
||||
INT64 msg_id = GetInt64Param(j_param, "msgId");
|
||||
std::wstring wxid = GetWStringParam(j_param, "wxid");
|
||||
INT64 success =
|
||||
wxhelper::WechatService::GetInstance().ForwardMsg(msg_id, wxid);
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"msg", "success"}, {"data", {}}};
|
||||
return ret_data.dump();
|
||||
}
|
||||
|
||||
std::string SendImageMsg(struct mg_http_message* hm){
|
||||
nlohmann::json j_param = nlohmann::json::parse(
|
||||
hm->body.ptr, hm->body.ptr + hm->body.len, nullptr, false);
|
||||
std::wstring wxid = GetWStringParam(j_param, "wxid");
|
||||
std::wstring path = GetWStringParam(j_param, "imagePath");
|
||||
INT64 success =
|
||||
wxhelper::WechatService::GetInstance().SendImageMsg(wxid, path);
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"data", {}}, {"msg", "success"}};
|
||||
return ret_data.dump();
|
||||
}
|
||||
|
||||
std::string SendFileMsg(struct mg_http_message* hm){
|
||||
nlohmann::json j_param = nlohmann::json::parse(
|
||||
hm->body.ptr, hm->body.ptr + hm->body.len, nullptr, false);
|
||||
std::wstring wxid = GetWStringParam(j_param, "wxid");
|
||||
std::wstring path = GetWStringParam(j_param, "filePath");
|
||||
INT64 success =
|
||||
wxhelper::WechatService::GetInstance().SendFileMsg(wxid, path);
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"data", {}}, {"msg", "success"}};
|
||||
return ret_data.dump();
|
||||
}
|
||||
|
||||
std::string SendAtText(struct mg_http_message* hm) {
|
||||
nlohmann::json j_param = nlohmann::json::parse(
|
||||
hm->body.ptr, hm->body.ptr + hm->body.len, nullptr, false);
|
||||
std::wstring chat_room_id = GetWStringParam(j_param, "chatRoomId");
|
||||
std::vector<std::wstring> wxids = GetArrayParam(j_param, "wxids");
|
||||
std::wstring msg = GetWStringParam(j_param, "msg");
|
||||
std::vector<std::wstring> wxid_list;
|
||||
for (unsigned int i = 0; i < wxids.size(); i++) {
|
||||
wxid_list.push_back(wxids[i]);
|
||||
}
|
||||
INT64 success = wxhelper::WechatService::GetInstance().SendAtText(
|
||||
chat_room_id, wxid_list, msg);
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"msg", "success"}, {"data", {}}};
|
||||
return ret_data.dump();
|
||||
}
|
||||
|
||||
std::string SendMultiAtText(struct mg_http_message* hm) {
|
||||
nlohmann::json j_param = nlohmann::json::parse(
|
||||
hm->body.ptr, hm->body.ptr + hm->body.len, nullptr, false);
|
||||
nlohmann::json array = j_param["at"];
|
||||
std::vector<std::pair<std::wstring, std::wstring>> at_vector;
|
||||
if (array.is_array()) {
|
||||
for (const auto& item : array) {
|
||||
at_vector.push_back(std::make_pair(GetWStringParam(item, "wxid"),
|
||||
GetWStringParam(item, "msg")));
|
||||
}
|
||||
}
|
||||
std::wstring chat_room_id = GetWStringParam(j_param, "chatRoomId");
|
||||
INT64 success = wxhelper::WechatService::GetInstance().SendMultiAtText(
|
||||
chat_room_id, at_vector);
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"msg", "success"}, {"data", {}}};
|
||||
return ret_data.dump();
|
||||
}
|
||||
|
||||
std::string GetLoginUrl(struct mg_http_message* hm) {
|
||||
std::string url = wxhelper::WechatService::GetInstance().GetLoginUrl();
|
||||
nlohmann::json ret_data = {
|
||||
{"code", 1}, {"msg", "success"}, {"data", {{"loginUrl", url}}}};
|
||||
return ret_data.dump();
|
||||
}
|
||||
|
||||
std::string TranslateVoice(struct mg_http_message* hm) {
|
||||
nlohmann::json j_param = nlohmann::json::parse(
|
||||
hm->body.ptr, hm->body.ptr + hm->body.len, nullptr, false);
|
||||
INT64 msg_id = GetInt64Param(j_param, "msgId");
|
||||
INT64 success = wxhelper::WechatService::GetInstance().TranslateVoice(msg_id);
|
||||
nlohmann::json ret_data = {
|
||||
{"code", success}, {"msg", "success"}, {"data", {}}};
|
||||
return ret_data.dump();
|
||||
}
|
||||
|
||||
std::string GetTranslateVoiceText(struct mg_http_message* hm) {
|
||||
nlohmann::json j_param = nlohmann::json::parse(
|
||||
hm->body.ptr, hm->body.ptr + hm->body.len, nullptr, false);
|
||||
INT64 msg_id = GetInt64Param(j_param, "msgId");
|
||||
std::string content =
|
||||
wxhelper::WechatService::GetInstance().GetTranslateVoiceText(msg_id);
|
||||
nlohmann::json ret_data = {
|
||||
{"code", 1}, {"msg", "success"}, {"data", {{"transtext", content}}}};
|
||||
return ret_data.dump();
|
||||
}
|
||||
} // namespace wxhelper
|
@ -1,28 +0,0 @@
|
||||
#ifndef WXHELPER_HTTP_URL_HANDLER_H_
|
||||
#define WXHELPER_HTTP_URL_HANDLER_H_
|
||||
#include <string>
|
||||
|
||||
#include "mongoose.h"
|
||||
namespace wxhelper {
|
||||
std::string SendTextMsg(struct mg_http_message *hm);
|
||||
std::string HookSyncMsg(struct mg_http_message *hm);
|
||||
std::string GetContacts(struct mg_http_message *hm);
|
||||
std::string UnHookSyncMsg(struct mg_http_message *hm);
|
||||
std::string CheckLogin(struct mg_http_message *hm);
|
||||
std::string GetSelfInfo(struct mg_http_message *hm);
|
||||
std::string GetDBInfo(struct mg_http_message *hm);
|
||||
std::string ExecSql(struct mg_http_message *hm);
|
||||
std::string LockWeChat(struct mg_http_message *hm);
|
||||
std::string UnLockWeChat(struct mg_http_message *hm);
|
||||
std::string EnterWeChat(struct mg_http_message* hm);
|
||||
std::string ForwardMsg(struct mg_http_message* hm);
|
||||
std::string SendImageMsg(struct mg_http_message* hm);
|
||||
std::string SendFileMsg(struct mg_http_message* hm);
|
||||
std::string SendAtText(struct mg_http_message* hm);
|
||||
std::string SendMultiAtText(struct mg_http_message* hm);
|
||||
std::string GetLoginUrl(struct mg_http_message* hm);
|
||||
std::string TranslateVoice(struct mg_http_message* hm);
|
||||
std::string GetTranslateVoiceText(struct mg_http_message* hm);
|
||||
} // namespace wxhelper
|
||||
|
||||
#endif
|
@ -1,205 +0,0 @@
|
||||
#include <WS2tcpip.h>
|
||||
#include "wechat_hook.h"
|
||||
|
||||
|
||||
#include <detours/detours.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "base64.h"
|
||||
#include "http_client.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "thread_pool.h"
|
||||
#include "wxutils.h"
|
||||
namespace offset = wxhelper::V3_9_8_25::offset;
|
||||
namespace common = wxhelper::common;
|
||||
|
||||
namespace hook {
|
||||
static bool kEnableHttp = false;
|
||||
static bool kLogHookFlag = false;
|
||||
static char kServerIp[20] = "127.0.0.1";
|
||||
static int kServerPort = 19099;
|
||||
|
||||
UINT64(*RealDoAddMsg)
|
||||
(UINT64, UINT64, UINT64) = (UINT64(*)(UINT64, UINT64, UINT64))(
|
||||
wxhelper::wxutils::GetWeChatWinBase() + offset::kDoAddMsg);
|
||||
|
||||
VOID SendMsgCallback(PTP_CALLBACK_INSTANCE instance, PVOID context,
|
||||
PTP_WORK Work) {
|
||||
common::InnerMessageStruct *msg = (common::InnerMessageStruct *)context;
|
||||
if (msg == NULL) {
|
||||
SPDLOG_INFO("add work:msg is null");
|
||||
return;
|
||||
}
|
||||
std::unique_ptr<common::InnerMessageStruct> sms(msg);
|
||||
nlohmann::json j_msg = nlohmann::json::parse(
|
||||
msg->buffer, msg->buffer + msg->length, nullptr, false);
|
||||
if (j_msg.is_discarded() == true) {
|
||||
return;
|
||||
}
|
||||
std::string jstr = j_msg.dump() + "\n";
|
||||
|
||||
WSADATA was_data = {0};
|
||||
int ret = WSAStartup(MAKEWORD(2, 2), &was_data);
|
||||
if (ret != 0) {
|
||||
SPDLOG_ERROR("WSAStartup failed:{}", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
SOCKET client_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (client_socket < 0) {
|
||||
SPDLOG_ERROR("socket init fail");
|
||||
return;
|
||||
}
|
||||
BOOL status = false;
|
||||
sockaddr_in client_addr;
|
||||
memset(&client_addr, 0, sizeof(client_addr));
|
||||
client_addr.sin_family = AF_INET;
|
||||
client_addr.sin_port = htons((u_short)kServerPort);
|
||||
InetPtonA(AF_INET, kServerIp, &client_addr.sin_addr.s_addr);
|
||||
if (connect(client_socket, reinterpret_cast<sockaddr *>(&client_addr),
|
||||
sizeof(sockaddr)) < 0) {
|
||||
SPDLOG_ERROR("socket connect fail. host:{} , port:{},",kServerIp,kServerPort);
|
||||
goto clean;
|
||||
}
|
||||
char recv_buf[1024] = {0};
|
||||
ret = send(client_socket, jstr.c_str(), static_cast<int>(jstr.size()), 0);
|
||||
if (ret < 0) {
|
||||
SPDLOG_ERROR("socket send fail ,ret:{}", ret);
|
||||
goto clean;
|
||||
}
|
||||
ret = shutdown(client_socket, SD_SEND);
|
||||
if (ret == SOCKET_ERROR) {
|
||||
SPDLOG_ERROR("shutdown failed with erro:{}", ret);
|
||||
goto clean;
|
||||
}
|
||||
ret = recv(client_socket, recv_buf, sizeof(recv_buf), 0);
|
||||
if (ret < 0) {
|
||||
SPDLOG_ERROR("socket recv fail ,ret:{}", ret);
|
||||
goto clean;
|
||||
}
|
||||
clean:
|
||||
closesocket(client_socket);
|
||||
WSACleanup();
|
||||
return;
|
||||
}
|
||||
|
||||
VOID SendHttpMsgCallback(PTP_CALLBACK_INSTANCE instance, PVOID context,
|
||||
PTP_WORK Work) {
|
||||
common::InnerMessageStruct *msg = (common::InnerMessageStruct *)context;
|
||||
if (msg == NULL) {
|
||||
SPDLOG_INFO("http msg is null");
|
||||
return;
|
||||
}
|
||||
|
||||
std::unique_ptr<common::InnerMessageStruct> sms(msg);
|
||||
nlohmann::json j_msg = nlohmann::json::parse(
|
||||
msg->buffer, msg->buffer + msg->length, nullptr, false);
|
||||
if (j_msg.is_discarded() == true) {
|
||||
return;
|
||||
}
|
||||
std::string jstr = j_msg.dump() + "\n";
|
||||
http::HttpClient::SendRequest(jstr);
|
||||
}
|
||||
|
||||
void HandleSyncMsg(INT64 param1, INT64 param2, INT64 param3) {
|
||||
nlohmann::json msg;
|
||||
|
||||
msg["pid"] = GetCurrentProcessId();
|
||||
msg["fromUser"] =
|
||||
wxhelper::wxutils::ReadSKBuiltinString(*(INT64 *)(param2 + 0x18));
|
||||
msg["toUser"] =
|
||||
wxhelper::wxutils::ReadSKBuiltinString(*(INT64 *)(param2 + 0x28));
|
||||
msg["content"] =
|
||||
wxhelper::wxutils::ReadSKBuiltinString(*(INT64 *)(param2 + 0x30));
|
||||
msg["signature"] =
|
||||
wxhelper::wxutils::ReadWeChatStr(*(INT64 *)(param2 + 0x48));
|
||||
msg["msgId"] = *(INT64 *)(param2 + 0x60);
|
||||
msg["msgSequence"] = *(DWORD *)(param2 + 0x5C);
|
||||
msg["createTime"] = *(DWORD *)(param2 + 0x58);
|
||||
msg["displayFullContent"] =
|
||||
wxhelper::wxutils::ReadWeChatStr(*(INT64 *)(param2 + 0x50));
|
||||
DWORD type = *(DWORD *)(param2 + 0x24);
|
||||
msg["type"] = type;
|
||||
if (type == 3) {
|
||||
int a = 1;
|
||||
std::string img =
|
||||
wxhelper::wxutils::ReadSKBuiltinBuffer(*(INT64 *)(param2 + 0x40));
|
||||
SPDLOG_INFO("encode size:{}", img.size());
|
||||
msg["base64Img"] = base64_encode(img);
|
||||
a = 2;
|
||||
}
|
||||
std::string jstr = msg.dump() + '\n';
|
||||
common::InnerMessageStruct *inner_msg = new common::InnerMessageStruct;
|
||||
inner_msg->buffer = new char[jstr.size() + 1];
|
||||
memcpy(inner_msg->buffer, jstr.c_str(), jstr.size() + 1);
|
||||
inner_msg->length = jstr.size();
|
||||
if (kEnableHttp) {
|
||||
bool add =
|
||||
base::ThreadPool::GetInstance().AddWork(SendHttpMsgCallback, inner_msg);
|
||||
SPDLOG_INFO("add http msg work:{}", add);
|
||||
} else {
|
||||
bool add =
|
||||
base::ThreadPool::GetInstance().AddWork(SendMsgCallback, inner_msg);
|
||||
SPDLOG_INFO("add msg work:{}", add);
|
||||
}
|
||||
RealDoAddMsg(param1, param2, param3);
|
||||
}
|
||||
|
||||
void WechatHook::Init(WechatHookParam param) {
|
||||
if(!init_){
|
||||
param_ = param;
|
||||
kEnableHttp = param.enable_http;
|
||||
}
|
||||
}
|
||||
|
||||
int WechatHook::HookSyncMsg() {
|
||||
if (sync_msg_flag_) {
|
||||
SPDLOG_INFO("recv msg hook already called");
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (param_.server_ip.size() < 1) {
|
||||
return -2;
|
||||
}
|
||||
UINT64 base = wxhelper::wxutils::GetWeChatWinBase();
|
||||
if (!base) {
|
||||
SPDLOG_INFO("base addr is null");
|
||||
return -1;
|
||||
}
|
||||
if (param_.enable_http) {
|
||||
http::HttpClient::SetConfig(param_.http_url,param_.http_time_out);
|
||||
}else{
|
||||
const char* charPtr = param_.server_ip.c_str();
|
||||
std::strcpy(kServerIp, charPtr);
|
||||
kServerPort = param_.server_port;
|
||||
}
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
DetourAttach(&(PVOID &)RealDoAddMsg, &HandleSyncMsg);
|
||||
LONG ret = DetourTransactionCommit();
|
||||
if (ret == NO_ERROR) {
|
||||
sync_msg_flag_ = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int WechatHook::UnHookSyncMsg() {
|
||||
if (!sync_msg_flag_) {
|
||||
SPDLOG_INFO("call UnHookSyncMsg but no hooked ");
|
||||
return NO_ERROR;
|
||||
}
|
||||
UINT64 base = wxhelper::wxutils::GetWeChatWinBase();
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
DetourDetach(&(PVOID &)RealDoAddMsg, &HandleSyncMsg);
|
||||
LONG ret = DetourTransactionCommit();
|
||||
if (ret == NO_ERROR) {
|
||||
sync_msg_flag_ = false;
|
||||
strcpy_s(kServerIp, "127.0.0.1");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
int WechatHook::HookLog() { return 0; }
|
||||
int WechatHook::UnHookLog() { return 0; }
|
||||
} // namespace hook
|
@ -1,34 +0,0 @@
|
||||
#ifndef WXHELPER_WECHAT_HOOK_H_
|
||||
#define WXHELPER_WECHAT_HOOK_H_
|
||||
#include "wechat_function.h"
|
||||
#include "singleton.h"
|
||||
|
||||
namespace hook {
|
||||
struct WechatHookParam {
|
||||
std::string server_ip = "127.0.0.1";
|
||||
std::string http_url = "http:://127.0.0.1:19088";
|
||||
int server_port = 19099;
|
||||
bool enable_http = false;
|
||||
uint64_t http_time_out = 3000;
|
||||
};
|
||||
|
||||
class WechatHook :public base::Singleton<WechatHook>{
|
||||
public:
|
||||
void Init(WechatHookParam param);
|
||||
|
||||
int HookSyncMsg();
|
||||
int UnHookSyncMsg();
|
||||
|
||||
int HookLog();
|
||||
|
||||
int UnHookLog();
|
||||
|
||||
private:
|
||||
WechatHookParam param_;
|
||||
bool sync_msg_flag_;
|
||||
bool init_;
|
||||
};
|
||||
|
||||
} // namespace hook
|
||||
|
||||
#endif
|
@ -1,751 +0,0 @@
|
||||
#include "wechat_service.h"
|
||||
#include "wxutils.h"
|
||||
#include "utils.h"
|
||||
#include "memory.h"
|
||||
#include "db.h"
|
||||
#include "tinyxml2.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
namespace offset = wxhelper::V3_9_8_25::offset;
|
||||
namespace prototype = wxhelper::V3_9_8_25::prototype;
|
||||
namespace func = wxhelper::V3_9_8_25::function;
|
||||
namespace wxhelper {
|
||||
|
||||
prototype::WeChatString *BuildWechatString(const std::wstring &ws) {
|
||||
prototype::WeChatString *p =
|
||||
base::utils::WxHeapAlloc<prototype::WeChatString>(
|
||||
sizeof(prototype::WeChatString));
|
||||
wchar_t *p_chat_room_id =
|
||||
base::utils::WxHeapAlloc<wchar_t>((ws.size() + 1) * 2);
|
||||
wmemcpy(p_chat_room_id, ws.c_str(), ws.size() + 1);
|
||||
p->ptr = p_chat_room_id;
|
||||
p->length = static_cast<DWORD>(ws.size());
|
||||
p->max_length = static_cast<DWORD>(ws.size());
|
||||
p->c_len = 0;
|
||||
p->c_ptr = 0;
|
||||
return p;
|
||||
}
|
||||
WechatService::~WechatService() {}
|
||||
|
||||
INT64 WechatService::CheckLogin() {
|
||||
INT64 success = -1;
|
||||
UINT64 accout_service_addr = base_addr_ + offset::kGetAccountServiceMgr;
|
||||
func::__GetAccountService GetSevice =
|
||||
(func::__GetAccountService)accout_service_addr;
|
||||
UINT64 service_addr = GetSevice();
|
||||
if (service_addr) {
|
||||
success = *(UINT64*)(service_addr + 0x7F8);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
INT64 WechatService::GetSelfInfo(common::SelfInfoInner& out) {
|
||||
INT64 success = -1;
|
||||
UINT64 accout_service_addr = base_addr_ + offset::kGetAccountServiceMgr;
|
||||
UINT64 get_app_data_save_path_addr = base_addr_ + offset::kGetAppDataSavePath;
|
||||
UINT64 get_current_data_path_addr = base_addr_ + offset::kGetCurrentDataPath;
|
||||
func::__GetAccountService GetSevice = (func::__GetAccountService)accout_service_addr;
|
||||
func::__GetDataSavePath GetDataSavePath = (func::__GetDataSavePath)get_app_data_save_path_addr;
|
||||
func::__GetCurrentDataPath GetCurrentDataPath = (func::__GetCurrentDataPath)get_current_data_path_addr;
|
||||
|
||||
UINT64 service_addr = GetSevice();
|
||||
if (service_addr) {
|
||||
if (*(INT64 *)(service_addr + 0x80) == 0 ||
|
||||
*(INT64 *)(service_addr + 0x80 + 0x10) == 0) {
|
||||
out.wxid = std::string();
|
||||
} else {
|
||||
if (*(INT64 *)(service_addr + 0x80 + 0x18) == 0xF) {
|
||||
out.wxid = std::string((char *)(service_addr + 0x80),
|
||||
*(INT64 *)(service_addr + 0x80 + 0x10));
|
||||
} else {
|
||||
out.wxid = std::string(*(char **)(service_addr + 0x80),
|
||||
*(INT64 *)(service_addr + 0x80 + 0x10));
|
||||
}
|
||||
}
|
||||
|
||||
if (*(INT64 *)(service_addr + 0x108) == 0 ||
|
||||
*(INT64 *)(service_addr + 0x108 + 0x10) == 0) {
|
||||
out.account = std::string();
|
||||
} else {
|
||||
if (*(INT64 *)(service_addr + 0x108 + 0x18) == 0xF) {
|
||||
out.account = std::string((char *)(service_addr + 0x108),
|
||||
*(INT64 *)(service_addr + 0x108 + 0x10));
|
||||
} else {
|
||||
out.account = std::string(*(char **)(service_addr + 0x108),
|
||||
*(INT64 *)(service_addr + 0x108 + 0x10));
|
||||
}
|
||||
}
|
||||
|
||||
if (*(INT64 *)(service_addr + 0x128) == 0 ||
|
||||
*(INT64 *)(service_addr + 0x128 + 0x10) == 0) {
|
||||
out.mobile = std::string();
|
||||
} else {
|
||||
if (*(INT64 *)(service_addr + 0x128 + 0x18) == 0xF) {
|
||||
out.mobile = std::string((char *)(service_addr + 0x128),
|
||||
*(INT64 *)(service_addr + 0x128 + 0x10));
|
||||
} else {
|
||||
out.mobile = std::string(*(char **)(service_addr + 0x128),
|
||||
*(INT64 *)(service_addr + 0x128 + 0x10));
|
||||
}
|
||||
}
|
||||
|
||||
if (*(INT64 *)(service_addr + 0x148) == 0 ||
|
||||
*(INT64 *)(service_addr + 0x148 + 0x10) == 0) {
|
||||
out.signature = std::string();
|
||||
} else {
|
||||
if (*(INT64 *)(service_addr + 0x148 + 0x18) == 0xF) {
|
||||
out.signature = std::string((char *)(service_addr + 0x148),
|
||||
*(INT64 *)(service_addr + 0x148 + 0x10));
|
||||
} else {
|
||||
out.signature = std::string(*(char **)(service_addr + 0x148),
|
||||
*(INT64 *)(service_addr + 0x148 + 0x10));
|
||||
}
|
||||
}
|
||||
|
||||
if (*(INT64 *)(service_addr + 0x168) == 0 ||
|
||||
*(INT64 *)(service_addr + 0x168 + 0x10) == 0) {
|
||||
out.country = std::string();
|
||||
} else {
|
||||
if (*(INT64 *)(service_addr + 0x168 + 0x18) == 0xF) {
|
||||
out.country = std::string((char *)(service_addr + 0x168),
|
||||
*(INT64 *)(service_addr + 0x168 + 0x10));
|
||||
} else {
|
||||
out.country = std::string(*(char **)(service_addr + 0x168),
|
||||
*(INT64 *)(service_addr + 0x168 + 0x10));
|
||||
}
|
||||
}
|
||||
|
||||
if (*(INT64 *)(service_addr + 0x188) == 0 ||
|
||||
*(INT64 *)(service_addr + 0x188 + 0x10) == 0) {
|
||||
out.province = std::string();
|
||||
} else {
|
||||
if (*(INT64 *)(service_addr + 0x188 + 0x18) == 0xF) {
|
||||
out.province = std::string((char *)(service_addr + 0x188),
|
||||
*(INT64 *)(service_addr + 0x188 + 0x10));
|
||||
} else {
|
||||
out.province = std::string(*(char **)(service_addr + 0x188),
|
||||
*(INT64 *)(service_addr + 0x188 + 0x10));
|
||||
}
|
||||
}
|
||||
|
||||
if (*(INT64 *)(service_addr + 0x1A8) == 0 ||
|
||||
*(INT64 *)(service_addr + 0x1A8 + 0x10) == 0) {
|
||||
out.city = std::string();
|
||||
} else {
|
||||
if (*(INT64 *)(service_addr + 0x1A8 + 0x18) == 0xF) {
|
||||
out.city = std::string((char *)(service_addr + 0x1A8),
|
||||
*(INT64 *)(service_addr + 0x1A8 + 0x10));
|
||||
} else {
|
||||
out.city = std::string(*(char **)(service_addr + 0x1A8),
|
||||
*(INT64 *)(service_addr + 0x1A8 + 0x10));
|
||||
}
|
||||
}
|
||||
|
||||
if (*(INT64 *)(service_addr + 0x1E8) == 0 ||
|
||||
*(INT64 *)(service_addr + 0x1E8 + 0x10) == 0) {
|
||||
out.name = std::string();
|
||||
} else {
|
||||
if (*(INT64 *)(service_addr + 0x1E8 + 0x18) == 0xF) {
|
||||
out.name = std::string((char *)(service_addr + 0x1E8),
|
||||
*(INT64 *)(service_addr + 0x1E8 + 0x10));
|
||||
} else {
|
||||
out.name = std::string(*(char **)(service_addr + 0x1E8),
|
||||
*(INT64 *)(service_addr + 0x1E8 + 0x10));
|
||||
}
|
||||
}
|
||||
|
||||
if (*(INT64 *)(service_addr + 0x450) == 0 ||
|
||||
*(INT64 *)(service_addr + 0x450 + 0x10) == 0) {
|
||||
out.head_img = std::string();
|
||||
} else {
|
||||
out.head_img = std::string(*(char **)(service_addr + 0x450),
|
||||
*(INT64 *)(service_addr + 0x450 + 0x10));
|
||||
}
|
||||
|
||||
if (*(INT64 *)(service_addr + 0x7B8) == 0 ||
|
||||
*(INT64 *)(service_addr + 0x7B8 + 0x10) == 0) {
|
||||
out.public_key = std::string();
|
||||
} else {
|
||||
out.public_key = std::string(*(char **)(service_addr + 0x7B8),
|
||||
*(INT64 *)(service_addr + 0x7B8 + 0x10));
|
||||
}
|
||||
|
||||
if (*(INT64 *)(service_addr + 0x7D8) == 0 ||
|
||||
*(INT64 *)(service_addr + 0x7D8 + 0x10) == 0) {
|
||||
out.private_key = std::string();
|
||||
} else {
|
||||
out.private_key = std::string(*(char **)(service_addr + 0x7D8),
|
||||
*(INT64 *)(service_addr + 0x7D8 + 0x10));
|
||||
}
|
||||
|
||||
if (*(INT64 *)(service_addr + 0x6E0) == 0 ||
|
||||
*(INT64 *)(service_addr + 0x6E8) == 0) {
|
||||
out.db_key = std::string();
|
||||
} else {
|
||||
INT64 byte_addr = *(INT64 *)(service_addr + 0x6E0);
|
||||
INT64 len = *(INT64 *)(service_addr + 0x6E8);
|
||||
out.db_key = base::utils::Bytes2Hex((BYTE *)byte_addr, static_cast<int>(len));
|
||||
}
|
||||
|
||||
UINT64 flag = *(UINT64 *)(service_addr + 0x7F8);
|
||||
if (flag == 1) {
|
||||
prototype::WeChatString current_data_path;
|
||||
// _GetCurrentDataPath(get_current_data_path_addr,
|
||||
// reinterpret_cast<ULONG_PTR>(¤t_data_path));
|
||||
GetCurrentDataPath(reinterpret_cast<ULONG_PTR>(¤t_data_path));
|
||||
if (current_data_path.ptr) {
|
||||
out.current_data_path = base::utils::WstringToUtf8(
|
||||
std::wstring(current_data_path.ptr, current_data_path.length));
|
||||
} else {
|
||||
out.current_data_path = std::string();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prototype::WeChatString data_save_path;
|
||||
// _GetDataSavePath(get_app_data_save_path_addr,
|
||||
// reinterpret_cast<ULONG_PTR>(&data_save_path));
|
||||
GetCurrentDataPath(reinterpret_cast<ULONG_PTR>(&data_save_path));
|
||||
if (data_save_path.ptr) {
|
||||
out.data_save_path = base::utils::WstringToUtf8(
|
||||
std::wstring(data_save_path.ptr, data_save_path.length));
|
||||
} else {
|
||||
out.data_save_path = std::string();
|
||||
}
|
||||
|
||||
success = 1;
|
||||
return success;
|
||||
}
|
||||
|
||||
INT64 WechatService::SendTextMsg(const std::wstring& wxid,
|
||||
const std::wstring& msg) {
|
||||
INT64 success = -1;
|
||||
prototype::WeChatString to_user(wxid);
|
||||
prototype::WeChatString text_msg(msg);
|
||||
UINT64 send_message_mgr_addr = base_addr_ + offset::kGetSendMessageMgr;
|
||||
UINT64 send_text_msg_addr = base_addr_ + offset::kSendTextMsg;
|
||||
UINT64 free_chat_msg_addr = base_addr_ + offset::kFreeChatMsg;
|
||||
char chat_msg[0x460] = {0};
|
||||
UINT64 temp[3] = {0};
|
||||
func::__GetSendMessageMgr mgr;
|
||||
mgr = (func::__GetSendMessageMgr)send_message_mgr_addr;
|
||||
func::__SendTextMsg send;
|
||||
send = (func::__SendTextMsg)send_text_msg_addr;
|
||||
func::__FreeChatMsg free;
|
||||
free = (func::__FreeChatMsg)free_chat_msg_addr;
|
||||
mgr();
|
||||
send(reinterpret_cast<UINT64>(&chat_msg), reinterpret_cast<UINT64>(&to_user),
|
||||
reinterpret_cast<UINT64>(&text_msg), reinterpret_cast<UINT64>(&temp), 1,
|
||||
1, 0, 0);
|
||||
free(reinterpret_cast<UINT64>(&chat_msg));
|
||||
success = 1;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
INT64 WechatService::SendImageMsg(const std::wstring& wxid,
|
||||
const std::wstring& image_path) {
|
||||
INT64 success = -1;
|
||||
prototype::WeChatString to_user(wxid);
|
||||
prototype::WeChatString image_full_path(image_path);
|
||||
UINT64 send_message_mgr_addr = base_addr_ + offset::kGetSendMessageMgr;
|
||||
UINT64 send_img_addr = base_addr_ + offset::kSendImageMsg;
|
||||
UINT64 new_chat_msg_addr = base_addr_ + offset::kChatMsgInstanceCounter;
|
||||
UINT64 free_chat_msg_addr = base_addr_ + offset::kFreeChatMsg;
|
||||
func::__NewChatMsg new_chat_msg = (func::__NewChatMsg)new_chat_msg_addr;
|
||||
func::__GetSendMessageMgr mgr =
|
||||
(func::__GetSendMessageMgr)send_message_mgr_addr;
|
||||
func::__SendImageMsg send_img = (func::__SendImageMsg)send_img_addr;
|
||||
func::__FreeChatMsg free = (func::__FreeChatMsg)free_chat_msg_addr;
|
||||
|
||||
char chat_msg[0x460] = {0};
|
||||
char chat_msg_temp[0x460] = {0};
|
||||
|
||||
UINT64 p_chat_msg_temp = new_chat_msg(reinterpret_cast<UINT64>(&chat_msg_temp));
|
||||
UINT64 temp1 =0;
|
||||
UINT64 temp2 =0;
|
||||
UINT64* flag[10] = {};
|
||||
flag[8] = &temp1;
|
||||
flag[9] = &temp2;
|
||||
flag[1] = reinterpret_cast<UINT64*>(p_chat_msg_temp);
|
||||
|
||||
UINT64 p_chat_msg = new_chat_msg(reinterpret_cast<UINT64>(&chat_msg));
|
||||
UINT64 send_mgr = mgr();
|
||||
send_img(send_mgr, p_chat_msg,
|
||||
reinterpret_cast<UINT64>(&to_user),
|
||||
reinterpret_cast<UINT64>(&image_full_path),
|
||||
reinterpret_cast<UINT64>(&flag));
|
||||
free(p_chat_msg);
|
||||
free(p_chat_msg_temp);
|
||||
success = 1;
|
||||
return success;
|
||||
}
|
||||
|
||||
INT64 WechatService::SendFileMsg(const std::wstring& wxid,
|
||||
const std::wstring& file_path) {
|
||||
INT64 success = -1;
|
||||
prototype::WeChatString* to_user= (prototype::WeChatString*)HeapAlloc(GetProcessHeap(),0,sizeof(prototype::WeChatString));
|
||||
wchar_t * ptr_wxid = (wchar_t*)HeapAlloc(GetProcessHeap(),0,(wxid.length()+1)*2);
|
||||
wmemcpy(ptr_wxid,wxid.c_str(),wxid.length()+1);
|
||||
to_user->ptr = ptr_wxid;
|
||||
to_user->length = static_cast<DWORD>(wxid.length());
|
||||
to_user->max_length = static_cast<DWORD>(wxid.length());
|
||||
to_user->c_len=0;
|
||||
to_user->c_ptr=0;
|
||||
prototype::WeChatString* file_full_path= (prototype::WeChatString*)HeapAlloc(GetProcessHeap(),0,sizeof(prototype::WeChatString));
|
||||
wchar_t * ptr_path = (wchar_t*)HeapAlloc(GetProcessHeap(),0,(file_path.length()+1)*2);
|
||||
wmemcpy(ptr_path,file_path.c_str(),file_path.length()+1);
|
||||
file_full_path->ptr = ptr_path;
|
||||
file_full_path->length = static_cast<DWORD>(file_path.length());
|
||||
file_full_path->max_length = static_cast<DWORD>(file_path.length());
|
||||
file_full_path->c_len = 0;
|
||||
file_full_path->c_ptr = 0;
|
||||
|
||||
UINT64 get_app_msg_mgr_addr = base_addr_ + offset::kGetAppMsgMgr;
|
||||
UINT64 send_file_addr = base_addr_ + offset::kSendFileMsg;
|
||||
UINT64 new_chat_msg_addr = base_addr_ + offset::kChatMsgInstanceCounter;
|
||||
UINT64 free_chat_msg_addr = base_addr_ + offset::kFreeChatMsg;
|
||||
func::__NewChatMsg new_chat_msg = (func::__NewChatMsg)new_chat_msg_addr;
|
||||
func::__GetAppMsgMgr get_app_mgr =
|
||||
(func::__GetAppMsgMgr)get_app_msg_mgr_addr;
|
||||
func::__SendFile send_file = (func::__SendFile)send_file_addr;
|
||||
func::__FreeChatMsg free = (func::__FreeChatMsg)free_chat_msg_addr;
|
||||
|
||||
|
||||
char* chat_msg= (char*)HeapAlloc(GetProcessHeap(),0,0x460);
|
||||
|
||||
UINT64* temp1 = (UINT64*)HeapAlloc(GetProcessHeap(),0,sizeof(UINT64)*4);
|
||||
UINT64* temp2 = (UINT64*)HeapAlloc(GetProcessHeap(),0,sizeof(UINT64)*4);
|
||||
UINT64* temp3 = (UINT64*)HeapAlloc(GetProcessHeap(),0,sizeof(UINT64)*4);
|
||||
UINT64* temp4 = (UINT64*)HeapAlloc(GetProcessHeap(),0,sizeof(UINT64)*4);
|
||||
ZeroMemory(temp1,sizeof(UINT64)*4);
|
||||
ZeroMemory(temp2,sizeof(UINT64)*4);
|
||||
ZeroMemory(temp3,sizeof(UINT64)*4);
|
||||
ZeroMemory(temp4,sizeof(UINT64)*4);
|
||||
*temp4=0x1F;
|
||||
UINT64 app_mgr = get_app_mgr();
|
||||
send_file(app_mgr, reinterpret_cast<UINT64>(chat_msg),
|
||||
reinterpret_cast<UINT64>(to_user),
|
||||
reinterpret_cast<UINT64>(file_full_path), 1,
|
||||
reinterpret_cast<UINT64>(temp1), 0, reinterpret_cast<UINT64>(temp2),
|
||||
0, reinterpret_cast<UINT64>(temp3), 0, 0);
|
||||
free(reinterpret_cast<UINT64>(chat_msg));
|
||||
HeapFree(GetProcessHeap(),0,to_user);
|
||||
HeapFree(GetProcessHeap(),0,file_full_path);
|
||||
HeapFree(GetProcessHeap(),0,temp1);
|
||||
HeapFree(GetProcessHeap(),0,temp2);
|
||||
HeapFree(GetProcessHeap(),0,temp3);
|
||||
HeapFree(GetProcessHeap(),0,temp4);
|
||||
success = 1;
|
||||
return success;
|
||||
}
|
||||
|
||||
INT64 WechatService::GetContacts(std::vector<common::ContactInner>& vec) {
|
||||
INT64 success = -1;
|
||||
UINT64 get_contact_mgr_addr = base_addr_ + offset::kGetContactMgr;
|
||||
UINT64 get_contact_list_addr = base_addr_ + offset::kGetContactList;
|
||||
func::__GetContactMgr get_contact_mgr =
|
||||
(func::__GetContactMgr)get_contact_mgr_addr;
|
||||
func::__GetContactList get_contact_list =
|
||||
(func::__GetContactList)get_contact_list_addr;
|
||||
UINT64 mgr = get_contact_mgr();
|
||||
UINT64 contact_vec[3] = {0, 0, 0};
|
||||
success = get_contact_list(mgr, reinterpret_cast<UINT64>(&contact_vec));
|
||||
|
||||
UINT64 start = contact_vec[0];
|
||||
UINT64 end = contact_vec[2];
|
||||
while (start < end) {
|
||||
common::ContactInner temp;
|
||||
temp.wxid = wxutils::ReadWstringThenConvert(start + 0x10);
|
||||
temp.custom_account = wxutils::ReadWstringThenConvert(start + 0x30);
|
||||
temp.encrypt_name = wxutils::ReadWstringThenConvert(start + 0x50);
|
||||
temp.nickname = wxutils::ReadWstringThenConvert(start + 0xA0);
|
||||
temp.pinyin = wxutils::ReadWstringThenConvert(start + 0x108);
|
||||
temp.pinyin_all = wxutils::ReadWstringThenConvert(start + 0x128);
|
||||
temp.verify_flag = *(DWORD *)(start + 0x70);
|
||||
temp.type = *(DWORD *)(start + 0x74);
|
||||
temp.reserved1 = *(DWORD *)(start + 0x1F0);
|
||||
temp.reserved2 = *(DWORD *)(start + 0x1F4);
|
||||
vec.push_back(temp);
|
||||
start += 0x6A8;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
INT64 WechatService::GetChatRoomDetailInfo(
|
||||
const std::wstring& room_id, common::ChatRoomInfoInner& room_info) {
|
||||
return INT64();
|
||||
}
|
||||
|
||||
INT64 WechatService::AddMemberToChatRoom(
|
||||
const std::wstring& room_id, const std::vector<std::wstring>& members) {
|
||||
return INT64();
|
||||
}
|
||||
|
||||
INT64 WechatService::ModChatRoomMemberNickName(const std::wstring& room_id,
|
||||
const std::wstring& wxid,
|
||||
const std::wstring& nickname) {
|
||||
return INT64();
|
||||
}
|
||||
|
||||
INT64 WechatService::DelMemberFromChatRoom(
|
||||
const std::wstring& room_id, const std::vector<std::wstring>& members) {
|
||||
return INT64();
|
||||
}
|
||||
|
||||
INT64 WechatService::GetMemberFromChatRoom(
|
||||
const std::wstring& room_id, common::ChatRoomMemberInner& member) {
|
||||
return INT64();
|
||||
}
|
||||
|
||||
INT64 WechatService::SetTopMsg(ULONG64 msg_id) { return INT64(); }
|
||||
|
||||
INT64 WechatService::RemoveTopMsg(const std::wstring& room_id, ULONG64 msg_id) {
|
||||
return INT64();
|
||||
}
|
||||
|
||||
INT64 WechatService::InviteMemberToChatRoom(
|
||||
const std::wstring& room_id, const std::vector<std::wstring>& wxids) {
|
||||
return INT64();
|
||||
}
|
||||
|
||||
INT64 WechatService::CreateChatRoom(const std::vector<std::wstring>& wxids) {
|
||||
return INT64();
|
||||
}
|
||||
|
||||
INT64 WechatService::QuitChatRoom(const std::wstring& room_id) {
|
||||
return INT64();
|
||||
}
|
||||
|
||||
INT64 WechatService::ForwardMsg(UINT64 msg_id, const std::wstring& wxid) {
|
||||
INT64 success = -1;
|
||||
UINT64 forward_addr = base_addr_ + offset::kForwardMsg;
|
||||
func::__ForwardMsg forward_msg = (func::__ForwardMsg)forward_addr;
|
||||
INT64 index = 0;
|
||||
INT64 local_id = wxhelper::DB::GetInstance().GetLocalIdByMsgId(msg_id, index);
|
||||
if (local_id <= 0 || index >> 32 == 0) {
|
||||
success = -2;
|
||||
return success;
|
||||
}
|
||||
LARGE_INTEGER l;
|
||||
l.HighPart = index >> 32;
|
||||
l.LowPart = (DWORD)local_id;
|
||||
prototype::WeChatString *recv = BuildWechatString(wxid);
|
||||
success = forward_msg(reinterpret_cast<UINT64>(recv), l.QuadPart, 0x4, 0x0);
|
||||
return success;
|
||||
}
|
||||
|
||||
INT64 WechatService::GetSNSFirstPage() { return INT64(); }
|
||||
|
||||
INT64 WechatService::GetSNSNextPage(UINT64 sns_id) { return INT64(); }
|
||||
|
||||
INT64 WechatService::AddFavFromMsg(UINT64 msg_id) { return INT64(); }
|
||||
|
||||
INT64 WechatService::AddFavFromImage(const std::wstring& wxid,
|
||||
const std::wstring& image_path) {
|
||||
return INT64();
|
||||
}
|
||||
|
||||
INT64 WechatService::SendAtText(const std::wstring& room_id,
|
||||
const std::vector<std::wstring>& wxids,
|
||||
const std::wstring& msg) {
|
||||
INT64 success = -1;
|
||||
std::vector<prototype::WeChatString> wxid_list;
|
||||
common::VectorInner *list = (common::VectorInner *)&wxid_list;
|
||||
std::wstring at_msg = L"";
|
||||
int number = 0;
|
||||
for (unsigned int i = 0; i < wxids.size(); i++) {
|
||||
std::wstring nickname;
|
||||
std::wstring at_all = L"notify@all";
|
||||
if (at_all.compare(wxids[i]) == 0) {
|
||||
nickname = L"\u6240\u6709\u4eba";
|
||||
} else {
|
||||
nickname = GetContactOrChatRoomNickname(wxids[i]);
|
||||
}
|
||||
if (nickname.length() == 0) {
|
||||
continue;
|
||||
}
|
||||
prototype::WeChatString id(wxids[i]);
|
||||
wxid_list.push_back(id);
|
||||
at_msg = at_msg + L"@" + nickname + L" ";
|
||||
number++;
|
||||
}
|
||||
if (number < 1) {
|
||||
return success;
|
||||
}
|
||||
at_msg += msg;
|
||||
|
||||
INT64 head = (INT64)&list->start;
|
||||
prototype::WeChatString to_user(room_id);
|
||||
prototype::WeChatString text_msg(at_msg);
|
||||
UINT64 send_message_mgr_addr = base_addr_ + offset::kGetSendMessageMgr;
|
||||
UINT64 send_text_msg_addr = base_addr_ + offset::kSendTextMsg;
|
||||
UINT64 free_chat_msg_addr = base_addr_ + offset::kFreeChatMsg;
|
||||
char chat_msg[0x460] = {0};
|
||||
func::__GetSendMessageMgr mgr= (func::__GetSendMessageMgr)send_message_mgr_addr;
|
||||
func::__SendTextMsg send= (func::__SendTextMsg)send_text_msg_addr;
|
||||
func::__FreeChatMsg free= (func::__FreeChatMsg)free_chat_msg_addr;
|
||||
mgr();
|
||||
success = send(reinterpret_cast<UINT64>(&chat_msg),
|
||||
reinterpret_cast<UINT64>(&to_user),
|
||||
reinterpret_cast<UINT64>(&text_msg), head, 1, 1, 0, 0);
|
||||
free(reinterpret_cast<UINT64>(&chat_msg));
|
||||
return success;
|
||||
}
|
||||
|
||||
std::wstring WechatService::GetContactOrChatRoomNickname(
|
||||
const std::wstring& wxid) {
|
||||
prototype::WeChatString to_user(wxid);
|
||||
UINT64 get_contact_mgr_addr = base_addr_ + offset::kGetContactMgr;
|
||||
UINT64 new_contact_addr = base_addr_ + offset::kNewContact;
|
||||
UINT64 get_contact_addr = base_addr_ + offset::kGetContact;
|
||||
UINT64 free_contact_addr = base_addr_ + offset::kFreeContact;
|
||||
func::__GetContactMgr get_contact_mgr =
|
||||
(func::__GetContactMgr)get_contact_mgr_addr;
|
||||
func::__GetContact get_contact = (func::__GetContact)get_contact_addr;
|
||||
func::__NewContact new_contact = (func::__NewContact)new_contact_addr;
|
||||
func::__FreeContact free_contact = (func::__FreeContact)free_contact_addr;
|
||||
char buff[0x6A9] = {0};
|
||||
UINT64 contact = new_contact(reinterpret_cast<UINT64>(&buff));
|
||||
UINT64 mgr = get_contact_mgr();
|
||||
INT64 success = get_contact(mgr, reinterpret_cast<UINT64>(&to_user), contact);
|
||||
if (success == 1) {
|
||||
std::wstring nickname = wxutils::ReadWstring(contact + 0xA0);
|
||||
free_contact(contact);
|
||||
return nickname;
|
||||
} else {
|
||||
free_contact(contact);
|
||||
return L"";
|
||||
}
|
||||
}
|
||||
|
||||
INT64 WechatService::GetContactByWxid(const std::wstring& wxid,
|
||||
common::ContactProfileInner& profile) {
|
||||
return INT64();
|
||||
}
|
||||
|
||||
INT64 WechatService::DoDownloadTask(UINT64 msg_id) { return INT64(); }
|
||||
|
||||
INT64 WechatService::ForwardPublicMsg(const std::wstring& wxid,
|
||||
const std::wstring& title,
|
||||
const std::wstring& url,
|
||||
const std::wstring& thumb_url,
|
||||
const std::wstring& sender_id,
|
||||
const std::wstring& sender_name,
|
||||
const std::wstring& digest) {
|
||||
return INT64();
|
||||
}
|
||||
|
||||
INT64 WechatService::ForwardPublicMsgByMsgId(const std::wstring& wxid,
|
||||
UINT64 msg_id) {
|
||||
return INT64();
|
||||
}
|
||||
|
||||
INT64 WechatService::DecodeImage(const std::wstring& file_path,
|
||||
const std::wstring& save_dir) {
|
||||
return INT64();
|
||||
}
|
||||
|
||||
INT64 WechatService::GetVoiceByDB(ULONG64 msg_id, const std::wstring& dir) {
|
||||
return INT64();
|
||||
}
|
||||
|
||||
INT64 WechatService::SendCustomEmotion(const std::wstring& file_path,
|
||||
const std::wstring& wxid) {
|
||||
return INT64();
|
||||
}
|
||||
|
||||
INT64 WechatService::SendApplet(
|
||||
const std::wstring& recv_wxid, const std::wstring& waid_suff,
|
||||
const std::wstring& waid_w, const std::string& waid_s,
|
||||
const std::string& wa_wxid, const std::string& json_param,
|
||||
const std::string& head_image, const std::string& big_image,
|
||||
const std::string& index_page) {
|
||||
return INT64();
|
||||
}
|
||||
|
||||
INT64 WechatService::SendPatMsg(const std::wstring& room_id,
|
||||
const std::wstring& wxid) {
|
||||
return INT64();
|
||||
}
|
||||
|
||||
INT64 WechatService::DoOCRTask(const std::wstring& img_path,
|
||||
std::string& result) {
|
||||
return INT64();
|
||||
}
|
||||
|
||||
INT64 WechatService::LockWeChat() {
|
||||
INT64 success = -1;
|
||||
UINT64 lock_mgr_addr = base_addr_ + offset::kGetLockWechatMgr;
|
||||
UINT64 request_lock_addr = base_addr_ + offset::kRequestLockWechat;
|
||||
func::__GetLockWechatMgr GetLockMgr = (func::__GetLockWechatMgr)lock_mgr_addr;
|
||||
func::__RequestLockWechat request_lock =
|
||||
(func::__RequestLockWechat)request_lock_addr;
|
||||
UINT64 mgr = GetLockMgr();
|
||||
success = request_lock(mgr);
|
||||
return success;
|
||||
}
|
||||
|
||||
INT64 WechatService::UnLockWeChat() {
|
||||
INT64 success = -1;
|
||||
UINT64 lock_mgr_addr = base_addr_ + offset::kGetLockWechatMgr;
|
||||
UINT64 request_unlock_addr = base_addr_ + offset::kRequestUnLockWechat;
|
||||
func::__GetLockWechatMgr GetLockMgr = (func::__GetLockWechatMgr)lock_mgr_addr;
|
||||
func::__RequestUnLockWechat request_unlock =
|
||||
(func::__RequestUnLockWechat)request_unlock_addr;
|
||||
UINT64 mgr = GetLockMgr();
|
||||
success = request_unlock(mgr);
|
||||
return success;
|
||||
}
|
||||
|
||||
INT64 WechatService::EnterWeChat() {
|
||||
INT64 success = -1;
|
||||
UINT64 click_cb_addr = base_addr_ + offset::kOnLoginBtnClick;
|
||||
func::__OnLoginBtnClick cb = (func::__OnLoginBtnClick)click_cb_addr;
|
||||
auto vec =
|
||||
base::memory::ScanAndMatchValue(base_addr_ + 0x34e0c18, 0x1000, 0x8);
|
||||
for (int i = 0; i < vec.size(); i++) {
|
||||
INT64 ptr = vec.at(i);
|
||||
if (*(INT64 *)ptr == base_addr_ + 0x34e0c18) {
|
||||
INT64 login_wnd = ptr;
|
||||
success = cb(ptr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
INT64 WechatService::SendMultiAtText(
|
||||
const std::wstring &room_id,
|
||||
const std::vector<std::pair<std::wstring, std::wstring>> &at) {
|
||||
INT64 success = -1;
|
||||
std::vector<prototype::WeChatString> wxid_list;
|
||||
common::VectorInner *list = (common::VectorInner *)&wxid_list;
|
||||
std::wstring at_msg = L"";
|
||||
int number = 0;
|
||||
for (unsigned int i = 0; i < at.size(); i++) {
|
||||
std::wstring nickname;
|
||||
std::wstring at_all = L"notify@all";
|
||||
if (at_all.compare(at[i].first) == 0) {
|
||||
nickname = L"\u6240\u6709\u4eba";
|
||||
} else {
|
||||
nickname = GetContactOrChatRoomNickname(at[i].first);
|
||||
}
|
||||
if (nickname.length() == 0) {
|
||||
continue;
|
||||
}
|
||||
prototype::WeChatString id(at[i].first);
|
||||
wxid_list.push_back(id);
|
||||
at_msg = at_msg + L"@" + nickname + L" "+ at[i].second + L" ";
|
||||
number++;
|
||||
}
|
||||
if (number < 1) {
|
||||
return success;
|
||||
}
|
||||
INT64 head = (INT64)&list->start;
|
||||
prototype::WeChatString to_user(room_id);
|
||||
prototype::WeChatString text_msg(at_msg);
|
||||
UINT64 send_message_mgr_addr = base_addr_ + offset::kGetSendMessageMgr;
|
||||
UINT64 send_text_msg_addr = base_addr_ + offset::kSendTextMsg;
|
||||
UINT64 free_chat_msg_addr = base_addr_ + offset::kFreeChatMsg;
|
||||
char chat_msg[0x460] = {0};
|
||||
func::__GetSendMessageMgr mgr =
|
||||
(func::__GetSendMessageMgr)send_message_mgr_addr;
|
||||
func::__SendTextMsg send = (func::__SendTextMsg)send_text_msg_addr;
|
||||
func::__FreeChatMsg free = (func::__FreeChatMsg)free_chat_msg_addr;
|
||||
mgr();
|
||||
success = send(reinterpret_cast<UINT64>(&chat_msg),
|
||||
reinterpret_cast<UINT64>(&to_user),
|
||||
reinterpret_cast<UINT64>(&text_msg), head, 1, 1, 0, 0);
|
||||
free(reinterpret_cast<UINT64>(&chat_msg));
|
||||
return success;
|
||||
}
|
||||
|
||||
std::string WechatService::GetLoginUrl(){
|
||||
INT64 success = -1;
|
||||
UINT64 login_mgr_addr = base_addr_ + offset::kGetQRCodeLoginMgr;
|
||||
func::__GetQRCodeLoginMgr get = (func::__GetQRCodeLoginMgr)login_mgr_addr;
|
||||
UINT64 addr = get();
|
||||
std::string login_url = wxutils::ReadWeChatStr(addr + 0x68);
|
||||
return "http://weixin.qq.com/x/" + login_url;
|
||||
}
|
||||
|
||||
void WechatService::SetBaseAddr(UINT64 addr) { base_addr_ = addr; }
|
||||
|
||||
void WechatService::SetJsApiAddr(UINT64 addr) { js_api_addr_ = addr; }
|
||||
|
||||
INT64 WechatService::TranslateVoice(UINT64 msg_id){
|
||||
INT64 success = -1;
|
||||
UINT64 get_by_local_id_addr = base_addr_ + offset::kGetMgrByPrefixLocalId;
|
||||
func::__GetMgrByPrefixLocalId get_by_local_id =
|
||||
(func::__GetMgrByPrefixLocalId)get_by_local_id_addr;
|
||||
|
||||
UINT64 get_chat_mgr_addr = base_addr_ + offset::kGetChatMgr;
|
||||
func::__GetChatMgr get_chat_mgr = (func::__GetChatMgr)get_chat_mgr_addr;
|
||||
|
||||
UINT64 free_chat_msg_addr = base_addr_ + offset::kFreeChatMsg;
|
||||
func::__FreeChatMsg free_chat_msg = (func::__FreeChatMsg)free_chat_msg_addr;
|
||||
|
||||
UINT64 new_chat_msg_addr = base_addr_ + offset::kChatMsgInstanceCounter;
|
||||
func::__NewChatMsg new_chat_msg = (func::__NewChatMsg)new_chat_msg_addr;
|
||||
|
||||
UINT64 update_addr = base_addr_ + offset::kUpdateMsg;
|
||||
func::__UpdateMsg update = (func::__UpdateMsg)update_addr;
|
||||
|
||||
UINT64 get_voice_mgr_addr = base_addr_ + offset::kGetVoiceMgr;
|
||||
func::__GetVoiceMgr get_voice_mgr = (func::__GetVoiceMgr)get_voice_mgr_addr;
|
||||
|
||||
UINT64 to_msg_addr = base_addr_ + offset::kChatMsg2NetSceneSendMsg;
|
||||
func::__ChatMsg2NetSceneSendMsg to_msg =
|
||||
(func::__ChatMsg2NetSceneSendMsg)to_msg_addr;
|
||||
|
||||
UINT64 trans_addr = base_addr_ + offset::kTranslateVoice;
|
||||
func::__TranslateVoice translate_voice = (func::__TranslateVoice)trans_addr;
|
||||
|
||||
char temp_msg[0x460] = {0};
|
||||
|
||||
char *chat_msg = base::utils::WxHeapAlloc<char>(0x460);
|
||||
INT64 index = 0;
|
||||
INT64 local_id = DB::GetInstance().GetLocalIdByMsgId(msg_id, index);
|
||||
if (local_id <= 0 || index >> 32 == 0) {
|
||||
success = -2;
|
||||
return success;
|
||||
}
|
||||
LARGE_INTEGER l;
|
||||
l.HighPart = index >> 32;
|
||||
l.LowPart = (DWORD)local_id;
|
||||
UINT64 p_chat_msg = new_chat_msg(reinterpret_cast<UINT64>(chat_msg));
|
||||
get_chat_mgr();
|
||||
get_by_local_id(l.QuadPart, p_chat_msg);
|
||||
UINT64 mgr = get_chat_mgr();
|
||||
update(mgr, p_chat_msg, 0);
|
||||
|
||||
UINT64 voice_mgr = get_voice_mgr();
|
||||
UINT64 msg = to_msg(reinterpret_cast<UINT64>(&temp_msg), p_chat_msg);
|
||||
|
||||
success = translate_voice(voice_mgr, msg, 0);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
std::string WechatService::GetTranslateVoiceText(UINT64 msg_id) {
|
||||
std::string content = DB::GetInstance().GetChatMsgStrContentByMsgId(msg_id);
|
||||
if (content.empty()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
tinyxml2::XMLDocument doc;
|
||||
if (doc.Parse(content.c_str(), content.size()) != 0) {
|
||||
SPDLOG_INFO("tinyxml2 parse error");
|
||||
return {};
|
||||
}
|
||||
tinyxml2::XMLElement *msg = doc.FirstChildElement("msg");
|
||||
if (msg != nullptr) {
|
||||
tinyxml2::XMLElement *voicetrans = msg->FirstChildElement("voicetrans");
|
||||
if (voicetrans != nullptr) {
|
||||
const char *value = voicetrans->Attribute("transtext",nullptr);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
} // namespace wxhelper
|
@ -1,102 +0,0 @@
|
||||
#include "wxutils.h"
|
||||
|
||||
#include "utils.h"
|
||||
#define BUFSIZE 1024
|
||||
#define JPEG0 0xFF
|
||||
#define JPEG1 0xD8
|
||||
#define JPEG2 0xFF
|
||||
#define PNG0 0x89
|
||||
#define PNG1 0x50
|
||||
#define PNG2 0x4E
|
||||
#define BMP0 0x42
|
||||
#define BMP1 0x4D
|
||||
#define GIF0 0x47
|
||||
#define GIF1 0x49
|
||||
#define GIF2 0x46
|
||||
namespace wxhelper {
|
||||
namespace wxutils {
|
||||
UINT64 GetWeChatWinBase() { return (UINT64)GetModuleHandleA("WeChatWin.dll"); }
|
||||
|
||||
std::string ReadSKBuiltinString(INT64 addr) {
|
||||
INT64 inner_string = *(INT64 *)(addr + 0x8);
|
||||
if (inner_string == 0) {
|
||||
return std::string();
|
||||
}
|
||||
return ReadWeChatStr(inner_string);
|
||||
}
|
||||
|
||||
std::string ReadSKBuiltinBuffer(INT64 addr) {
|
||||
INT64 len = *(INT64 *)(addr + 0x10);
|
||||
if (len == 0) {
|
||||
return std::string();
|
||||
}
|
||||
INT64 inner_string = *(INT64 *)(addr + 0x8);
|
||||
if (inner_string == 0) {
|
||||
return std::string();
|
||||
}
|
||||
return ReadWeChatStr(inner_string);
|
||||
}
|
||||
|
||||
std::string ReadWeChatStr(INT64 addr) {
|
||||
INT64 len = *(INT64 *)(addr + 0x10);
|
||||
if (len == 0) {
|
||||
return std::string();
|
||||
}
|
||||
INT64 max_len = *(INT64 *)(addr + 0x18);
|
||||
if ((max_len | 0xF) == 0xF) {
|
||||
return std::string((char *)addr, len);
|
||||
}
|
||||
char *char_from_user = *(char **)(addr);
|
||||
return std::string(char_from_user, len);
|
||||
}
|
||||
|
||||
std::string ImageXor(std::string buf) {
|
||||
const char *origin = buf.c_str();
|
||||
short key = 0;
|
||||
if ((*origin ^ JPEG0) == (*(origin + 1) ^ JPEG1)) {
|
||||
key = *origin ^ JPEG0;
|
||||
} else if ((*origin ^ PNG1) == (*(origin + 1) ^ PNG2)) {
|
||||
key = *origin ^ PNG1;
|
||||
} else if ((*origin ^ GIF0) == (*(origin + 1) ^ GIF1)) {
|
||||
key = *origin ^ GIF0;
|
||||
} else if ((*origin ^ BMP0) == (*(origin + 1) ^ BMP1)) {
|
||||
key = *origin ^ BMP0;
|
||||
} else {
|
||||
key = -1;
|
||||
}
|
||||
if (key > 0) {
|
||||
char *img_buf = new char[buf.size()];
|
||||
for (unsigned int i = 0; i < buf.size(); i++) {
|
||||
img_buf[i] = *(origin + i) ^ key;
|
||||
}
|
||||
std::string str(img_buf);
|
||||
delete[] img_buf;
|
||||
img_buf = NULL;
|
||||
return str;
|
||||
}
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::wstring ReadWstring(INT64 addr) {
|
||||
DWORD len = *(DWORD *)(addr + 0x8);
|
||||
if (len == 0) {
|
||||
return std::wstring();
|
||||
}
|
||||
wchar_t *str = *(wchar_t **)(addr);
|
||||
if (str == NULL) {
|
||||
return std::wstring();
|
||||
}
|
||||
return std::wstring(str, len);
|
||||
}
|
||||
std::string ReadWstringThenConvert(INT64 addr) {
|
||||
std::wstring wstr = ReadWstring(addr);
|
||||
return base::utils::WstringToUtf8(wstr);
|
||||
}
|
||||
|
||||
INT64 DecodeImage(const wchar_t* file_path, const wchar_t* save_dir){
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
} // namespace wxutils
|
||||
} // namespace wxhelper
|
@ -1,21 +0,0 @@
|
||||
#ifndef WXHELPER_WXUTILS_H_
|
||||
#define WXHELPER_WXUTILS_H_
|
||||
#include <windows.h>
|
||||
#include <string>
|
||||
namespace wxhelper {
|
||||
namespace wxutils {
|
||||
|
||||
UINT64 GetWeChatWinBase();
|
||||
std::string ReadSKBuiltinString(INT64 addr);
|
||||
std::string ReadSKBuiltinBuffer(INT64 addr);
|
||||
std::string ReadWeChatStr(INT64 addr);
|
||||
|
||||
std::string ImageXor(std::string buf);
|
||||
std::wstring ReadWstring(INT64 addr);
|
||||
std::string ReadWstringThenConvert(INT64 addr);
|
||||
|
||||
INT64 DecodeImage(const wchar_t* file_path, const wchar_t* save_dir);
|
||||
} // namespace wxutils
|
||||
|
||||
} // namespace wxhelper
|
||||
#endif
|
@ -132,7 +132,7 @@ data: 接口返回的数据
|
||||
"dataSavePath": "C:\\wechatDir\\WeChat Files\\",
|
||||
"dbKey": "965715e30e474da09250cb5aa047e3940ffa1c8f767c4263b132bb512933db49",
|
||||
"headImage": "https://wx.qlogo.cn/mmhead/ver_1/MiblV0loY0GILewQ4u2121",
|
||||
"mobile": "13913913913",
|
||||
"mobile": "13949175447",
|
||||
"name": "xxx",
|
||||
"province": "Henan",
|
||||
"signature": "xxx",
|
||||
|
462
doc/3.9.7.29.md
462
doc/3.9.7.29.md
@ -1,462 +0,0 @@
|
||||
|
||||
|
||||
## 3.9.7.29版本,http接口文档,文档仅供参考。
|
||||
|
||||
### 简单说明:
|
||||
所有接口只支持post方法。
|
||||
全部使用json格式。
|
||||
格式: http://host:port/api/xxxx
|
||||
host: 绑定的host
|
||||
port: 监听的端口
|
||||
xxxx: 对应的功能路径
|
||||
返回结构的json格式:
|
||||
``` javascript
|
||||
{
|
||||
"code": 1,
|
||||
"data": {},
|
||||
"msg": "success"
|
||||
}
|
||||
```
|
||||
code: 错误码
|
||||
msg: 成功/错误信息
|
||||
data: 接口返回的数据
|
||||
|
||||
|
||||
接口与3.9.5.81基本无变化,优化了httpclient连接。
|
||||
config.ini 配置文件可以配置http服务端口和隐藏dll
|
||||
```
|
||||
Port=19088
|
||||
HiddenDll=0 //1隐藏 0不隐藏
|
||||
|
||||
```
|
||||
|
||||
|
||||
#### 0.检查微信登录**
|
||||
###### 接口功能
|
||||
> 检查微信是否登录
|
||||
|
||||
###### 接口地址
|
||||
> [/api/checkLogin](/api/checkLogin)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,1 成功, 0失败|
|
||||
|result|string|成功提示|
|
||||
|data|string|响应内容|
|
||||
|
||||
###### 接口示例
|
||||
入参:
|
||||
``` javascript
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 1,
|
||||
"msg": "success",
|
||||
"data":null
|
||||
}
|
||||
```
|
||||
|
||||
#### 1.获取登录用户信息**
|
||||
###### 接口功能
|
||||
> 获取登录用户信息
|
||||
|
||||
###### 接口地址
|
||||
> [/api/userInfo](/api/userInfo)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,1 成功, 0失败|
|
||||
|result|string|成功提示|
|
||||
|data|object|响应内容|
|
||||
|  account|string|账号|
|
||||
|  headImage|string|头像|
|
||||
|  city|string|城市|
|
||||
|  country|string|国家|
|
||||
|  currentDataPath|string|当前数据目录,登录的账号目录|
|
||||
|  dataSavePath|string|微信保存目录|
|
||||
|  mobile|string|手机|
|
||||
|  name|string|昵称|
|
||||
|  province|string|省|
|
||||
|  wxid|string|wxid|
|
||||
|  signature|string|个人签名|
|
||||
|  dbKey|string|数据库的SQLCipher的加密key,可以使用该key配合decrypt.py解密数据库
|
||||
|
||||
###### 接口示例
|
||||
入参:
|
||||
``` javascript
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 1,
|
||||
"data": {
|
||||
"account": "xxx",
|
||||
"city": "Zhengzhou",
|
||||
"country": "CN",
|
||||
"currentDataPath": "C:\\WeChat Files\\wxid_xxx\\",
|
||||
"dataSavePath": "C:\\wechatDir\\WeChat Files\\",
|
||||
"dbKey": "965715e30e474da09250cb5aa047e3940ffa1c8f767c4263b132bb512933db49",
|
||||
"headImage": "https://wx.qlogo.cn/mmhead/ver_1/MiblV0loY0GILewQ4u2121",
|
||||
"mobile": "13913913913",
|
||||
"name": "xxx",
|
||||
"province": "Henan",
|
||||
"signature": "xxx",
|
||||
"wxid": "wxid_22222"
|
||||
},
|
||||
"msg": "success"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### 2.发送文本消息**
|
||||
###### 接口功能
|
||||
> 发送文本消息
|
||||
|
||||
###### 接口地址
|
||||
> [/api/sendTextMsg](/api/sendTextMsg)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|wxid |true |string| 接收人wxid |
|
||||
|msg|true |string|消息文本内容|
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,不为0成功, 0失败|
|
||||
|msg|string|成功提示|
|
||||
|data|object|null|
|
||||
|
||||
|
||||
###### 接口示例
|
||||
|
||||
入参:
|
||||
``` javascript
|
||||
{
|
||||
"wxid": "filehelper",
|
||||
"msg": "1112222"
|
||||
}
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{"code":345686720,"msg":"success","data":null}
|
||||
```
|
||||
|
||||
#### 3.hook消息**
|
||||
###### 接口功能
|
||||
> hook接收文本消息,图片消息,群消息.该接口将hook的消息通过tcp回传给本地的端口。
|
||||
enableHttp=1时,使用url,timeout参数配置服务端的接收地址。请求为post,Content-Type 为json。
|
||||
enableHttp=0时,使用ip,port的tcp服务回传消息。
|
||||
|
||||
###### 接口地址
|
||||
> [/api/hookSyncMsg](/api/hookSyncMsg)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|port |true |string| 本地服务端端口,用来接收消息内容 |
|
||||
|ip |true |string| 服务端ip地址,用来接收消息内容,可以是任意ip,即tcp客户端连接的服务端的ip|
|
||||
|url |true |string| http的请求地址,enableHttp=1时,不能为空 |
|
||||
|timeout |true |string| 超时时间,单位ms|
|
||||
|enableHttp |true |number| 0/1 :1.启用http 0.不启用http|
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,0成功, 非0失败|
|
||||
|data|object|null|
|
||||
|msg|string|成功提示|
|
||||
|
||||
|
||||
###### 接口示例
|
||||
入参:
|
||||
``` javascript
|
||||
{
|
||||
"port": "19099",
|
||||
"ip":"127.0.0.1",
|
||||
"url":"http://localhost:8080",
|
||||
"timeout":"3000",
|
||||
"enableHttp":"0"
|
||||
}
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{"code":0,"msg":"success","data":null}
|
||||
```
|
||||
|
||||
#### 4.取消hook消息**
|
||||
###### 接口功能
|
||||
> 取消hook消息
|
||||
|
||||
###### 接口地址
|
||||
> [/api/unhookSyncMsg](/api/unhookSyncMsg)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,0成功, 非0失败|
|
||||
|data|object|null|
|
||||
|msg|string|成功提示|
|
||||
|
||||
|
||||
###### 接口示例
|
||||
入参:
|
||||
``` javascript
|
||||
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{"code":0,"msg":"success","data":null}
|
||||
```
|
||||
|
||||
#### 5.好友列表**
|
||||
###### 接口功能
|
||||
> 好友列表
|
||||
|
||||
###### 接口地址
|
||||
> [/api/getContactList](/api/getContactList)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,0成功, 非0失败|
|
||||
|data|object|好友信息|
|
||||
|  customAccount|string|自定义账号|
|
||||
|  encryptName|string|昵称|
|
||||
|  nickname|string|昵称|
|
||||
|  pinyin|string|简拼|
|
||||
|  pinyinAll|string|全拼|
|
||||
|  reserved1|number|未知|
|
||||
|  reserved2|number|未知|
|
||||
|  type|number|未知|
|
||||
|  verifyFlag|number|未知|
|
||||
|  wxid|string|wxid|
|
||||
|msg|string|成功提示|
|
||||
|
||||
|
||||
###### 接口示例
|
||||
入参:
|
||||
``` javascript
|
||||
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 1,
|
||||
"data": [
|
||||
{
|
||||
"customAccount": "",
|
||||
"encryptName": "v3_020b3826fd03010000000000e04128fddf4d90000000501ea9a3dba12f95f6b60a0536a1adb6b40fc4086288f46c0b89e6c4eb8062bb1661b4b6fbab708dc4f89d543d7ade135b2be74c14b9cfe3accef377b9@stranger",
|
||||
"nickname": "文件传输助手",
|
||||
"pinyin": "WJCSZS",
|
||||
"pinyinAll": "wenjianchuanshuzhushou",
|
||||
"reserved1": 1,
|
||||
"reserved2": 1,
|
||||
"type": 3,
|
||||
"verifyFlag": 0,
|
||||
"wxid": "filehelper"
|
||||
}
|
||||
].
|
||||
"msg": "success"
|
||||
|
||||
```
|
||||
|
||||
#### 6.获取数据库信息**
|
||||
###### 接口功能
|
||||
> 获取数据库信息和句柄
|
||||
|
||||
###### 接口地址
|
||||
> [/api/getDBInfo](/api/getDBInfo)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,0成功, 非0失败|
|
||||
|msg|string|返回信息|
|
||||
|data|array|好友信息|
|
||||
|  databaseName|string|数据库名称|
|
||||
|  handle|number|句柄|
|
||||
|  tables|array|表信息|
|
||||
|    name|string|表名|
|
||||
|    rootpage|string|rootpage|
|
||||
|    sql|string|ddl语句|
|
||||
|    tableName|string|表名|
|
||||
|
||||
|
||||
###### 接口示例
|
||||
入参:
|
||||
``` javascript
|
||||
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 1,
|
||||
"data": [
|
||||
{
|
||||
"databaseName": "MicroMsg.db",
|
||||
"handle": 1755003930784,
|
||||
"tables": [
|
||||
{
|
||||
"name": "Contact",
|
||||
"rootpage": "2",
|
||||
"sql": "CREATE TABLE Contact(UserName TEXT PRIMARY KEY ,Alias TEXT,EncryptUserName TEXT,DelFlag INTEGER DEFAULT 0,Type INTEGER DEFAULT 0,VerifyFlag INTEGER DEFAULT 0,Reserved1 INTEGER DEFAULT 0,Reserved2 INTEGER DEFAULT 0,Reserved3 TEXT,Reserved4 TEXT,Remark TEXT,NickName TEXT,LabelIDList TEXT,DomainList TEXT,ChatRoomType int,PYInitial TEXT,QuanPin TEXT,RemarkPYInitial TEXT,RemarkQuanPin TEXT,BigHeadImgUrl TEXT,SmallHeadImgUrl TEXT,HeadImgMd5 TEXT,ChatRoomNotify INTEGER DEFAULT 0,Reserved5 INTEGER DEFAULT 0,Reserved6 TEXT,Reserved7 TEXT,ExtraBuf BLOB,Reserved8 INTEGER DEFAULT 0,Reserved9 INTEGER DEFAULT 0,Reserved10 TEXT,Reserved11 TEXT)",
|
||||
"tableName": "Contact"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"msg":"success"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### 7.查询数据库**
|
||||
###### 接口功能
|
||||
> 查询数据库
|
||||
|
||||
###### 接口地址
|
||||
> [/api/execSql](/api/execSql)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|dbHandle |true |number| |
|
||||
|sql |true |string| 执行的sql |
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,0成功, 非0失败|
|
||||
|msg|string|返回信息|
|
||||
|data|array|sqlite返回的结果|
|
||||
|
||||
|
||||
|
||||
###### 接口示例
|
||||
入参:
|
||||
``` javascript
|
||||
{
|
||||
"dbHandle":2006119800400,
|
||||
"sql":"select * from MSG where localId =301;"
|
||||
}
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 1,
|
||||
"data": [
|
||||
[
|
||||
"localId",
|
||||
"TalkerId",
|
||||
"MsgSvrID",
|
||||
"Type",
|
||||
"SubType",
|
||||
"IsSender",
|
||||
"CreateTime",
|
||||
"Sequence",
|
||||
"StatusEx",
|
||||
"FlagEx",
|
||||
"Status",
|
||||
"MsgServerSeq",
|
||||
"MsgSequence",
|
||||
"StrTalker",
|
||||
"StrContent",
|
||||
"DisplayContent",
|
||||
"Reserved0",
|
||||
"Reserved1",
|
||||
"Reserved2",
|
||||
"Reserved3",
|
||||
"Reserved4",
|
||||
"Reserved5",
|
||||
"Reserved6",
|
||||
"CompressContent",
|
||||
"BytesExtra",
|
||||
"BytesTrans"
|
||||
],
|
||||
[
|
||||
"301",
|
||||
"1",
|
||||
"8824834301214701891",
|
||||
"1",
|
||||
"0",
|
||||
"0",
|
||||
"1685401473",
|
||||
"1685401473000",
|
||||
"0",
|
||||
"0",
|
||||
"2",
|
||||
"1",
|
||||
"795781866",
|
||||
"wxid_123",
|
||||
"testtest",
|
||||
"",
|
||||
"0",
|
||||
"2",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"CgQIEBAAGo0BCAcSiAE8bXNnc291cmNlPJPHNpZ25hdHVyZT52MV9wd12bTZyRzwvc2lnbmF0dXJPgoJPHRtcF9ub2RlPgoJCTxwsaXNoZXItaWQ+Jmx0OyFbQ0RBVEFbXV0mZ3Q7PC9wdWJsaXNoZXItaWQ+Cgk8L3RtcF9ub2RlPgo8L21zZ3NvdXJjZT4KGiQIAhIgNDE1MDA0NjRhZTRmMjk2NjhjMzY2ZjFkOTdmMjAwNDg=",
|
||||
""
|
||||
]
|
||||
],
|
||||
"msg": "success"
|
||||
}
|
||||
```
|
951
doc/3.9.8.25.md
951
doc/3.9.8.25.md
@ -1,951 +0,0 @@
|
||||
#### 编译构建
|
||||
环境:
|
||||
cl.exe目录= c:/cl.exe
|
||||
ml64.exe目录 =c:/ml64.exe
|
||||
vcpkg目录 = c:/vcpkg
|
||||
wxhelper目录 = c:/wxhelper
|
||||
```
|
||||
|
||||
vcpkg install detours:x64-windows
|
||||
vcpkg install nlohmann-json:x64-windows
|
||||
|
||||
cd wxhelper
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DCMAKE_C_COMPILER=cl.exe \
|
||||
-DCMAKE_CXX_COMPILER=cl.exe \
|
||||
-DCMAKE_ASM_MASM_COMPILER=ml64.exe \
|
||||
-DCMAKE_BUILD_TYPE=Debug \
|
||||
-DCMAKE_INSTALL_PREFIX=C:/wxhelper/install/x64-debug \
|
||||
-DCMAKE_TOOLCHAIN_FILE:FILEPATH=C:/vcpkg/scripts/buildsystems/vcpkg.cmake \
|
||||
-SC:c:/wxhelper \
|
||||
-BC:c:/wxhelper/build/x64-debug\
|
||||
-G Ninja
|
||||
cmake --build ..
|
||||
```
|
||||
如果有错误按错误提示修正即可。
|
||||
|
||||
## 3.9.8.25版本,http接口文档,文档仅供参考。
|
||||
|
||||
### 简单说明:
|
||||
所有接口只支持post方法。
|
||||
全部使用json格式。
|
||||
格式: http://host:port/api/xxxx
|
||||
host: 绑定的host
|
||||
port: 监听的端口
|
||||
xxxx: 对应的功能路径
|
||||
返回结构的json格式:
|
||||
``` javascript
|
||||
{
|
||||
"code": 1,
|
||||
"data": {},
|
||||
"msg": "success"
|
||||
}
|
||||
```
|
||||
code: 错误码
|
||||
msg: 成功/错误信息
|
||||
data: 接口返回的数据
|
||||
|
||||
|
||||
|
||||
#### 0.检查微信登录**
|
||||
###### 接口功能
|
||||
> 检查微信是否登录
|
||||
|
||||
###### 接口地址
|
||||
> [/api/checkLogin](/api/checkLogin)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,1 成功, 0失败|
|
||||
|result|string|成功提示|
|
||||
|data|string|响应内容|
|
||||
|
||||
###### 接口示例
|
||||
入参:
|
||||
``` javascript
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 1,
|
||||
"msg": "success",
|
||||
"data":null
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### 1.获取登录用户信息**
|
||||
###### 接口功能
|
||||
> 获取登录用户信息
|
||||
|
||||
###### 接口地址
|
||||
> [/api/userInfo](/api/userInfo)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,1 成功, 0失败|
|
||||
|result|string|成功提示|
|
||||
|data|object|响应内容|
|
||||
|  account|string|账号|
|
||||
|  headImage|string|头像|
|
||||
|  city|string|城市|
|
||||
|  country|string|国家|
|
||||
|  currentDataPath|string|当前数据目录,登录的账号目录|
|
||||
|  dataSavePath|string|微信保存目录|
|
||||
|  mobile|string|手机|
|
||||
|  name|string|昵称|
|
||||
|  province|string|省|
|
||||
|  wxid|string|wxid|
|
||||
|  signature|string|个人签名|
|
||||
|  dbKey|string|数据库的SQLCipher的加密key,可以使用该key配合decrypt.py解密数据库
|
||||
|
||||
###### 接口示例
|
||||
入参:
|
||||
``` javascript
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 1,
|
||||
"data": {
|
||||
"account": "xxx",
|
||||
"city": "Zhengzhou",
|
||||
"country": "CN",
|
||||
"currentDataPath": "C:\\WeChat Files\\wxid_xxx\\",
|
||||
"dataSavePath": "C:\\wechatDir\\WeChat Files\\",
|
||||
"dbKey": "965715e30e474da09250cb5aa047e3940ffa1c8f767c4263b132bb512933db49",
|
||||
"headImage": "https://wx.qlogo.cn/mmhead/ver_1/MiblV0loY0GILewQ4u2121",
|
||||
"mobile": "13912341234",
|
||||
"name": "xxx",
|
||||
"province": "Henan",
|
||||
"signature": "xxx",
|
||||
"wxid": "wxid_22222",
|
||||
"privateKey":"-----BEGIN RSA PRIVATE KEY-----\nMIICXAIBAAKBgQCsC8wKKfylbnl0QpcowI4XDoCMlDptEeVq1aY0w9nR62llfjVL\nKIDbHMf9+tCxv5MWBuxrZgldzLkSQ/M5XwL5HQrO+XTj9Sx/ -END RSA PRIVATE KEY-----\n",
|
||||
"publicKey":"-----BEGIN PUBLIC KEY-----\nMIGfMA0GCSqGSIb3DQEBAQAB\n-----END PUBLIC KEY-----\n"
|
||||
},
|
||||
"msg": "success"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### 2.发送文本消息**
|
||||
###### 接口功能
|
||||
> 发送文本消息
|
||||
|
||||
###### 接口地址
|
||||
> [/api/sendTextMsg](/api/sendTextMsg)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|wxid |true |string| 接收人wxid |
|
||||
|msg|true |string|消息文本内容|
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,不为0成功, 0失败|
|
||||
|msg|string|成功提示|
|
||||
|data|object|null|
|
||||
|
||||
|
||||
###### 接口示例
|
||||
|
||||
入参:
|
||||
``` javascript
|
||||
{
|
||||
"wxid": "filehelper",
|
||||
"msg": "1112222"
|
||||
}
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{"code":345686720,"msg":"success","data":null}
|
||||
```
|
||||
|
||||
#### 3.hook消息**
|
||||
###### 接口功能
|
||||
> hook接收文本消息,图片消息,群消息.该接口将hook的消息通过tcp回传给本地的端口。
|
||||
enableHttp=1时,使用url,timeout参数配置服务端的接收地址。请求为post,Content-Type 为json。
|
||||
enableHttp=0时,使用ip,port的tcp服务回传消息。
|
||||
|
||||
###### 接口地址
|
||||
> [/api/hookSyncMsg](/api/hookSyncMsg)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|port |true |string| 本地服务端端口,用来接收消息内容 |
|
||||
|ip |true |string| 服务端ip地址,用来接收消息内容,可以是任意ip,即tcp客户端连接的服务端的ip|
|
||||
|url |true |string| http的请求地址,enableHttp=1时,不能为空 |
|
||||
|timeout |true |string| 超时时间,单位ms|
|
||||
|enableHttp |true |bool| true/false :true.启用http false.不启用http|
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,0成功, 非0失败|
|
||||
|data|object|null|
|
||||
|msg|string|成功提示|
|
||||
|
||||
|
||||
###### 接口示例
|
||||
入参:
|
||||
``` javascript
|
||||
{
|
||||
"port": "19099",
|
||||
"ip":"127.0.0.1",
|
||||
"url":"http://localhost:8080",
|
||||
"timeout":"3000",
|
||||
"enableHttp":false
|
||||
}
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{"code":0,"msg":"success","data":null}
|
||||
```
|
||||
|
||||
#### 4.取消hook消息**
|
||||
###### 接口功能
|
||||
> 取消hook消息
|
||||
|
||||
###### 接口地址
|
||||
> [/api/unhookSyncMsg](/api/unhookSyncMsg)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,0成功, 非0失败|
|
||||
|data|object|null|
|
||||
|msg|string|成功提示|
|
||||
|
||||
|
||||
###### 接口示例
|
||||
入参:
|
||||
``` javascript
|
||||
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{"code":0,"msg":"success","data":null}
|
||||
```
|
||||
|
||||
#### 5.好友列表**
|
||||
###### 接口功能
|
||||
> 好友列表
|
||||
|
||||
###### 接口地址
|
||||
> [/api/getContactList](/api/getContactList)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,0成功, 非0失败|
|
||||
|data|object|好友信息|
|
||||
|  customAccount|string|自定义账号|
|
||||
|  encryptName|string|昵称|
|
||||
|  nickname|string|昵称|
|
||||
|  pinyin|string|简拼|
|
||||
|  pinyinAll|string|全拼|
|
||||
|  reserved1|number|未知|
|
||||
|  reserved2|number|未知|
|
||||
|  type|number|未知|
|
||||
|  verifyFlag|number|未知|
|
||||
|  wxid|string|wxid|
|
||||
|msg|string|成功提示|
|
||||
|
||||
|
||||
###### 接口示例
|
||||
入参:
|
||||
``` javascript
|
||||
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 1,
|
||||
"data": [
|
||||
{
|
||||
"customAccount": "",
|
||||
"encryptName": "v3_020b3826fd03010000000000e04128fddf4d90000000501ea9a3dba12f95f6b60a0536a1adb6b40fc4086288f46c0b89e6c4eb8062bb1661b4b6fbab708dc4f89d543d7ade135b2be74c14b9cfe3accef377b9@stranger",
|
||||
"nickname": "文件传输助手",
|
||||
"pinyin": "WJCSZS",
|
||||
"pinyinAll": "wenjianchuanshuzhushou",
|
||||
"reserved1": 1,
|
||||
"reserved2": 1,
|
||||
"type": 3,
|
||||
"verifyFlag": 0,
|
||||
"wxid": "filehelper"
|
||||
}
|
||||
].
|
||||
"msg": "success"
|
||||
|
||||
```
|
||||
|
||||
#### 6.获取数据库信息**
|
||||
###### 接口功能
|
||||
> 获取数据库信息和句柄
|
||||
|
||||
###### 接口地址
|
||||
> [/api/getDBInfo](/api/getDBInfo)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,0成功, 非0失败|
|
||||
|msg|string|返回信息|
|
||||
|data|array|好友信息|
|
||||
|  databaseName|string|数据库名称|
|
||||
|  handle|number|句柄|
|
||||
|  tables|array|表信息|
|
||||
|    name|string|表名|
|
||||
|    rootpage|string|rootpage|
|
||||
|    sql|string|ddl语句|
|
||||
|    tableName|string|表名|
|
||||
|
||||
|
||||
###### 接口示例
|
||||
入参:
|
||||
``` javascript
|
||||
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 1,
|
||||
"data": [
|
||||
{
|
||||
"databaseName": "MicroMsg.db",
|
||||
"handle": 1755003930784,
|
||||
"tables": [
|
||||
{
|
||||
"name": "Contact",
|
||||
"rootpage": "2",
|
||||
"sql": "CREATE TABLE Contact(UserName TEXT PRIMARY KEY ,Alias TEXT,EncryptUserName TEXT,DelFlag INTEGER DEFAULT 0,Type INTEGER DEFAULT 0,VerifyFlag INTEGER DEFAULT 0,Reserved1 INTEGER DEFAULT 0,Reserved2 INTEGER DEFAULT 0,Reserved3 TEXT,Reserved4 TEXT,Remark TEXT,NickName TEXT,LabelIDList TEXT,DomainList TEXT,ChatRoomType int,PYInitial TEXT,QuanPin TEXT,RemarkPYInitial TEXT,RemarkQuanPin TEXT,BigHeadImgUrl TEXT,SmallHeadImgUrl TEXT,HeadImgMd5 TEXT,ChatRoomNotify INTEGER DEFAULT 0,Reserved5 INTEGER DEFAULT 0,Reserved6 TEXT,Reserved7 TEXT,ExtraBuf BLOB,Reserved8 INTEGER DEFAULT 0,Reserved9 INTEGER DEFAULT 0,Reserved10 TEXT,Reserved11 TEXT)",
|
||||
"tableName": "Contact"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"msg":"success"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### 7.查询数据库**
|
||||
###### 接口功能
|
||||
> 查询数据库
|
||||
|
||||
###### 接口地址
|
||||
> [/api/execSql](/api/execSql)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|dbHandle |true |number| |
|
||||
|sql |true |string| 执行的sql |
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,0成功, 非0失败|
|
||||
|msg|string|返回信息|
|
||||
|data|array|sqlite返回的结果|
|
||||
|
||||
|
||||
|
||||
###### 接口示例
|
||||
入参:
|
||||
``` javascript
|
||||
{
|
||||
"dbHandle":2006119800400,
|
||||
"sql":"select * from MSG where localId =301;"
|
||||
}
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 1,
|
||||
"data": [
|
||||
[
|
||||
"localId",
|
||||
"TalkerId",
|
||||
"MsgSvrID",
|
||||
"Type",
|
||||
"SubType",
|
||||
"IsSender",
|
||||
"CreateTime",
|
||||
"Sequence",
|
||||
"StatusEx",
|
||||
"FlagEx",
|
||||
"Status",
|
||||
"MsgServerSeq",
|
||||
"MsgSequence",
|
||||
"StrTalker",
|
||||
"StrContent",
|
||||
"DisplayContent",
|
||||
"Reserved0",
|
||||
"Reserved1",
|
||||
"Reserved2",
|
||||
"Reserved3",
|
||||
"Reserved4",
|
||||
"Reserved5",
|
||||
"Reserved6",
|
||||
"CompressContent",
|
||||
"BytesExtra",
|
||||
"BytesTrans"
|
||||
],
|
||||
[
|
||||
"301",
|
||||
"1",
|
||||
"8824834301214701891",
|
||||
"1",
|
||||
"0",
|
||||
"0",
|
||||
"1685401473",
|
||||
"1685401473000",
|
||||
"0",
|
||||
"0",
|
||||
"2",
|
||||
"1",
|
||||
"795781866",
|
||||
"wxid_123",
|
||||
"testtest",
|
||||
"",
|
||||
"0",
|
||||
"2",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"CgQIEBAAGo0BCAcSiAE8bXNnc291cmNlPJPHNpZ25hdHVyZT52MV9wd12bTZyRzwvc2lnbmF0dXJPgoJPHRtcF9ub2RlPgoJCTxwsaXNoZXItaWQ+Jmx0OyFbQ0RBVEFbXV0mZ3Q7PC9wdWJsaXNoZXItaWQ+Cgk8L3RtcF9ub2RlPgo8L21zZ3NvdXJjZT4KGiQIAhIgNDE1MDA0NjRhZTRmMjk2NjhjMzY2ZjFkOTdmMjAwNDg=",
|
||||
""
|
||||
]
|
||||
],
|
||||
"msg": "success"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### 8.锁定微信**
|
||||
###### 接口功能
|
||||
> 锁定微信
|
||||
|
||||
###### 接口地址
|
||||
> [/api/lockWeChat](/api/lockWeChat)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,大于0成功, 小于0失败|
|
||||
|msg|string|返回信息|
|
||||
|data|object|null|
|
||||
|
||||
|
||||
|
||||
###### 接口示例
|
||||
入参:
|
||||
``` javascript
|
||||
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 2,
|
||||
"data": null,
|
||||
"msg": "success"
|
||||
}
|
||||
```
|
||||
|
||||
#### 9.解锁微信**
|
||||
###### 接口功能
|
||||
> 锁定微信
|
||||
|
||||
###### 接口地址
|
||||
> [/api/unlockWeChat](/api/unlockWeChat)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,大于0成功, 小于0失败|
|
||||
|msg|string|返回信息|
|
||||
|data|object|null|
|
||||
|
||||
|
||||
|
||||
###### 接口示例
|
||||
入参:
|
||||
``` javascript
|
||||
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 2,
|
||||
"data": null,
|
||||
"msg": "success"
|
||||
}
|
||||
```
|
||||
|
||||
#### 10.进入微信**
|
||||
###### 接口功能
|
||||
> 打开微信时的进入微信按钮
|
||||
|
||||
###### 接口地址
|
||||
> [/api/clickEnterWeChat](/api/clickEnterWeChat)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,大于0成功, 小于0失败|
|
||||
|msg|string|返回信息|
|
||||
|data|object|null|
|
||||
|
||||
|
||||
|
||||
###### 接口示例
|
||||
入参:
|
||||
``` javascript
|
||||
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 1,
|
||||
"data": null,
|
||||
"msg": "success"
|
||||
}
|
||||
```
|
||||
|
||||
#### 11.转发消息**
|
||||
###### 接口功能
|
||||
> 转发微信消息
|
||||
|
||||
###### 接口地址
|
||||
> [/api/forwardMsg](/api/forwardMsg)
|
||||
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|wxid|string|接收人id|
|
||||
|msgId|string|消息id|
|
||||
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,1成功, -1失败|
|
||||
|msg|string|成功提示|
|
||||
|data|object|null|
|
||||
|
||||
|
||||
###### 接口示例
|
||||
|
||||
入参:
|
||||
``` javascript
|
||||
{
|
||||
"wxid":"filehelper",
|
||||
"msgId":"1233312233123"
|
||||
}
|
||||
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 1,
|
||||
"data": null,
|
||||
"msg": "success"
|
||||
}
|
||||
```
|
||||
|
||||
#### 12.发送图片**
|
||||
###### 接口功能
|
||||
> 发送图片
|
||||
|
||||
###### 接口地址I
|
||||
> [/api/sendImagesMsg](/api/sendImagesMsg)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|wxid|string|wxid|
|
||||
|imagePath|string|图片路径|
|
||||
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,大于0成功, -1失败|
|
||||
|msg|string|成功提示|
|
||||
|data|object|null|
|
||||
|
||||
###### 接口示例
|
||||
|
||||
入参:
|
||||
``` javascript
|
||||
|
||||
{
|
||||
"wxid":"filehelper",
|
||||
"imagePath":"C:\\test.png"
|
||||
}
|
||||
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 1,
|
||||
"data": {},
|
||||
"msg": "success"
|
||||
}
|
||||
```
|
||||
|
||||
#### 13.发送文件消息**
|
||||
###### 接口功能
|
||||
> 发送文件消息
|
||||
|
||||
###### 接口地址
|
||||
> [/api/sendFileMsg](/api/sendFileMsg)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|wxid |true |string| 接收人wxid |
|
||||
|filePath|true |string|文件绝对路径|
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,不为0成功, 0失败|
|
||||
|msg|string|成功提示|
|
||||
|data|object|null|
|
||||
|
||||
###### 接口示例
|
||||
|
||||
入参:
|
||||
``` javascript
|
||||
{
|
||||
"wxid": "filehelper",
|
||||
"filePath": "c:\\test.zip"
|
||||
}
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{"code":345686720,"msg":"success","data":null}
|
||||
```
|
||||
|
||||
#### 14.发送@消息**
|
||||
###### 接口功能
|
||||
> 发送@消息
|
||||
|
||||
###### 接口地址
|
||||
> [/api/sendAtText](/api/sendAtText)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|wxids|string|wxid字符串,多个用,分隔,发送所有人传值"notify@all"|
|
||||
|chatRoomId|string|群id|
|
||||
|msg|string|消息内容|
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,大于0成功, -1失败|
|
||||
|msg|string|成功提示|
|
||||
|data|object|null|
|
||||
|
||||
|
||||
###### 接口示例
|
||||
|
||||
入参:
|
||||
``` javascript
|
||||
{
|
||||
|
||||
"wxids":"notify@all",
|
||||
"chatRoomId":"123@chatroom",
|
||||
"msg":"你们好啊"
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 67316444768,
|
||||
"data": null,
|
||||
"msg": "success"
|
||||
}
|
||||
```
|
||||
|
||||
#### 15.发送多个不同@消息**
|
||||
###### 接口功能
|
||||
> 发送多个不同@消息
|
||||
|
||||
###### 接口地址
|
||||
> [/api/sendMultiAtText](/api/sendMultiAtText)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|chatRoomId|string|群id|
|
||||
|at|array|消息数组|
|
||||
|  msg|string|消息内容|
|
||||
|  wxid|string|wxid字符串,多个用,分隔,发送所有人传值"notify@all"|
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,大于0成功, -1失败|
|
||||
|msg|string|成功提示|
|
||||
|data|object|null|
|
||||
|
||||
|
||||
###### 接口示例
|
||||
|
||||
入参:
|
||||
``` javascript
|
||||
{
|
||||
"chatRoomId": "213111111004@chatroom",
|
||||
"at": [
|
||||
{
|
||||
"wxid": "wxid_123",
|
||||
"msg": "1112"
|
||||
},
|
||||
{
|
||||
"wxid": "notify@all",
|
||||
"msg": "2223"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 67316444768,
|
||||
"data": null,
|
||||
"msg": "success"
|
||||
}
|
||||
```
|
||||
|
||||
#### 16.获取扫码登录地址**
|
||||
###### 接口功能
|
||||
> 未登录状态下,获取登录地址,转换成二维码,手机扫码登录
|
||||
|
||||
###### 接口地址
|
||||
> [/api/getLoginUrl](/api/getLoginUrl)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,大于0成功, -1失败|
|
||||
|msg|string|成功提示|
|
||||
|data|object|返回内容|
|
||||
|  loginUrl|string|登录地址|
|
||||
|
||||
|
||||
###### 接口示例
|
||||
|
||||
入参:
|
||||
``` javascript
|
||||
|
||||
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 1,
|
||||
"data": {
|
||||
"loginUrl": "http://weixin.qq.com/x/extdevn1pwd_1YtY3pVY0FBTnhia1dScEtleDJ6Tl122231xJAWFVCcDAzSG5maXpjb2N0T3VmeZOUZlb0ZwdVKbFVN"
|
||||
},
|
||||
"msg": "success"
|
||||
}
|
||||
```
|
||||
|
||||
#### 17.语音转文本**
|
||||
###### 接口功能
|
||||
> 语音消息转换文本
|
||||
|
||||
###### 接口地址
|
||||
> [/api/translateVoice](/api/translateVoice)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|msgId|string|消息id|
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,大于0成功, -1失败|
|
||||
|msg|string|成功提示|
|
||||
|data|object|返回内容|
|
||||
|
||||
|
||||
|
||||
###### 接口示例
|
||||
|
||||
入参:
|
||||
``` javascript
|
||||
{
|
||||
"msgId":"23206240123137465"
|
||||
}
|
||||
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 1,
|
||||
"data": null,
|
||||
"msg": "success"
|
||||
}
|
||||
```
|
||||
|
||||
#### 18.获取语音转文本结果**
|
||||
###### 接口功能
|
||||
> 获取语音转文本结果 (可以使用数据库查询功能查询,该接口只是为了方便减少hook)
|
||||
|
||||
###### 接口地址
|
||||
> [/api/getTranslateVoiceText](/api/getTranslateVoiceText)
|
||||
|
||||
###### HTTP请求方式
|
||||
> POST JSON
|
||||
|
||||
###### 请求参数
|
||||
|参数|必选|类型|说明|
|
||||
|---|---|---|---|
|
||||
|msgId|string|消息id|
|
||||
|
||||
###### 返回字段
|
||||
|返回字段|字段类型|说明 |
|
||||
|---|---|---|
|
||||
|code|int|返回状态,大于0成功, -1失败|
|
||||
|msg|string|成功提示|
|
||||
|data|object|返回内容|
|
||||
|  transtext|string|转换文本|
|
||||
|
||||
|
||||
###### 接口示例
|
||||
|
||||
入参:
|
||||
``` javascript
|
||||
{
|
||||
"msgId":"23206212223137465"
|
||||
}
|
||||
|
||||
```
|
||||
响应:
|
||||
``` javascript
|
||||
{
|
||||
"code": 1,
|
||||
"data": {
|
||||
"transtext": "冲冲,冲冲。"
|
||||
},
|
||||
"msg": "success"
|
||||
}
|
||||
```
|
640
doc/postman.json
Normal file
640
doc/postman.json
Normal file
@ -0,0 +1,640 @@
|
||||
{
|
||||
"info": {
|
||||
"name": "Wechat Hook 395",
|
||||
"_postman_id": "d2b6a4f2-6d7d-4a21-9bbf-65b5a5a3a5a",
|
||||
"description": "A collection of Wechat Hook 395 API requests.",
|
||||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
||||
},
|
||||
"item": [
|
||||
{
|
||||
"name": "checkLogin",
|
||||
"request": {
|
||||
"url": {
|
||||
"raw": "http://127.0.0.1:19088/api/checkLogin",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"127.0.0.1"
|
||||
],
|
||||
"port": "19088",
|
||||
"path": [
|
||||
"api",
|
||||
"checkLogin"
|
||||
]
|
||||
},
|
||||
"method": "POST",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": ""
|
||||
},
|
||||
"description": "API to check login status."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "userInfo",
|
||||
"request": {
|
||||
"url": {
|
||||
"raw": "http://127.0.0.1:19088/api/userInfo",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"127.0.0.1"
|
||||
],
|
||||
"port": "19088",
|
||||
"path": [
|
||||
"api",
|
||||
"userInfo"
|
||||
]
|
||||
},
|
||||
"method": "POST",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": ""
|
||||
},
|
||||
"description": "API to get user information."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "sendTextMsg",
|
||||
"request": {
|
||||
"url": {
|
||||
"raw": "http://127.0.0.1:19088/api/sendTextMsg",
|
||||
"protocol": "http",
|
||||
"host": [
|
||||
"127.0.0.1"
|
||||
],
|
||||
"port": "19088",
|
||||
"path": [
|
||||
"api",
|
||||
"sendTextMsg"
|
||||
]
|
||||
},
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"wxid\": \"filehelper\",\"msg\": \"12www\"}"
|
||||
},
|
||||
"description": "API to send text messages."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "sendImagesMsg",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/sendImagesMsg",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"wxid\": \"filehelper\",\"imagePath\": \"C:\\pic.png\"}"
|
||||
},
|
||||
"description": "API to send image messages."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "sendFileMsg",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/sendFileMsg",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"wxid\": \"filehelper\",\"filePath\": \"C:\\test.zip\"}"
|
||||
},
|
||||
"description": "API to send file messages."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "hookSyncMsg",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/hookSyncMsg",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"port\": \"19099\",\"ip\": \"127.0.0.1\",\"url\": \"http://localhost:8080\",\"timeout\": \"3000\",\"enableHttp\": \"0\"}"
|
||||
},
|
||||
"description": "API to hook sync messages."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "unhookSyncMsg",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/unhookSyncMsg",
|
||||
"method": "POST",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": ""
|
||||
},
|
||||
"description": "API to unhook sync messages."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "getContactList",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/getContactList",
|
||||
"method": "POST",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": ""
|
||||
},
|
||||
"description": "API to get the contact list."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "getDBInfo",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/getDBInfo",
|
||||
"method": "POST",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": ""
|
||||
},
|
||||
"description": "API to get database information."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "execSql",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/execSql",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"dbHandle\": 1713425147584,\"sql\": \"select * from MSG where localId =100;\"}"
|
||||
},
|
||||
"description": "API to execute SQL queries."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "getChatRoomDetailInfo",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/getChatRoomDetailInfo",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"chatRoomId\": \"123333@chatroom\"}"
|
||||
},
|
||||
"description": "API to get chat room detail information."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "addMemberToChatRoom",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/addMemberToChatRoom",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"chatRoomId\": \"123@chatroom\",\"memberIds\": \"wxid_123\"}"
|
||||
},
|
||||
"description": "API to add member to chat room."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "delMemberFromChatRoom",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/delMemberFromChatRoom",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"chatRoomId\": \"21363231004@chatroom\",\"memberIds\": \"wxid_123\"}"
|
||||
},
|
||||
"description": "API to delete member from chat room."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "modifyNickname",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/modifyNickname",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"chatRoomId\": \"123@chatroom\",\"wxid\": \"wxid_123\",\"nickName\": \"test\"}"
|
||||
},
|
||||
"description": "API to modify a nickname in a chat room."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "getMemberFromChatRoom",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/getMemberFromChatRoom",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"chatRoomId\": \"123@chatroom\"}"
|
||||
},
|
||||
"description": "API to get members from a chat room."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "topMsg",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/topMsg",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"msgId\": 1222222}"
|
||||
},
|
||||
"description": "API to top a message."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "removeTopMsg",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/removeTopMsg",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"chatRoomId\": \"123@chatroom\",\"msgId\": 123}"
|
||||
},
|
||||
"description": "API to remove a topped message."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "InviteMemberToChatRoom",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/InviteMemberToChatRoom",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"chatRoomId\": \"123@chatroom\",\"memberIds\": \"wxid_123\"}"
|
||||
},
|
||||
"description": "API to invite members to a chat room."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "hookLog",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/hookLog",
|
||||
"method": "POST",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": ""
|
||||
},
|
||||
"description": "API to hook logs."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "unhookLog",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/unhookLog",
|
||||
"method": "POST",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": ""
|
||||
},
|
||||
"description": "API to unhook logs."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "createChatRoom",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/createChatRoom",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"memberIds\": \"wxid_8yn4k908tdqp22,wxid_oyb662qhop4422\"}"
|
||||
},
|
||||
"description": "API to create a chat room."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "quitChatRoom",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/quitChatRoom",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"chatRoomId\": \"123@chatroom\"}"
|
||||
},
|
||||
"description": "API to quit a chat room."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "forwardMsg",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/forwardMsg",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"wxid\": \"filehelper\",\"msgId\": \"12331\"}"
|
||||
},
|
||||
"description": "API to forward a message."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "getSNSFirstPage",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/getSNSFirstPage",
|
||||
"method": "POST",
|
||||
"header": [],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": ""
|
||||
},
|
||||
"description": "API to get the first page of SNS data."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "getSNSNextPage",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/getSNSNextPage",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"snsId\": \"\"}"
|
||||
},
|
||||
"description": "API to get the next page of SNS data."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "addFavFromMsg",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/addFavFromMsg",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"msgId\": \"1222222\"}"
|
||||
},
|
||||
"description": "API to add a favorite from a message."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "addFavFromImage",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/addFavFromImage",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"wxid\": \"\",\"imagePath\": \"\"}"
|
||||
},
|
||||
"description": "API to add a favorite from an image."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "getContactProfile",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/getContactProfile",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"wxid\": \"\"}"
|
||||
},
|
||||
"description": "API to get contact profile."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "sendAtText",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/sendAtText",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"wxids\": \"notify@all\",\"chatRoomId\": \"123@chatroom\",\"msg\": \"你好啊\"}"
|
||||
},
|
||||
"description": "API to send an at-text message."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "forwardPublicMsg",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/forwardPublicMsg",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"appName\": \"\",\"userName\": \"\",\"title\": \"\",\"url\": \"\",\"thumbUrl\": \"\",\"digest\": \"\",\"wxid\": \"filehelper\"}"
|
||||
},
|
||||
"description": "API to forward a public message."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "forwardPublicMsgByMsgId",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/forwardPublicMsgByMsgId",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"msgId\": 123,\"wxid\": \"filehelper\"}"
|
||||
},
|
||||
"description": "API to forward a public message by message ID."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "downloadAttach",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/downloadAttach",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"msgId\": 123}"
|
||||
},
|
||||
"description": "API to download an attachment."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "decodeImage",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/decodeImage",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"filePath\": \"C:\\66664816980131.dat\",\"storeDir\": \"C:\\test\"}"
|
||||
},
|
||||
"description": "API to decode an image."
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "getVoiceByMsgId",
|
||||
"request": {
|
||||
"url": "http://127.0.0.1:19088/api/getVoiceByMsgId",
|
||||
"method": "POST",
|
||||
"header": [
|
||||
{
|
||||
"key": "Content-Type",
|
||||
"value": "application/json",
|
||||
"description": "Specify that the request body is in JSON format."
|
||||
}
|
||||
],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"msgId\": 7880439644200,\"storeDir\": \"c:\\test\"}"
|
||||
},
|
||||
"description": "API to get voice by message ID."
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
11
go_client/main.go
Normal file
11
go_client/main.go
Normal file
@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"go_client/tcpserver"
|
||||
"log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
||||
tcpserver.Listen(19099)
|
||||
}
|
44
go_client/tcpserver/tcpserver.go
Normal file
44
go_client/tcpserver/tcpserver.go
Normal file
@ -0,0 +1,44 @@
|
||||
package tcpserver
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"log"
|
||||
"net"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func Listen(port int) {
|
||||
p := strconv.Itoa(port)
|
||||
adress := "127.0.0.1:" + p
|
||||
ln, err := net.Listen("tcp", adress)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer ln.Close()
|
||||
log.Println("tcp server started")
|
||||
for {
|
||||
conn, err := ln.Accept()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
continue
|
||||
}
|
||||
go handle(conn)
|
||||
}
|
||||
}
|
||||
|
||||
func handle(conn net.Conn) {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
log.Println("发生了未处理的异常", err)
|
||||
}
|
||||
}()
|
||||
defer conn.Close()
|
||||
scanner := bufio.NewScanner(conn)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Bytes()
|
||||
log.Println("收到消息:", string(line))
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
log.Println("错误:", err)
|
||||
}
|
||||
}
|
33
java_client/.gitignore
vendored
Normal file
33
java_client/.gitignore
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
21
java_client/README.md
Normal file
21
java_client/README.md
Normal file
@ -0,0 +1,21 @@
|
||||
环境为jdk17
|
||||
执行之后会在当前项目所处磁盘根路径生成一个exec文件夹,然后会把src/main/resources/exec下的文件放在那避免因为路径问题出错
|
||||
java_client/src/main/resources/exec/c.exe 为注入器,只不过把名字改短了,更新的话换成最新版,改个名字就行, wxhelper.dll同理
|
||||
|
||||
项目启动之后,会生成一个tcp服务端,用来接受hook信息,然后把接收的信息放在队列中,之后用一个线程去循环处理消息.
|
||||
具体实现可以看
|
||||
```com.example.wxhk.tcp.vertx```包下的三个文件
|
||||
|
||||
com.example.wxhk.tcp.vertx.VertxTcp 这个是tcp服务端,接受信息
|
||||
|
||||
com.example.wxhk.tcp.vertx.InitWeChat 微信环境初始化
|
||||
|
||||
com.example.wxhk.tcp.vertx.ArrHandle 循环消息处理
|
||||
|
||||
com.example.wxhk.server.WxSmgServer 为消息处理接口,实现其中的方法即可
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
启动项目需要去修改配置文件的微信路径
|
185
java_client/pom.xml
Normal file
185
java_client/pom.xml
Normal file
@ -0,0 +1,185 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.2.2</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>wxhk</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>wxhk</name>
|
||||
<description>wxhk</description>
|
||||
<properties>
|
||||
<java.version>21</java.version>
|
||||
<vertx-web-client.version>4.5.3</vertx-web-client.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-thymeleaf</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-web</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
<version>4.1.105.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.11.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-core</artifactId>
|
||||
<version>${vertx-web-client.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-web</artifactId>
|
||||
<version>${vertx-web-client.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-web-client</artifactId>
|
||||
<version>${vertx-web-client.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.vertx</groupId>
|
||||
<artifactId>vertx-mysql-client</artifactId>
|
||||
<version>${vertx-web-client.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.dromara.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>6.0.0.M3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.15.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
|
||||
<!-- 排除文件配置 -->
|
||||
<!-- <excludes> -->
|
||||
<!-- <exclude>*.**</exclude> -->
|
||||
<!-- <exclude>*/**.xml</exclude> -->
|
||||
<!-- </excludes> -->
|
||||
|
||||
<!-- 包含文件配置,现在只打包 com 文件夹 -->
|
||||
<includes>
|
||||
<include>
|
||||
**/com/example/wxhk/**
|
||||
</include>
|
||||
</includes>
|
||||
|
||||
<archive>
|
||||
<manifest>
|
||||
<!-- 配置加入依赖包 -->
|
||||
<addClasspath>true</addClasspath>
|
||||
<classpathPrefix>lib/</classpathPrefix>
|
||||
<useUniqueVersions>false</useUniqueVersions>
|
||||
<!-- Spring Boot 启动类(自行修改) -->
|
||||
<mainClass>com.example.wxhk.WxhkApplication</mainClass>
|
||||
</manifest>
|
||||
<manifestEntries>
|
||||
<!-- 外部资源路径加入 manifest.mf 的 Class-Path -->
|
||||
<Class-Path>resources/</Class-Path>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
<!-- jar 输出目录 -->
|
||||
<outputDirectory>${project.build.directory}/pack/</outputDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<!-- 复制依赖 -->
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-dependencies</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<!-- 依赖包 输出目录 -->
|
||||
<outputDirectory>${project.build.directory}/pack/lib</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<!-- 复制资源 -->
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
<!-- 资源文件 输出目录 -->
|
||||
<outputDirectory>${project.build.directory}/pack/resources</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,22 @@
|
||||
package com.example.wxhk;
|
||||
|
||||
import io.vertx.core.Vertx;
|
||||
import io.vertx.core.VertxOptions;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class WxhkApplication {
|
||||
public static final Vertx vertx;
|
||||
|
||||
static {
|
||||
vertx = Vertx.vertx(new VertxOptions().setWorkerPoolSize(5).setEventLoopPoolSize(5));
|
||||
}
|
||||
|
||||
//ConsoleInject.exe -i WeChat.exe -p D:\wxhelper.dll
|
||||
//ConsoleApplication.exe -I 4568 -p C:\wxhelper.dll -m 17484 -P 1888
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(WxhkApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.example.wxhk.constant;
|
||||
|
||||
/**
|
||||
* 接受到的微信消息类型
|
||||
*
|
||||
* @author wt
|
||||
* @date 2023/05/26
|
||||
*/
|
||||
public enum WxMsgType {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
私聊信息(1),
|
||||
好友请求(37),
|
||||
收到名片(42),
|
||||
表情(47),
|
||||
转账和收款(49),
|
||||
收到转账之后或者文件助手等信息(51),
|
||||
|
||||
入群(10000),
|
||||
/**
|
||||
* 扫码触发,会触发2次, 有一次有编号,一次没有,还有登陆之后也有,很多情况都会调用这个
|
||||
*/
|
||||
扫码触发(10002),
|
||||
|
||||
;
|
||||
Integer type;
|
||||
|
||||
WxMsgType(Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.example.wxhk.controller;
|
||||
|
||||
|
||||
import org.dromara.hutool.log.Log;
|
||||
|
||||
public class WxMsgController {
|
||||
|
||||
protected static final Log log = Log.get();
|
||||
|
||||
|
||||
void init() {
|
||||
|
||||
}
|
||||
}
|
11
java_client/src/main/java/com/example/wxhk/infe/Resp.java
Normal file
11
java_client/src/main/java/com/example/wxhk/infe/Resp.java
Normal file
@ -0,0 +1,11 @@
|
||||
package com.example.wxhk.infe;
|
||||
|
||||
/**
|
||||
* http 响应
|
||||
* @author wt
|
||||
* @date 2023/06/01
|
||||
*/
|
||||
public interface Resp extends java.io.Serializable{
|
||||
|
||||
|
||||
}
|
17
java_client/src/main/java/com/example/wxhk/infe/SendMsg.java
Normal file
17
java_client/src/main/java/com/example/wxhk/infe/SendMsg.java
Normal file
@ -0,0 +1,17 @@
|
||||
package com.example.wxhk.infe;
|
||||
|
||||
import io.vertx.core.json.JsonObject;
|
||||
|
||||
/**
|
||||
* http接口请求的基础接口
|
||||
*
|
||||
* @author wt
|
||||
* @date 2023/06/01
|
||||
*/
|
||||
public interface SendMsg<T> extends java.io.Serializable{
|
||||
|
||||
default JsonObject toJson(){
|
||||
return JsonObject.mapFrom(this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.example.wxhk.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 私聊
|
||||
*
|
||||
* @author wt
|
||||
* @date 2023/05/26
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class PrivateChatMsg implements Serializable {
|
||||
|
||||
String path;
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
|
||||
private String content;
|
||||
/**
|
||||
* 当是群聊的时候 为群id,否则为微信id
|
||||
*/
|
||||
private String fromGroup;
|
||||
/**
|
||||
* 微信id
|
||||
*/
|
||||
private String fromUser;
|
||||
private Integer isSendMsg;
|
||||
/**
|
||||
* 1通过手机发送
|
||||
*/
|
||||
private Integer isSendByPhone;
|
||||
private Long msgId;
|
||||
private Integer pid;
|
||||
private String sign;
|
||||
private String signature;
|
||||
private String time;
|
||||
private Integer timestamp;
|
||||
|
||||
/**
|
||||
* 对用户,如果是文件助手是filehelper
|
||||
*/
|
||||
private String toUser;
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private Integer type;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.example.wxhk.model.dto;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 支付信息
|
||||
*
|
||||
* @author wt
|
||||
* @param receiverUsername 付款人
|
||||
* @param decimal 收款金额
|
||||
* @param remark 备注
|
||||
* @param transcationid
|
||||
* @param transferid
|
||||
* @date 2023/06/06
|
||||
*/
|
||||
public record PayoutInformation(String receiverUsername, BigDecimal decimal, String remark,String transcationid,String transferid) implements java.io.Serializable {
|
||||
|
||||
public PayoutInformation(String receiverUsername, BigDecimal decimal, String remark) {
|
||||
this(receiverUsername, decimal, remark, null, null);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.example.wxhk.model.request;
|
||||
|
||||
import com.example.wxhk.infe.SendMsg;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 添加wxid 好友
|
||||
* @author wt
|
||||
* @date 2023/06/01
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AddFriends implements SendMsg<AddFriends> {
|
||||
String wxid;
|
||||
/**
|
||||
* 验证信息
|
||||
*/
|
||||
String msg;
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.example.wxhk.model.request;
|
||||
|
||||
import com.example.wxhk.infe.SendMsg;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 确认收款
|
||||
* @author wt
|
||||
* @date 2023/06/01
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ConfirmThePayment implements SendMsg<ConfirmThePayment> {
|
||||
/**
|
||||
* 转账人微信id,从hook的消息中获取
|
||||
*/
|
||||
String wxid;
|
||||
/**
|
||||
* 从hook的消息中获取对应的字段内容
|
||||
*/
|
||||
String transcationId;
|
||||
/**
|
||||
* 从hook的消息中获取对应的字段内容。
|
||||
*/
|
||||
String transferId;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.example.wxhk.model.request;
|
||||
|
||||
import com.example.wxhk.infe.SendMsg;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 通过手机或者qq查找微信
|
||||
* @author wt
|
||||
* @date 2023/06/01
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class FindWeChat implements SendMsg<FindWeChat> {
|
||||
/**
|
||||
* 通过 手机或qq查询信息
|
||||
*/
|
||||
String keyword;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.example.wxhk.model.request;
|
||||
|
||||
import com.example.wxhk.infe.SendMsg;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 转发消息
|
||||
* @author wt
|
||||
* @date 2023/06/01
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ForwardMessages implements SendMsg<ForwardMessages> {
|
||||
/**
|
||||
* 消息接收人wxid
|
||||
*/
|
||||
String wxid;
|
||||
/**
|
||||
* 消息id
|
||||
*/
|
||||
String msgid;
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.example.wxhk.model.request;
|
||||
|
||||
import com.example.wxhk.infe.SendMsg;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 获取群成员
|
||||
* @author wt
|
||||
* @date 2023/06/01
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class GetGroupMembers implements SendMsg<GetGroupMembers> {
|
||||
String chatRoomId;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.example.wxhk.model.request;
|
||||
|
||||
import com.example.wxhk.infe.SendMsg;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 获取群成员昵称
|
||||
* @author wt
|
||||
* @date 2023/06/01
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class GetsTheNicknameOfAGroupMember implements SendMsg<GetsTheNicknameOfAGroupMember> {
|
||||
/**
|
||||
* 聊天室id
|
||||
*/
|
||||
String chatRoomId;
|
||||
/**
|
||||
* 成员id
|
||||
*/
|
||||
String memberId;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.example.wxhk.model.request;
|
||||
|
||||
import com.example.wxhk.infe.SendMsg;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 增加群成员
|
||||
* @author wt
|
||||
* @date 2023/06/01
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class IncreaseGroupMembership implements SendMsg<IncreaseGroupMembership> {
|
||||
/**
|
||||
* 聊天室id
|
||||
*/
|
||||
String chatRoomId;
|
||||
/**
|
||||
* 成员id,以,分割
|
||||
*/
|
||||
String memberIds;
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.example.wxhk.model.request;
|
||||
|
||||
import com.example.wxhk.infe.SendMsg;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 开启hook
|
||||
*
|
||||
* @author wt
|
||||
* @date 2023/06/01
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class OpenHook implements SendMsg<OpenHook> {
|
||||
String port;
|
||||
String ip;
|
||||
/**
|
||||
* 0/1 :1.启用http 0.不启用http
|
||||
*/
|
||||
boolean enableHttp;
|
||||
/**
|
||||
* 超时时间,单位ms
|
||||
*/
|
||||
String timeout;
|
||||
|
||||
/**
|
||||
* http的请求地址,enableHttp=1时,不能为空
|
||||
*/
|
||||
String url;
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.example.wxhk.model.request;
|
||||
|
||||
import com.example.wxhk.infe.SendMsg;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 发送at文本
|
||||
* @author wt
|
||||
* @date 2023/06/01
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class SendAtText implements SendMsg<SendAtText> {
|
||||
/**
|
||||
* 聊天室id,群聊用
|
||||
*/
|
||||
String chatRoomId;
|
||||
/**
|
||||
* 群聊的时候用at多个用逗号隔开,@所有人则是<b>notify@all</b>
|
||||
*/
|
||||
String wxids;
|
||||
|
||||
String msg;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.example.wxhk.model.request;
|
||||
|
||||
import com.example.wxhk.infe.SendMsg;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 发送文件
|
||||
*
|
||||
* @author wt
|
||||
* @date 2023/06/01
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class SendFile implements SendMsg<SendFile> {
|
||||
String wxid;
|
||||
/**
|
||||
* 发送文件路径
|
||||
* "filePath": "C:/Users/123.txt"
|
||||
*/
|
||||
String filePath;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.example.wxhk.model.request;
|
||||
|
||||
import com.example.wxhk.infe.SendMsg;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 发送图片
|
||||
*
|
||||
* @author wt
|
||||
* @date 2023/06/01
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class SendImg implements SendMsg<SendImg> {
|
||||
String wxid;
|
||||
/**
|
||||
* 发送图片接口
|
||||
* "imagePath": "C:/Users/123.png"
|
||||
*/
|
||||
String imagePath;
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package com.example.wxhk.model.request;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* http请求参数
|
||||
*
|
||||
* @author wt
|
||||
* @date 2023/06/01
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class SendMsg {
|
||||
/**
|
||||
* wxid
|
||||
*/
|
||||
String wxid;
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
String msg;
|
||||
|
||||
/**
|
||||
* 聊天室id,群聊用
|
||||
*/
|
||||
String chatRoomId;
|
||||
/**
|
||||
* 成员id
|
||||
*/
|
||||
String memberId;
|
||||
|
||||
/**
|
||||
* 群聊的时候用at多个用逗号隔开,@所有人则是<b>notify@all</b>
|
||||
*/
|
||||
String wxids;
|
||||
/**
|
||||
* 发送图片接口
|
||||
* "imagePath": "C:/Users/123.png"
|
||||
*/
|
||||
String imagePath;
|
||||
/**
|
||||
* 发送文件路径
|
||||
* "filePath": "C:/Users/123.txt"
|
||||
*/
|
||||
String filePath;
|
||||
/**
|
||||
* 通过 手机或qq查询信息
|
||||
*/
|
||||
String keyword;
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.example.wxhk.model.request;
|
||||
|
||||
import com.example.wxhk.infe.SendMsg;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 发送文本
|
||||
*
|
||||
* @author wt
|
||||
* @date 2023/06/01
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class SendText implements SendMsg<SendText> {
|
||||
String wxid;
|
||||
String msg;
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.example.wxhk.model.request;
|
||||
|
||||
import com.example.wxhk.infe.SendMsg;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 通过好友请求
|
||||
* @author wt
|
||||
* @date 2023/06/01
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ThroughFriends implements SendMsg<ThroughFriends> {
|
||||
/**
|
||||
* 添加好友消息内容里的encryptusername
|
||||
*/
|
||||
String v3;
|
||||
/**
|
||||
* 添加好友消息内容里的ticket
|
||||
*/
|
||||
String v4;
|
||||
/**
|
||||
* 好友权限,0是无限制,1是不让他看我,2是不看他,3是1+2
|
||||
*/
|
||||
String permission;
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.example.wxhk.model.response;
|
||||
|
||||
import com.example.wxhk.infe.Resp;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 联系人列表
|
||||
* @author wt
|
||||
* @date 2023/06/01
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ContactList implements Resp {
|
||||
|
||||
/**
|
||||
* code : 1
|
||||
* data : [{"customAccount":"","delFlag":0,"type":1,"userName":"朋友推荐消息","verifyFlag":0,"wxid":"fmessage"},{"customAccount":"tencent_cloud","delFlag":0,"type":3,"userName":"腾讯云助手","verifyFlag":24,"wxid":"gh_a73e2407e0f8"},{"customAccount":"","delFlag":0,"type":1,"userName":"语音记事本","verifyFlag":0,"wxid":"medianote"},{"customAccount":"","delFlag":0,"type":1,"userName":"漂流瓶","verifyFlag":0,"wxid":"floatbottle"},{"customAccount":"jys-wt","delFlag":0,"type":8651011,"userName":"时光似水戏流年","verifyFlag":0,"wxid":"wxid_gf1fogt5a0pq22"},{"customAccount":"wxzhifu","delFlag":0,"type":3,"userName":"微信支付","verifyFlag":24,"wxid":"gh_3dfda90e39d6"},{"customAccount":"dhkzfr","delFlag":0,"type":3,"userName":"阿芙(代发)","verifyFlag":0,"wxid":"wxid_kh16lri40gzj22"},{"customAccount":"","delFlag":0,"type":3,"userName":"文件传输助手","verifyFlag":0,"wxid":"filehelper"},{"customAccount":"","delFlag":0,"type":3,"userName":"fff","verifyFlag":0,"wxid":"24964676359@chatroom"},{"customAccount":"","delFlag":0,"type":2,"userName":"最美阿芙","verifyFlag":0,"wxid":"23793178249@chatroom"},{"customAccount":"afu943344","delFlag":0,"type":2,"userName":"A-阿芙4号-LOL永劫云顶出租-代发","verifyFlag":0,"wxid":"wxid_1gxthknqbmwv22"},{"customAccount":"","delFlag":0,"type":3,"userName":"微信收款助手","verifyFlag":24,"wxid":"gh_f0a92aa7146c"},{"customAccount":"","delFlag":0,"type":0,"userName":"","verifyFlag":0,"wxid":"25984984710827869@openim"}]
|
||||
* result : OK
|
||||
*/
|
||||
|
||||
private Integer code;
|
||||
private String result;
|
||||
private List<DataBean> data;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class DataBean implements Serializable {
|
||||
/**
|
||||
* customAccount :
|
||||
* delFlag : 0
|
||||
* type : 1
|
||||
* userName : 朋友推荐消息
|
||||
* verifyFlag : 0
|
||||
* wxid : fmessage
|
||||
*/
|
||||
|
||||
private String customAccount;
|
||||
private Integer delFlag;
|
||||
private Integer type;
|
||||
private String userName;
|
||||
private Integer verifyFlag;
|
||||
private String wxid;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.example.wxhk.model.response;
|
||||
|
||||
import com.example.wxhk.infe.Resp;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class GroupMembers implements Resp {
|
||||
|
||||
/**
|
||||
* code : 1
|
||||
* data : {"admin":"wxid_gf1fogt5a0pq22","chatRoomId":"24964676359@chatroom","members":"wxid_gf1fogt5a0pq22^Gwxid_4yr8erik0uho22"}
|
||||
* result : OK
|
||||
*/
|
||||
|
||||
private Integer code;
|
||||
private DataBean data;
|
||||
private String result;
|
||||
|
||||
@Data
|
||||
public static class DataBean implements Serializable {
|
||||
/**
|
||||
* admin : wxid_gf1fogt5a0pq22
|
||||
* chatRoomId : 24964676359@chatroom
|
||||
* members : wxid_gf1fogt5a0pq22^Gwxid_4yr8erik0uho22
|
||||
*/
|
||||
|
||||
private String admin;
|
||||
private String chatRoomId;
|
||||
private String members;
|
||||
}
|
||||
}
|
256
java_client/src/main/java/com/example/wxhk/msg/WxMsgHandle.java
Normal file
256
java_client/src/main/java/com/example/wxhk/msg/WxMsgHandle.java
Normal file
@ -0,0 +1,256 @@
|
||||
package com.example.wxhk.msg;
|
||||
|
||||
import com.example.wxhk.constant.WxMsgType;
|
||||
import com.example.wxhk.model.PrivateChatMsg;
|
||||
import com.example.wxhk.model.dto.PayoutInformation;
|
||||
import com.example.wxhk.server.WxSmgServer;
|
||||
import com.example.wxhk.tcp.vertx.InitWeChat;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import org.dromara.hutool.core.util.XmlUtil;
|
||||
import org.dromara.hutool.log.Log;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
@Component
|
||||
public class WxMsgHandle {
|
||||
public static final ConcurrentHashMap<Integer, Handle> map = new ConcurrentHashMap<>(32);
|
||||
protected static final Log log = Log.get();
|
||||
/**
|
||||
* 文件传输助手
|
||||
*/
|
||||
public static final String FILEHELPER = "filehelper";
|
||||
/**
|
||||
* 收款码缓存 因为有2段信息,一段是交易id,里面可以解析出来源方,二段解析出金额
|
||||
*/
|
||||
public static ConcurrentHashMap<String, String> collection_code_caching = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
public static WxSmgServer wxSmgServer;
|
||||
/**
|
||||
* 看
|
||||
*/
|
||||
public static final ReentrantReadWriteLock LOOK = new ReentrantReadWriteLock();
|
||||
|
||||
@Autowired
|
||||
public void setWxSmgServer(WxSmgServer wxSmgServer) {
|
||||
WxMsgHandle.wxSmgServer = wxSmgServer;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
add(chatMsg -> {
|
||||
if(Objects.equals(chatMsg.getToUser(), FILEHELPER)){
|
||||
wxSmgServer.文件助手(chatMsg);
|
||||
}else{
|
||||
wxSmgServer.私聊(chatMsg);
|
||||
}
|
||||
|
||||
return null;
|
||||
}, WxMsgType.私聊信息);
|
||||
add(chatMsg -> {
|
||||
if (FILEHELPER.equals(chatMsg.getFromUser())) {
|
||||
wxSmgServer.文件助手(chatMsg);
|
||||
}
|
||||
return 1;
|
||||
}, WxMsgType.收到转账之后或者文件助手等信息);
|
||||
add(chatMsg -> {
|
||||
wxSmgServer.收到名片(chatMsg);
|
||||
return 1;
|
||||
}, WxMsgType.收到名片);
|
||||
add(chatMsg -> {
|
||||
wxSmgServer.收到好友请求(chatMsg);
|
||||
return 1;
|
||||
}, WxMsgType.好友请求);// 好友请求
|
||||
add(chatMsg -> {
|
||||
boolean f = 解析扫码支付第二段(chatMsg);
|
||||
if (f) {
|
||||
f = 解析收款信息1段(chatMsg);
|
||||
if (f) {
|
||||
解析收款信息2段(chatMsg);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}, WxMsgType.转账和收款);
|
||||
add(chatMsg -> {
|
||||
boolean f = 解析扫码支付第一段(chatMsg);
|
||||
return null;
|
||||
}, WxMsgType.扫码触发);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析扫码支付第一段,得到交易id和微信id
|
||||
*
|
||||
* @param chatMsg
|
||||
* @return boolean 返回true 则继续解析,否则解析成功,不需要解析了
|
||||
*/
|
||||
public static boolean 解析扫码支付第一段(PrivateChatMsg chatMsg) {
|
||||
try {
|
||||
Document document = XmlUtil.parseXml(chatMsg.getContent());
|
||||
Element documentElement = document.getDocumentElement();
|
||||
String localName = documentElement.getLocalName();
|
||||
if ("sysmsg".equals(localName)) {
|
||||
String type = documentElement.getAttribute("type");
|
||||
if ("paymsg".equals(type)) {
|
||||
NodeList outtradeno = documentElement.getElementsByTagName("outtradeno");
|
||||
if (outtradeno.getLength() > 0) {
|
||||
String textContent = outtradeno.item(0).getTextContent();
|
||||
String textContent1 = documentElement.getElementsByTagName("username").item(0).getTextContent();
|
||||
collection_code_caching.put(textContent, textContent1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解析扫码支付第二段
|
||||
*
|
||||
* @param chatMsg 聊天味精
|
||||
* @return boolean true 则 继续解析, false则解析成功,不需要再解析了
|
||||
*/
|
||||
public static boolean 解析扫码支付第二段(PrivateChatMsg chatMsg) {
|
||||
try {
|
||||
Document document = XmlUtil.parseXml(chatMsg.getContent());
|
||||
Element documentElement = document.getDocumentElement();
|
||||
String localName = documentElement.getLocalName();
|
||||
if ("msg".equals(localName)) {
|
||||
NodeList outtradeno = documentElement.getElementsByTagName("weapp_path");
|
||||
if (outtradeno.getLength() > 1) {
|
||||
String textContent = outtradeno.item(1).getTextContent();
|
||||
Set<Map.Entry<String, String>> entries = collection_code_caching.entrySet();
|
||||
Iterator<Map.Entry<String, String>> iterator = entries.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, String> next = iterator.next();
|
||||
if (textContent.contains(next.getKey())) {
|
||||
// 得到了交易信息
|
||||
NodeList word = documentElement.getElementsByTagName("word");
|
||||
String monery = word.item(1).getTextContent();
|
||||
String remark = word.item(3).getTextContent();
|
||||
if (monery.startsWith("¥")) {
|
||||
String substring = monery.substring(1);
|
||||
BigDecimal decimal = new BigDecimal(substring);
|
||||
log.info("扫码收款:{},付款人:{},付款备注:{}", decimal.stripTrailingZeros().toPlainString(), next.getValue(), remark);
|
||||
wxSmgServer.扫码收款(new PayoutInformation(next.getValue(),decimal,remark));
|
||||
iterator.remove();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean 解析收款信息2段(PrivateChatMsg chatMsg) {
|
||||
try {
|
||||
Document document = XmlUtil.parseXml(chatMsg.getContent());
|
||||
Element documentElement = document.getDocumentElement();
|
||||
String localName = documentElement.getLocalName();
|
||||
if ("msg".equals(localName)) {
|
||||
if (documentElement.getElementsByTagName("transcationid").getLength() > 0) {
|
||||
String remark = documentElement.getElementsByTagName("pay_memo").item(0).getTextContent();
|
||||
String monery = documentElement.getElementsByTagName("feedesc").item(0).getTextContent();
|
||||
String receiver_username = documentElement.getElementsByTagName("receiver_username").item(0).getTextContent();
|
||||
// 如果是机器人发出的,则跳过解析
|
||||
if (InitWeChat.WXID_MAP.contains(receiver_username) ) {
|
||||
return false;
|
||||
}
|
||||
if (monery.startsWith("¥")) {
|
||||
String substring = monery.substring(1);
|
||||
BigDecimal decimal = new BigDecimal(substring);
|
||||
log.info("收款:{},付款人:{},付款备注:{}", decimal.stripTrailingZeros().toPlainString(), receiver_username, remark);
|
||||
wxSmgServer.收款之后(new PayoutInformation(receiver_username, decimal, remark));
|
||||
return false;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解析收款信息1段
|
||||
* <b>会自动进行收款</b>
|
||||
*
|
||||
* @param chatMsg
|
||||
* @return boolean true则 继续解析,false则不需要解析了
|
||||
*/
|
||||
public static boolean 解析收款信息1段(PrivateChatMsg chatMsg) {
|
||||
try {
|
||||
String content = chatMsg.getContent();
|
||||
Document document = XmlUtil.parseXml(content);
|
||||
NodeList paysubtype1 = document.getElementsByTagName("paysubtype");
|
||||
if (paysubtype1.getLength() == 0) {
|
||||
return true;
|
||||
}
|
||||
Node paysubtype = paysubtype1.item(0);
|
||||
if ("1".equals(paysubtype.getTextContent().trim())) {
|
||||
// 手机发出去的
|
||||
String textContent = document.getElementsByTagName("receiver_username").item(0).getTextContent();
|
||||
if (!InitWeChat.WXID_MAP.contains(textContent)) {
|
||||
// 如果不是机器人收款,则认为不需要解析了,大概率是机器人自己发出去的
|
||||
return false;
|
||||
}
|
||||
|
||||
String remark = document.getElementsByTagName("pay_memo").item(0).getTextContent();
|
||||
String monery = document.getElementsByTagName("feedesc").item(0).getTextContent();
|
||||
String receiver_username = document.getElementsByTagName("receiver_username").item(0).getTextContent();
|
||||
if (monery.startsWith("¥")) {
|
||||
String substring = monery.substring(1);
|
||||
BigDecimal decimal = new BigDecimal(substring);
|
||||
Node transcationid = document.getDocumentElement().getElementsByTagName("transcationid").item(0);
|
||||
Node transferid = document.getDocumentElement().getElementsByTagName("transferid").item(0);
|
||||
wxSmgServer.接到收款(new PayoutInformation(chatMsg.getFromUser(), decimal, remark, transcationid.getTextContent(), transferid.getTextContent()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void exec(PrivateChatMsg chatMsg) {
|
||||
Handle handle = map.get(chatMsg.getType());
|
||||
if (handle != null) {
|
||||
handle.handle(chatMsg);
|
||||
}
|
||||
}
|
||||
|
||||
public void add(Handle handle, WxMsgType... type) {
|
||||
for (WxMsgType integer : type) {
|
||||
map.put(integer.getType(), handle);
|
||||
}
|
||||
}
|
||||
|
||||
public interface Handle {
|
||||
Object handle(PrivateChatMsg chatMsg);
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.example.wxhk.server;
|
||||
|
||||
import com.example.wxhk.model.PrivateChatMsg;
|
||||
import com.example.wxhk.model.dto.PayoutInformation;
|
||||
|
||||
/**
|
||||
* 微信消息处理提取
|
||||
* @author wt
|
||||
* @date 2023/06/06
|
||||
*/
|
||||
public interface WxSmgServer {
|
||||
/**
|
||||
* 接到收款
|
||||
*
|
||||
* @param payoutInformation 支付信息
|
||||
*/
|
||||
void 接到收款(PayoutInformation payoutInformation);
|
||||
|
||||
void 收款之后(PayoutInformation pay);
|
||||
|
||||
void 私聊(PrivateChatMsg chatMsg);
|
||||
|
||||
void 文件助手(PrivateChatMsg chatMsg);
|
||||
|
||||
void 收到名片(PrivateChatMsg chatMsg);
|
||||
|
||||
void 收到好友请求(PrivateChatMsg chatMsg);
|
||||
|
||||
void 扫码收款(PayoutInformation payoutInformation);
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package com.example.wxhk.server.impl;
|
||||
|
||||
import com.example.wxhk.model.PrivateChatMsg;
|
||||
import com.example.wxhk.model.dto.PayoutInformation;
|
||||
import com.example.wxhk.model.request.ConfirmThePayment;
|
||||
import com.example.wxhk.util.HttpSendUtil;
|
||||
import org.dromara.hutool.core.text.StrUtil;
|
||||
import org.dromara.hutool.core.util.XmlUtil;
|
||||
import org.dromara.hutool.log.Log;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
public class WxSmgServerImpl implements com.example.wxhk.server.WxSmgServer {
|
||||
|
||||
protected static final Log log=Log.get();
|
||||
|
||||
public static final String FILEHELPER = "filehelper";
|
||||
@Override
|
||||
public void 接到收款(PayoutInformation payoutInformation) {
|
||||
HttpSendUtil.确认收款(new ConfirmThePayment().setWxid(payoutInformation.receiverUsername()).setTranscationId(payoutInformation.transcationid()).setTransferId(payoutInformation.transferid()));
|
||||
}
|
||||
@Override
|
||||
public void 收款之后(PayoutInformation pay) {
|
||||
HttpSendUtil.发送文本(pay.receiverUsername(), StrUtil.format("收到款项:{},备注:{}", pay.decimal().stripTrailingZeros().toPlainString(), pay.remark()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void 私聊(PrivateChatMsg chatMsg) {
|
||||
if (Objects.equals(chatMsg.getIsSendMsg(), 1) && Objects.equals(chatMsg.getIsSendByPhone(), 1)) {
|
||||
log.info("手机端对:{}发出:{}", chatMsg.getFromUser(), chatMsg.getContent());
|
||||
}else{
|
||||
log.info("收到私聊{}",chatMsg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void 文件助手(PrivateChatMsg chatMsg) {
|
||||
log.info("文件助手:{}",chatMsg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void 收到名片(PrivateChatMsg chatMsg) {
|
||||
if (FILEHELPER.equals(chatMsg.getFromUser())) {
|
||||
Document document = XmlUtil.parseXml(chatMsg.getContent());
|
||||
Element documentElement = document.getDocumentElement();
|
||||
String username = documentElement.getAttribute("username");
|
||||
if (StrUtil.isNotBlank(username)) {
|
||||
HttpSendUtil.发送文本(username);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void 收到好友请求(PrivateChatMsg chatMsg) {
|
||||
HttpSendUtil.通过好友请求(chatMsg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void 扫码收款(PayoutInformation payoutInformation) {
|
||||
HttpSendUtil.发送文本(payoutInformation.receiverUsername(), StrUtil.format("扫码收款:{},备注:{}", payoutInformation.decimal().stripTrailingZeros().toPlainString(), payoutInformation.remark()));
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package com.example.wxhk.tcp.vertx;
|
||||
|
||||
import com.example.wxhk.model.PrivateChatMsg;
|
||||
import com.example.wxhk.msg.WxMsgHandle;
|
||||
import com.example.wxhk.util.HttpSendUtil;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import org.dromara.hutool.core.thread.NamedThreadFactory;
|
||||
import org.dromara.hutool.log.Log;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 消息处理
|
||||
*
|
||||
* @author wt
|
||||
* @date 2023/05/31
|
||||
*/
|
||||
@Component
|
||||
public class ArrHandle {
|
||||
|
||||
/**
|
||||
* 线程处理消息队列,但是必须保证核心数大于2,其中必定要有一个线程可以单独处理交易队列信息
|
||||
*/
|
||||
public static final ThreadPoolExecutor sub = new ThreadPoolExecutor(4, 10, 30, TimeUnit.MINUTES, new LinkedBlockingQueue<>(), new NamedThreadFactory("sub", false));
|
||||
public static final ThreadLocal<PrivateChatMsg> chatMsgThreadLocal = new InheritableThreadLocal<>();
|
||||
protected static final Log log = Log.get();
|
||||
|
||||
/**
|
||||
* 得到当前正在处理的消息
|
||||
*
|
||||
* @return {@link PrivateChatMsg}
|
||||
*/
|
||||
public static PrivateChatMsg getPriMsg() {
|
||||
return chatMsgThreadLocal.get();
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void exec() {
|
||||
for (int i = 0; i < sub.getCorePoolSize()-1; i++) {
|
||||
sub.submit(() -> {
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
try {
|
||||
JsonObject take = VertxTcp.LINKED_BLOCKING_QUEUE.take();
|
||||
log.info("{}", take.encode());
|
||||
PrivateChatMsg privateChatMsg = take.mapTo(PrivateChatMsg.class);
|
||||
chatMsgThreadLocal.set(privateChatMsg);
|
||||
if ("weixin".equals(privateChatMsg.getFromUser())) {
|
||||
String s = HttpSendUtil.获取当前登陆微信id();
|
||||
InitWeChat.WXID_MAP.add(s);
|
||||
continue;
|
||||
}
|
||||
WxMsgHandle.exec(privateChatMsg);
|
||||
} catch (Exception e) {
|
||||
log.error(e);
|
||||
}finally {
|
||||
chatMsgThreadLocal.remove();
|
||||
}
|
||||
}
|
||||
log.error("退出线程了");
|
||||
});
|
||||
}
|
||||
sub.submit(() -> {
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
try {
|
||||
JsonObject take = VertxTcp.LINKED_BLOCKING_QUEUE_MON.take();
|
||||
log.info("{}", take.encode());
|
||||
PrivateChatMsg privateChatMsg = take.mapTo(PrivateChatMsg.class);
|
||||
chatMsgThreadLocal.set(privateChatMsg);
|
||||
if ("weixin".equals(privateChatMsg.getFromUser())) {
|
||||
String s = HttpSendUtil.获取当前登陆微信id();
|
||||
InitWeChat.WXID_MAP.add(s);
|
||||
continue;
|
||||
}
|
||||
WxMsgHandle.exec(privateChatMsg);
|
||||
} catch (Exception e) {
|
||||
log.error(e);
|
||||
}finally {
|
||||
chatMsgThreadLocal.remove();
|
||||
}
|
||||
}
|
||||
log.error("退出线程了");
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,158 @@
|
||||
package com.example.wxhk.tcp.vertx;
|
||||
|
||||
import com.example.wxhk.util.HttpAsyncUtil;
|
||||
import com.example.wxhk.util.HttpSyncUtil;
|
||||
import io.vertx.core.impl.ConcurrentHashSet;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import org.dromara.hutool.core.io.file.FileUtil;
|
||||
import org.dromara.hutool.core.net.NetUtil;
|
||||
import org.dromara.hutool.core.text.StrUtil;
|
||||
import org.dromara.hutool.core.thread.ThreadUtil;
|
||||
import org.dromara.hutool.log.Log;
|
||||
import org.dromara.hutool.setting.Setting;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 微信注入环境初始化和相关方法
|
||||
*
|
||||
* @author wt
|
||||
* @date 2023/05/16
|
||||
*/
|
||||
@Order(-1)
|
||||
@Component
|
||||
public class InitWeChat implements CommandLineRunner {
|
||||
|
||||
public final static Log log = Log.get();
|
||||
public static final ConcurrentHashSet<String> WXID_MAP = new ConcurrentHashSet<>();
|
||||
public static String wxPath;
|
||||
public static Integer wxPort;
|
||||
public static Integer vertxPort;
|
||||
/**
|
||||
* wxhelper.dll 所在路径
|
||||
*/
|
||||
public static File DLL_PATH;
|
||||
|
||||
public static void 注入dll(String wxPid) throws IOException {
|
||||
String format = StrUtil.format("cmd /C c.exe -I {} -p {}\\wxhelper.dll -m {}", wxPid, DLL_PATH.getAbsolutePath(), wxPid);
|
||||
Process exec = Runtime.getRuntime().exec(format, null, DLL_PATH);
|
||||
log.info("注入结果:{}", new String(exec.getInputStream().readAllBytes(), "gbk"));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static File 环境初始化() {
|
||||
File target = new File(new File("").getAbsolutePath().split("\\\\")[0] + "\\exec\\");
|
||||
try {
|
||||
File wxPathFile = new File(wxPath);
|
||||
File config = new File(wxPathFile.getParentFile(), "config.ini");
|
||||
Setting setting = new Setting(config.getAbsolutePath());
|
||||
setting.getGroupedMap().put("config", "port", String.valueOf(wxPort));
|
||||
setting.store();
|
||||
ClassPathResource classPathResource = new ClassPathResource("exec");
|
||||
File file = classPathResource.getFile();
|
||||
target.mkdir();
|
||||
for (File listFile : file.listFiles()) {
|
||||
FileUtil.copy(listFile, target, true);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e, "环境初始化失败,请检查");
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回最后一个微信的pid
|
||||
*
|
||||
* @return {@link String}
|
||||
* @throws IOException ioexception
|
||||
*/
|
||||
public static String createWx() throws IOException {
|
||||
Runtime.getRuntime().exec("cmd /C \"" + wxPath + "\"");
|
||||
return getWxPid();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getWxPid() throws IOException {
|
||||
String line = null;
|
||||
try {
|
||||
Process exec = Runtime.getRuntime().exec("cmd /C tasklist /FI \"IMAGENAME eq WeChat.exe\" ");
|
||||
byte[] bytes = exec.getInputStream().readAllBytes();
|
||||
line = new String(bytes, "gbk");
|
||||
String[] split = line.split("\n");
|
||||
if (!line.contains("WeChat.exe")) {
|
||||
return createWx();
|
||||
}
|
||||
String[] split1 = split[split.length - 1].replaceAll("\\s{2,}", " ").split(" ");
|
||||
return split1[1];
|
||||
} catch (IOException e) {
|
||||
log.error("获取端口错误:{}", line);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public static Integer getWxPort() {
|
||||
return wxPort;
|
||||
}
|
||||
|
||||
@Value("${wx.port}")
|
||||
public void setWxPort(Integer wxPort) {
|
||||
InitWeChat.wxPort = wxPort;
|
||||
}
|
||||
|
||||
public static String getWxPath() {
|
||||
return wxPath;
|
||||
}
|
||||
|
||||
@Value("${wx.path}")
|
||||
public void setWxPath(String wxPath) {
|
||||
InitWeChat.wxPath = wxPath;
|
||||
}
|
||||
|
||||
public static Integer getVertxPort() {
|
||||
return vertxPort;
|
||||
}
|
||||
|
||||
@Value("${vertx.port}")
|
||||
public void setVertxPort(Integer vertxPort) {
|
||||
InitWeChat.vertxPort = vertxPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
//tasklist /FI "IMAGENAME eq WeChat.exe" /m
|
||||
boolean usableLocalPort = NetUtil.isUsableLocalPort(wxPort);
|
||||
if (usableLocalPort) {
|
||||
DLL_PATH = 环境初始化();
|
||||
String wxPid = getWxPid();
|
||||
注入dll(wxPid);
|
||||
}
|
||||
ThreadUtil.execute(() -> {
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
JsonObject exec = HttpSyncUtil.exec(HttpAsyncUtil.Type.检查微信登陆, new JsonObject());
|
||||
if (exec.getInteger("code").equals(1)) {
|
||||
JsonObject dl = HttpSyncUtil.exec(HttpAsyncUtil.Type.获取登录信息, new JsonObject());
|
||||
JsonObject jsonObject = dl.getJsonObject("data");
|
||||
String wx = jsonObject.getString("wxid");
|
||||
WXID_MAP.add(wx);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("检测到微信登陆:{}", wx);
|
||||
}
|
||||
break;
|
||||
}
|
||||
ThreadUtil.safeSleep(500);
|
||||
}
|
||||
|
||||
});
|
||||
// FIXME: 2023/6/2 程序结束后关闭hook会偶尔出现微信闪退情况,暂时禁用
|
||||
// Runtime.getRuntime().addShutdownHook(new Thread(HttpSendUtil::关闭hook));
|
||||
//netstat -aon|findstr "端口号"
|
||||
// c.exe -I 4568 -p D:\exec\wxhelper.dll -m 4568
|
||||
}
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
package com.example.wxhk.tcp.vertx;
|
||||
|
||||
import com.example.wxhk.WxhkApplication;
|
||||
import com.example.wxhk.constant.WxMsgType;
|
||||
import com.example.wxhk.model.request.OpenHook;
|
||||
import com.example.wxhk.util.HttpSendUtil;
|
||||
import io.vertx.core.AbstractVerticle;
|
||||
import io.vertx.core.DeploymentOptions;
|
||||
import io.vertx.core.Future;
|
||||
import io.vertx.core.Promise;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.core.net.NetServer;
|
||||
import io.vertx.core.net.NetServerOptions;
|
||||
import io.vertx.core.parsetools.JsonParser;
|
||||
import org.dromara.hutool.log.Log;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
/**
|
||||
* 接受微信hook信息
|
||||
*
|
||||
* @author wt
|
||||
* @date 2023/05/26
|
||||
*/
|
||||
@Component
|
||||
@Order()
|
||||
public class VertxTcp extends AbstractVerticle implements CommandLineRunner {
|
||||
public final static LinkedBlockingQueue<JsonObject> LINKED_BLOCKING_QUEUE = new LinkedBlockingQueue<>();
|
||||
/**
|
||||
* 这个只保留交易相关的类型
|
||||
*/
|
||||
public final static LinkedBlockingQueue<JsonObject> LINKED_BLOCKING_QUEUE_MON = new LinkedBlockingQueue<>();
|
||||
protected static final Log log = Log.get();
|
||||
NetServer netServer;
|
||||
|
||||
@Override
|
||||
public void start(Promise<Void> startPromise) throws Exception {
|
||||
netServer = vertx.createNetServer(new NetServerOptions()
|
||||
.setPort(InitWeChat.getVertxPort())
|
||||
.setIdleTimeout(0)
|
||||
.setLogActivity(false)
|
||||
);
|
||||
netServer.connectHandler(socket -> {
|
||||
JsonParser parser = JsonParser.newParser();
|
||||
parser.objectValueMode();
|
||||
parser.handler(event -> {
|
||||
switch (event.type()) {
|
||||
case START_OBJECT -> {
|
||||
}
|
||||
case END_OBJECT -> {
|
||||
}
|
||||
case START_ARRAY -> {
|
||||
}
|
||||
case END_ARRAY -> {
|
||||
}
|
||||
case VALUE -> {
|
||||
JsonObject entries = event.objectValue();
|
||||
|
||||
if(Objects.equals(entries.getInteger("type"), WxMsgType.扫码触发.getType()) ||
|
||||
Objects.equals(entries.getInteger("type"), WxMsgType.转账和收款.getType())){
|
||||
LINKED_BLOCKING_QUEUE_MON.add(entries);
|
||||
}else{
|
||||
LINKED_BLOCKING_QUEUE.add(entries);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
socket.handler(parser);
|
||||
});
|
||||
|
||||
Future<NetServer> listen = netServer.listen();
|
||||
listen.onComplete(event -> {
|
||||
boolean succeeded = event.succeeded();
|
||||
if (succeeded) {
|
||||
HttpSendUtil.开启hook(new OpenHook().setPort(InitWeChat.getVertxPort().toString()).setIp("127.0.0.1")
|
||||
.setEnableHttp(false)
|
||||
.setTimeout("5000"));
|
||||
// HttpAsyncUtil.exec(HttpAsyncUtil.Type.开启hook, new JsonObject().put("port", InitWeChat.getVertxPort().toString()).put("ip", "127.0.0.1"));
|
||||
startPromise.complete();
|
||||
} else {
|
||||
startPromise.fail(event.cause());
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
WxhkApplication.vertx.deployVerticle(this, new DeploymentOptions().setWorkerPoolSize(6));
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package com.example.wxhk.util;
|
||||
|
||||
import com.example.wxhk.WxhkApplication;
|
||||
import com.example.wxhk.tcp.vertx.InitWeChat;
|
||||
import io.vertx.core.AsyncResult;
|
||||
import io.vertx.core.Future;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.buffer.Buffer;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.client.HttpResponse;
|
||||
import io.vertx.ext.web.client.WebClient;
|
||||
import io.vertx.ext.web.client.WebClientOptions;
|
||||
import org.dromara.hutool.log.Log;
|
||||
|
||||
/**
|
||||
* http异步请求
|
||||
*
|
||||
* @author wt
|
||||
* @date 2023/05/25
|
||||
*/
|
||||
public class HttpAsyncUtil {
|
||||
public static final WebClient client = WebClient.create(WxhkApplication.vertx, new WebClientOptions().setDefaultHost("localhost").setDefaultPort(InitWeChat.wxPort)
|
||||
.setConnectTimeout(10000).setMaxPoolSize(10).setPoolEventLoopSize(10));
|
||||
protected static final Log log = Log.get();
|
||||
|
||||
public static Future<HttpResponse<Buffer>> exec(Type type, JsonObject object) {
|
||||
return client.post(InitWeChat.wxPort, "localhost", "/api/" + type.getType())
|
||||
.sendJsonObject(object)
|
||||
.onSuccess(event ->
|
||||
{
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("type:{},{}", type.getType(), event.bodyAsJsonObject());
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public static Future<HttpResponse<Buffer>> exec(Type type, JsonObject object, Handler<AsyncResult<HttpResponse<Buffer>>> handler) {
|
||||
return client.post(InitWeChat.wxPort, "localhost", "/api/" + type.getType())
|
||||
.sendJsonObject(object)
|
||||
.onComplete(handler)
|
||||
;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
检查微信登陆("checkLogin"),
|
||||
获取登录信息("userInfo"),
|
||||
发送文本("sendTextMsg"),
|
||||
转发消息("forwardMsg"),
|
||||
发送at文本("sendAtText"),
|
||||
发送图片("5"),
|
||||
发送文件("sendFileMsg"),
|
||||
开启hook("hookSyncMsg"),
|
||||
关闭hook("unhookSyncMsg"),
|
||||
添加好友("20"),
|
||||
通过好友申请("23"),
|
||||
获取群成员("getMemberFromChatRoom"),
|
||||
获取群成员基础信息("getContactProfile"),
|
||||
获取群详情("getChatRoomDetailInfo"),
|
||||
添加群成员("addMemberToChatRoom"),
|
||||
修改群昵称("modifyNickname"),
|
||||
删除群成员("delMemberFromChatRoom"),
|
||||
置顶群消息("topMsg"),
|
||||
取消置顶群消息("removeTopMsg"),
|
||||
邀请入群("InviteMemberToChatRoom"),
|
||||
确认收款("45"),
|
||||
联系人列表("getContactList"),
|
||||
查询微信信息("55"),
|
||||
下载附件("downloadAttach"),
|
||||
解码("decodeImage"),
|
||||
|
||||
|
||||
;
|
||||
String type;
|
||||
|
||||
Type(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,151 @@
|
||||
package com.example.wxhk.util;
|
||||
|
||||
import com.example.wxhk.model.PrivateChatMsg;
|
||||
import com.example.wxhk.model.request.*;
|
||||
import com.example.wxhk.model.response.ContactList;
|
||||
import com.example.wxhk.model.response.GroupMembers;
|
||||
import com.example.wxhk.tcp.vertx.ArrHandle;
|
||||
import com.example.wxhk.tcp.vertx.InitWeChat;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import org.dromara.hutool.core.util.XmlUtil;
|
||||
import org.dromara.hutool.log.Log;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* 常见方法
|
||||
*
|
||||
* @author wt
|
||||
* @date 2023/05/29
|
||||
*/
|
||||
public class HttpSendUtil {
|
||||
|
||||
protected static final Log log = Log.get();
|
||||
|
||||
public static JsonObject 通过好友请求(PrivateChatMsg msg) {
|
||||
Document document = XmlUtil.parseXml(msg.getContent());
|
||||
String encryptusername = document.getDocumentElement().getAttribute("encryptusername");
|
||||
String ticket = document.getDocumentElement().getAttribute("ticket");
|
||||
return HttpSyncUtil.exec(HttpAsyncUtil.Type.通过好友申请, new JsonObject().put("v3", encryptusername).put("v4", ticket).put("permission", "0"));
|
||||
}
|
||||
|
||||
public static JsonObject 确认收款(PrivateChatMsg msg) {
|
||||
try {
|
||||
String content = msg.getContent();
|
||||
Document document = XmlUtil.parseXml(content);
|
||||
Node paysubtype = document.getElementsByTagName("paysubtype").item(0);
|
||||
if ("1".equals(paysubtype.getTextContent().trim())) {
|
||||
// 手机发出去的
|
||||
String textContent = document.getElementsByTagName("receiver_username").item(0).getTextContent();
|
||||
if (!InitWeChat.WXID_MAP.contains(textContent)) {
|
||||
return new JsonObject().put("spick", true);
|
||||
}
|
||||
Node transcationid = document.getDocumentElement().getElementsByTagName("transcationid").item(0);
|
||||
Node transferid = document.getDocumentElement().getElementsByTagName("transferid").item(0);
|
||||
return HttpSyncUtil.exec(HttpAsyncUtil.Type.确认收款, new JsonObject().put("wxid", msg.getFromUser())
|
||||
.put("transcationId", transcationid.getTextContent())
|
||||
.put("transferId", transferid.getTextContent()));
|
||||
|
||||
}
|
||||
// 如果是确认接受收款,则跳过
|
||||
return new JsonObject();
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static JsonObject 发送文本(String wxid, String msg) {
|
||||
return HttpSyncUtil.exec(HttpAsyncUtil.Type.发送文本, JsonObject.mapFrom(new SendMsg().setMsg(msg).setWxid(wxid)));
|
||||
}
|
||||
|
||||
public static JsonObject 发送文本(String msg) {
|
||||
return 发送文本(ArrHandle.getPriMsg().getFromUser(), msg);
|
||||
}
|
||||
|
||||
public static JsonObject 发送at文本(String chatRoomId, String wxids, String msg) {
|
||||
return HttpSyncUtil.exec(HttpAsyncUtil.Type.发送at文本, JsonObject.mapFrom(new SendMsg().setMsg(msg).setWxids(wxids).setChatRoomId(chatRoomId)));
|
||||
}
|
||||
|
||||
public static JsonObject 发送at文本(String wxids, String msg) {
|
||||
return 发送at文本(ArrHandle.getPriMsg().getFromGroup(), wxids, msg);
|
||||
}
|
||||
|
||||
public static JsonObject 发送图片(String wxid, String msg) {
|
||||
return HttpSyncUtil.exec(HttpAsyncUtil.Type.发送图片, JsonObject.mapFrom(new SendMsg().setImagePath(msg).setWxid(wxid)));
|
||||
}
|
||||
|
||||
public static JsonObject 发送图片(String msg) {
|
||||
return 发送图片(ArrHandle.getPriMsg().getFromUser(), msg);
|
||||
}
|
||||
|
||||
public static JsonObject 发送文件(String wxid, String msg) {
|
||||
return HttpSyncUtil.exec(HttpAsyncUtil.Type.发送文件, JsonObject.mapFrom(new SendMsg().setFilePath(msg).setWxid(wxid)));
|
||||
}
|
||||
|
||||
public static JsonObject 发送文件(String msg) {
|
||||
return 发送文件(ArrHandle.getPriMsg().getFromUser(), msg);
|
||||
}
|
||||
|
||||
public static JsonObject 添加好友(AddFriends p) {
|
||||
return HttpSyncUtil.exec(HttpAsyncUtil.Type.添加好友, p.toJson());
|
||||
}
|
||||
|
||||
|
||||
public static String 获取当前登陆微信id() {
|
||||
JsonObject exec = HttpSyncUtil.exec(HttpAsyncUtil.Type.获取登录信息, new JsonObject());
|
||||
return exec.getJsonObject("data").getString("wxid");
|
||||
}
|
||||
|
||||
public static ContactList 联系人列表(){
|
||||
JsonObject exec = HttpSyncUtil.exec(HttpAsyncUtil.Type.联系人列表, new JsonObject());
|
||||
return exec.mapTo(ContactList.class);
|
||||
}
|
||||
public static JsonObject 开启hook(OpenHook hook){
|
||||
JsonObject exec = HttpSyncUtil.exec(HttpAsyncUtil.Type.开启hook,hook.toJson());
|
||||
return exec;
|
||||
}
|
||||
public static JsonObject 关闭hook(){
|
||||
JsonObject exec = HttpSyncUtil.exec(HttpAsyncUtil.Type.关闭hook,new JsonObject());
|
||||
return exec;
|
||||
}
|
||||
|
||||
public static GroupMembers 获取群成员(GetGroupMembers p){
|
||||
return HttpSyncUtil.exec(HttpAsyncUtil.Type.获取群成员, p.toJson()).mapTo(GroupMembers.class);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static JsonObject 确认收款(ConfirmThePayment payment){
|
||||
return HttpSyncUtil.exec(HttpAsyncUtil.Type.确认收款, payment.toJson());
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public static com.example.wxhk.infe.SendMsg of(HttpAsyncUtil.Type type) {
|
||||
switch (type) {
|
||||
|
||||
case 检查微信登陆 -> {
|
||||
|
||||
}
|
||||
case 获取登录信息 -> {
|
||||
}
|
||||
case 发送文本 -> {
|
||||
return new SendText();
|
||||
}
|
||||
case 发送at文本 -> {
|
||||
return new SendAtText();
|
||||
}
|
||||
case 发送图片 -> {
|
||||
return new SendImg();
|
||||
}
|
||||
case 发送文件 -> {
|
||||
return new SendFile();
|
||||
}
|
||||
|
||||
}
|
||||
return new SendText();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.example.wxhk.util;
|
||||
|
||||
import com.example.wxhk.tcp.vertx.InitWeChat;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import org.dromara.hutool.http.client.ClientConfig;
|
||||
import org.dromara.hutool.http.client.Request;
|
||||
import org.dromara.hutool.http.client.engine.ClientEngine;
|
||||
import org.dromara.hutool.http.client.engine.ClientEngineFactory;
|
||||
import org.dromara.hutool.http.meta.Method;
|
||||
import org.dromara.hutool.log.Log;
|
||||
|
||||
/**
|
||||
* http同步请求
|
||||
*
|
||||
* @author wt
|
||||
* @date 2023/05/25
|
||||
*/
|
||||
public class HttpSyncUtil {
|
||||
protected static final Log log = Log.get();
|
||||
static final ClientEngine engine;
|
||||
|
||||
static {
|
||||
ClientConfig clientConfig = ClientConfig.of()
|
||||
.setTimeout(30 * 1000);
|
||||
engine = ClientEngineFactory.createEngine(clientConfig);
|
||||
|
||||
}
|
||||
|
||||
public static JsonObject exec(HttpAsyncUtil.Type type, JsonObject obj) {
|
||||
String post = engine.send(Request.of("http://localhost:" + InitWeChat.wxPort + "/api/" + type.getType()).method(Method.POST).body(obj.encode())).bodyStr();
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("type:{},{}", type.getType(), post);
|
||||
}
|
||||
return new JsonObject(post);
|
||||
}
|
||||
}
|
4
java_client/src/main/resources/application.properties
Normal file
4
java_client/src/main/resources/application.properties
Normal file
@ -0,0 +1,4 @@
|
||||
wx.path=D:\\Program Files (x86)\\Tencent\\WeChat\\WeChat.exe
|
||||
wx.port=19088
|
||||
spring.profiles.active=local
|
||||
vertx.port=8080
|
BIN
java_client/src/main/resources/exec/c.exe
Normal file
BIN
java_client/src/main/resources/exec/c.exe
Normal file
Binary file not shown.
BIN
java_client/src/main/resources/exec/wxhelper.dll
Normal file
BIN
java_client/src/main/resources/exec/wxhelper.dll
Normal file
Binary file not shown.
171
java_client/src/main/resources/logback-spring.xml
Normal file
171
java_client/src/main/resources/logback-spring.xml
Normal file
@ -0,0 +1,171 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
|
||||
<!--日志格式应用spring boot默认的格式,也可以自己更改-->
|
||||
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
|
||||
|
||||
<!--定义日志存放的位置,默认存放在项目启动的相对路径的目录-->
|
||||
<springProperty scope="context" name="LOG_PATH" source="log.path" defaultValue="log"/>
|
||||
<property name="withLineNumber_debug"
|
||||
value="%clr(%d{HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) [%t] %replace(%caller{1}){'\t|Caller.{1}0|\r\n', ''} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
|
||||
|
||||
<property name="file_pattern"
|
||||
value="%d{MM-dd HH:mm:ss.SSS} %-5level [${PID:- } %thread] %logger{50}#%method,%line : %msg%n"/>
|
||||
|
||||
<!-- ****************************************************************************************** -->
|
||||
<!-- ****************************** 本地开发只在控制台打印日志 ************************************ -->
|
||||
<!-- ****************************************************************************************** -->
|
||||
<springProfile name="local">
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${withLineNumber_debug}</pattern>
|
||||
<charset>utf-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 日志记录器,日期滚动记录 -->
|
||||
<appender name="FILE_ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
|
||||
<!-- 正在记录的日志文件的路径及文件名 -->
|
||||
<file>log_error.log</file>
|
||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${LOG_PATH}/error/%d{yyyy-MM}/log_error-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<maxHistory>100</maxHistory>
|
||||
</rollingPolicy>
|
||||
|
||||
<!-- 追加方式记录日志 -->
|
||||
<append>true</append>
|
||||
|
||||
<!-- 日志文件的格式 -->
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<pattern>${file_pattern}</pattern>
|
||||
<charset>utf-8</charset>
|
||||
</encoder>
|
||||
|
||||
<!-- 此日志文件只记录error级别的 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>error</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
|
||||
<!--默认所有的包以info-->
|
||||
<root level="info">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
|
||||
<!--各个服务的包在本地执行的时候,打开debug模式-->
|
||||
<logger name="com.example.wxhk" level="debug" additivity="false">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
<appender-ref ref="FILE_ERROR"/>
|
||||
</logger>
|
||||
<logger name="org.springframework" level="info" additivity="false">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</logger>
|
||||
</springProfile>
|
||||
|
||||
<!-- ********************************************************************************************** -->
|
||||
<!-- **** 放到服务器上不管在什么环境都只在文件记录日志,控制台(catalina.out)打印logback捕获不到的日志 **** -->
|
||||
<!-- ********************************************************************************************** -->
|
||||
<springProfile name="!local">
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||
<charset>utf-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 日志记录器,日期滚动记录 -->
|
||||
<appender name="FILE_ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
|
||||
<!-- 正在记录的日志文件的路径及文件名 -->
|
||||
<file>${LOG_PATH}/log_error.log</file>
|
||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${LOG_PATH}/error/%d{yyyy-MM}/log_error-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<maxHistory>100</maxHistory>
|
||||
</rollingPolicy>
|
||||
|
||||
<!-- 追加方式记录日志 -->
|
||||
<append>true</append>
|
||||
|
||||
<!-- 日志文件的格式 -->
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<pattern>${file_pattern}</pattern>
|
||||
<charset>utf-8</charset>
|
||||
</encoder>
|
||||
|
||||
<!-- 此日志文件只记录error级别的 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>error</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
|
||||
<!-- 日志记录器,日期滚动记录 -->
|
||||
<appender name="FILE_ALL" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!-- 正在记录的日志文件的路径及文件名 -->
|
||||
<file>${LOG_PATH}/log_total.log</file>
|
||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${LOG_PATH}/total/%d{yyyy-MM}/log_total-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<maxHistory>100</maxHistory>
|
||||
</rollingPolicy>
|
||||
<!-- 追加方式记录日志 -->
|
||||
<append>true</append>
|
||||
<!-- 日志文件的格式 -->
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<pattern>${file_pattern}</pattern>
|
||||
<charset>utf-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
<!-- 业务错误 -->
|
||||
<appender name="business_log" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!-- 正在记录的日志文件的路径及文件名 -->
|
||||
<file>${LOG_PATH}/log_business.log</file>
|
||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>${LOG_PATH}/business/%d{yyyy-MM}/log_business-%d{yyyy-MM-dd}.%i.log.gz
|
||||
</fileNamePattern>
|
||||
<maxFileSize>50MB</maxFileSize>
|
||||
<maxHistory>100</maxHistory>
|
||||
</rollingPolicy>
|
||||
<!-- 追加方式记录日志 -->
|
||||
<append>true</append>
|
||||
<!-- 日志文件的格式 -->
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<pattern>${file_pattern}</pattern>
|
||||
<charset>utf-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<logger name="com.example.wxhk" level="info" additivity="false">
|
||||
<appender-ref ref="business_log"/>
|
||||
<appender-ref ref="FILE_ERROR"/>
|
||||
</logger>
|
||||
<logger name="p6spy" level="info" additivity="false">
|
||||
<appender-ref ref="business_log"/>
|
||||
</logger>
|
||||
<logger name="org.springframework" level="warn"/>
|
||||
|
||||
<!--记录到文件时,记录两类一类是error日志,一个是所有日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="FILE_ERROR"/>
|
||||
<appender-ref ref="FILE_ALL"/>
|
||||
</root>
|
||||
|
||||
|
||||
</springProfile>
|
||||
|
||||
</configuration>
|
||||
|
||||
|
10
java_client/src/main/resources/spy.properties
Normal file
10
java_client/src/main/resources/spy.properties
Normal file
@ -0,0 +1,10 @@
|
||||
logMessageFormat=com.p6spy.engine.spy.appender.CustomLineFormat
|
||||
# 使用Slf4J记录sql
|
||||
appender=com.p6spy.engine.spy.appender.Slf4JLogger
|
||||
# 是否开启慢SQL记录
|
||||
outagedetection=true
|
||||
# 慢SQL记录标准,单位秒
|
||||
outagedetectioninterval=2
|
||||
#日期格式
|
||||
dateformat=HH:mm:ss
|
||||
customLogMessageFormat=%(executionTime)|%(category)|connection%(connectionId)|%(sqlSingleLine)
|
@ -0,0 +1,13 @@
|
||||
package com.example.wxhk;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class WxhkApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.example.wxhk.tcp;
|
||||
|
||||
import com.example.wxhk.util.HttpAsyncUtil;
|
||||
import io.vertx.core.Future;
|
||||
import io.vertx.core.buffer.Buffer;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.client.HttpResponse;
|
||||
import org.dromara.hutool.core.lang.Console;
|
||||
import org.dromara.hutool.core.thread.ThreadUtil;
|
||||
import org.dromara.hutool.log.Log;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class HttpAsyncUtilTest {
|
||||
|
||||
protected static final Log log = Log.get();
|
||||
|
||||
|
||||
@Test
|
||||
void exec() {
|
||||
Future<HttpResponse<Buffer>> exec = HttpAsyncUtil.exec(HttpAsyncUtil.Type.联系人列表, new JsonObject());
|
||||
exec.onSuccess(event -> {
|
||||
Console.log(event.bodyAsJsonObject());
|
||||
});
|
||||
}
|
||||
@Test
|
||||
void exec1() {
|
||||
|
||||
for(int i=0;i<10000;i++){
|
||||
int finalI = i;
|
||||
HttpAsyncUtil.exec(HttpAsyncUtil.Type.获取登录信息, new JsonObject(), event -> {
|
||||
if (event.succeeded()) {
|
||||
log.info("i:{},{}", finalI,event.result().bodyAsJsonObject());
|
||||
}else{
|
||||
event.cause().printStackTrace();
|
||||
}
|
||||
});
|
||||
log.info("发出请求:{}",i);
|
||||
}
|
||||
|
||||
ThreadUtil.sync(this);
|
||||
}
|
||||
@Test
|
||||
void exec2() {
|
||||
|
||||
}
|
||||
}
|
92
java_client/src/test/java/com/example/wxhk/tcp/XmlTest.java
Normal file
92
java_client/src/test/java/com/example/wxhk/tcp/XmlTest.java
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,49 @@
|
||||
package com.example.wxhk.util;
|
||||
|
||||
import com.example.wxhk.model.request.GetGroupMembers;
|
||||
import com.example.wxhk.model.response.ContactList;
|
||||
import com.example.wxhk.model.response.GroupMembers;
|
||||
import org.dromara.hutool.core.lang.Console;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@SpringBootTest
|
||||
class HttpSendUtilTest {
|
||||
|
||||
|
||||
@Test
|
||||
void 获取当前登陆微信id() {
|
||||
String s = HttpSendUtil.获取当前登陆微信id();
|
||||
}
|
||||
|
||||
@Test
|
||||
void 联系人列表() {
|
||||
ContactList contactList = HttpSendUtil.联系人列表();
|
||||
|
||||
List<ContactList.DataBean> data = contactList.getData();
|
||||
for (ContactList.DataBean datum : data) {
|
||||
Console.log(datum.getWxid(),datum.getUserName());
|
||||
}
|
||||
Console.log(contactList);
|
||||
}
|
||||
@Test
|
||||
void 开启hook() {
|
||||
|
||||
}
|
||||
@Test
|
||||
void 关闭ook() {
|
||||
HttpSendUtil.关闭hook();
|
||||
}
|
||||
|
||||
@Test
|
||||
void 获取群成员() {
|
||||
GroupMembers 获取群成员 = HttpSendUtil.获取群成员(new GetGroupMembers().setChatRoomId("24964676359@chatroom"));
|
||||
Console.log(获取群成员);
|
||||
|
||||
Duration between = Duration.between(LocalDateTime.now(), LocalDateTime.now());
|
||||
}
|
||||
}
|
26
nodejs_client/tcp_server.js
Normal file
26
nodejs_client/tcp_server.js
Normal file
@ -0,0 +1,26 @@
|
||||
const net = require('net')
|
||||
|
||||
const server = net.createServer(socket => {
|
||||
console.log('New client connected')
|
||||
|
||||
let data = Buffer.from('')
|
||||
|
||||
socket.on('data', data => {
|
||||
data = Buffer.concat([data, chunk])
|
||||
console.log(`Received data: ${data}`)
|
||||
})
|
||||
|
||||
socket.on('end', () => {
|
||||
const decodedData = data.toString('utf8')
|
||||
console.log(`Received data: ${decodedData}`)
|
||||
})
|
||||
|
||||
socket.on('close', () => {
|
||||
console.log('Client disconnected')
|
||||
})
|
||||
})
|
||||
|
||||
const port = 19099
|
||||
server.listen(port, () => {
|
||||
console.log(`Server listening on port ${port}`)
|
||||
})
|
493
python/3.9.5.81/http_client.py
Normal file
493
python/3.9.5.81/http_client.py
Normal file
@ -0,0 +1,493 @@
|
||||
import requests
|
||||
import json
|
||||
|
||||
|
||||
def checkLogin():
|
||||
url = "127.0.0.1:19088/api/checkLogin"
|
||||
payload = {}
|
||||
headers = {}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def userInfo():
|
||||
url = "127.0.0.1:19088/api/userInfo"
|
||||
payload = {}
|
||||
headers = {}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def sendTextMsg():
|
||||
url = "127.0.0.1:19088/api/sendTextMsg"
|
||||
payload = json.dumps({
|
||||
"wxid": "filehelper",
|
||||
"msg": "12www"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def sendImagesMsg():
|
||||
url = "127.0.0.1:19088/api/sendImagesMsg"
|
||||
print("modify imagePath")
|
||||
raise RuntimeError("modify imagePath then deleted me")
|
||||
payload = json.dumps({
|
||||
"wxid": "filehelper",
|
||||
"imagePath": "C:\\pic.png"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
print(response.text)
|
||||
|
||||
|
||||
def sendFileMsg():
|
||||
url = "127.0.0.1:19088/api/sendFileMsg"
|
||||
print("modify filePath")
|
||||
raise RuntimeError("modify filePath then deleted me")
|
||||
payload = json.dumps({
|
||||
"wxid": "filehelper",
|
||||
"filePath": "C:\\test.zip"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def hookSyncMsg():
|
||||
url = "127.0.0.1:19088/api/hookSyncMsg"
|
||||
print("modify ip port url ")
|
||||
raise RuntimeError("modify ip port url then deleted me")
|
||||
payload = json.dumps({
|
||||
"port": "19099",
|
||||
"ip": "127.0.0.1",
|
||||
"url": "http://localhost:8080",
|
||||
"timeout": "3000",
|
||||
"enableHttp": "0"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def unhookSyncMsg():
|
||||
url = "127.0.0.1:19088/api/unhookSyncMsg"
|
||||
payload = {}
|
||||
headers = {}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def getContactList():
|
||||
url = "127.0.0.1:19088/api/getContactList"
|
||||
payload = {}
|
||||
headers = {}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def getDBInfo():
|
||||
url = "127.0.0.1:19088/api/getDBInfo"
|
||||
payload = {}
|
||||
headers = {}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def execSql():
|
||||
url = "127.0.0.1:19088/api/execSql"
|
||||
print("modify dbHandle ")
|
||||
raise RuntimeError("modify dbHandle then deleted me")
|
||||
payload = json.dumps({
|
||||
"dbHandle": 1713425147584,
|
||||
"sql": "select * from MSG where localId =100;"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def getChatRoomDetailInfo():
|
||||
url = "127.0.0.1:19088/api/getChatRoomDetailInfo"
|
||||
print("modify chatRoomId ")
|
||||
raise RuntimeError("modify chatRoomId then deleted me")
|
||||
payload = json.dumps({
|
||||
"chatRoomId": "123333@chatroom"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def addMemberToChatRoom():
|
||||
url = "127.0.0.1:19088/api/addMemberToChatRoom"
|
||||
print("modify chatRoomId memberIds ")
|
||||
raise RuntimeError("modify chatRoomId memberIds then deleted me")
|
||||
payload = json.dumps({
|
||||
"chatRoomId": "123@chatroom",
|
||||
"memberIds": "wxid_123"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
print(response.text)
|
||||
|
||||
|
||||
def delMemberFromChatRoom():
|
||||
url = "127.0.0.1:19088/api/delMemberFromChatRoom"
|
||||
print("modify chatRoomId memberIds ")
|
||||
raise RuntimeError("modify chatRoomId memberIds then deleted me")
|
||||
payload = json.dumps({
|
||||
"chatRoomId": "21363231004@chatroom",
|
||||
"memberIds": "wxid_123"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def modifyNickname():
|
||||
url = "127.0.0.1:19088/api/modifyNickname"
|
||||
print("modify chatRoomId wxid nickName")
|
||||
raise RuntimeError("modify chatRoomId wxid nickName then deleted me")
|
||||
payload = json.dumps({
|
||||
"chatRoomId": "123@chatroom",
|
||||
"wxid": "wxid_123",
|
||||
"nickName": "test"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def getMemberFromChatRoom():
|
||||
print("modify chatRoomId ")
|
||||
raise RuntimeError("modify chatRoomId then deleted me")
|
||||
url = "127.0.0.1:19088/api/getMemberFromChatRoom"
|
||||
payload = json.dumps({
|
||||
"chatRoomId": "123@chatroom"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def topMsg():
|
||||
print("modify msgId ")
|
||||
raise RuntimeError("modify msgId then deleted me")
|
||||
url = "127.0.0.1:19088/api/topMsg"
|
||||
payload = json.dumps({
|
||||
"msgId": 1222222
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def removeTopMsg():
|
||||
print("modify msgId chatRoomId ")
|
||||
raise RuntimeError("modify msgId chatRoomId then deleted me")
|
||||
|
||||
url = "127.0.0.1:19088/api/removeTopMsg"
|
||||
|
||||
payload = json.dumps({
|
||||
"chatRoomId": "123@chatroom",
|
||||
"msgId": 123
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def InviteMemberToChatRoom():
|
||||
print("modify memberIds chatRoomId ")
|
||||
raise RuntimeError("modify memberIds chatRoomId then deleted me")
|
||||
|
||||
url = "127.0.0.1:19088/api/InviteMemberToChatRoom"
|
||||
|
||||
payload = json.dumps({
|
||||
"chatRoomId": "123@chatroom",
|
||||
"memberIds": "wxid_123"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def hookLog():
|
||||
url = "127.0.0.1:19088/api/hookLog"
|
||||
payload = {}
|
||||
headers = {}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def unhookLog():
|
||||
url = "127.0.0.1:19088/api/unhookLog"
|
||||
payload = {}
|
||||
headers = {}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def createChatRoom():
|
||||
print("modify memberIds ")
|
||||
raise RuntimeError("modify memberIds then deleted me")
|
||||
url = "127.0.0.1:19088/api/createChatRoom"
|
||||
|
||||
payload = json.dumps({
|
||||
"memberIds": "wxid_8yn4k908tdqp22,wxid_oyb662qhop4422"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
def quitChatRoom():
|
||||
print("modify chatRoomId ")
|
||||
raise RuntimeError("modify chatRoomId then deleted me")
|
||||
url = "127.0.0.1:19088/api/quitChatRoom"
|
||||
|
||||
payload = json.dumps({
|
||||
"chatRoomId": "123@chatroom"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
def forwardMsg():
|
||||
print("modify msgId ")
|
||||
raise RuntimeError("modify msgId then deleted me")
|
||||
url = "127.0.0.1:19088/api/forwardMsg"
|
||||
|
||||
payload = json.dumps({
|
||||
"wxid": "filehelper",
|
||||
"msgId": "12331"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
def getSNSFirstPage():
|
||||
url = "127.0.0.1:19088/api/getSNSFirstPage"
|
||||
|
||||
payload = {}
|
||||
headers = {}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
def getSNSNextPage():
|
||||
print("modify snsId ")
|
||||
raise RuntimeError("modify snsId then deleted me")
|
||||
url = "127.0.0.1:19088/api/getSNSNextPage"
|
||||
|
||||
payload = json.dumps({
|
||||
"snsId": ""
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
print(response.text)
|
||||
|
||||
def addFavFromMsg():
|
||||
print("modify msgId ")
|
||||
raise RuntimeError("modify msgId then deleted me")
|
||||
url = "127.0.0.1:19088/api/addFavFromMsg"
|
||||
|
||||
payload = json.dumps({
|
||||
"msgId": "1222222"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
print(response.text)
|
||||
|
||||
def addFavFromImage():
|
||||
print("modify wxid imagePath ")
|
||||
raise RuntimeError("modify wxid imagePath then deleted me")
|
||||
url = "127.0.0.1:19088/api/addFavFromImage"
|
||||
|
||||
payload = json.dumps({
|
||||
"wxid": "",
|
||||
"imagePath": ""
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
print(response.text)
|
||||
|
||||
def getContactProfile():
|
||||
print("modify wxid ")
|
||||
raise RuntimeError("modify wxid then deleted me")
|
||||
url = "127.0.0.1:19088/api/getContactProfile"
|
||||
|
||||
payload = json.dumps({
|
||||
"wxid": ""
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def sendAtText():
|
||||
print("modify wxids chatRoomId")
|
||||
raise RuntimeError("modify wxids chatRoomId then deleted me")
|
||||
url = "127.0.0.1:19088/api/sendAtText"
|
||||
|
||||
payload = json.dumps({
|
||||
"wxids": "notify@all",
|
||||
"chatRoomId": "123@chatroom",
|
||||
"msg": "你好啊"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
print(response.text)
|
||||
|
||||
def forwardPublicMsg():
|
||||
print("modify param ")
|
||||
raise RuntimeError("modify param then deleted me")
|
||||
url = "127.0.0.1:19088/api/forwardPublicMsg"
|
||||
|
||||
payload = json.dumps({
|
||||
"appName": "",
|
||||
"userName": "",
|
||||
"title": "",
|
||||
"url": "",
|
||||
"thumbUrl": "",
|
||||
"digest": "",
|
||||
"wxid": "filehelper"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
print(response.text)
|
||||
|
||||
def forwardPublicMsgByMsgId():
|
||||
print("modify param ")
|
||||
raise RuntimeError("modify param then deleted me")
|
||||
url = "127.0.0.1:19088/api/forwardPublicMsgByMsgId"
|
||||
|
||||
payload = json.dumps({
|
||||
"msgId": 123,
|
||||
"wxid": "filehelper"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
print(response.text)
|
||||
|
||||
def downloadAttach():
|
||||
print("modify param ")
|
||||
raise RuntimeError("modify param then deleted me")
|
||||
url = "127.0.0.1:19088/api/downloadAttach"
|
||||
|
||||
payload = json.dumps({
|
||||
"msgId": 123
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
print(response.text)
|
||||
|
||||
|
||||
def decodeImage():
|
||||
print("modify param ")
|
||||
raise RuntimeError("modify param then deleted me")
|
||||
url = "127.0.0.1:19088/api/decodeImage"
|
||||
|
||||
payload = json.dumps({
|
||||
"filePath": "C:\\66664816980131.dat",
|
||||
"storeDir": "C:\\test"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
print(response.text)
|
||||
|
||||
|
||||
def getVoiceByMsgId():
|
||||
print("modify param ")
|
||||
raise RuntimeError("modify param then deleted me")
|
||||
url = "127.0.0.1:19088/api/getVoiceByMsgId"
|
||||
|
||||
payload = json.dumps({
|
||||
"msgId": 7880439644200,
|
||||
"storeDir": "c:\\test"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
|
||||
print(response.text)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
checkLogin()
|
||||
# userInfo()
|
595
python/client.py
Normal file
595
python/client.py
Normal file
@ -0,0 +1,595 @@
|
||||
import requests
|
||||
import json
|
||||
|
||||
|
||||
def check_login():
|
||||
"""
|
||||
0.检查是否登录
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=0"
|
||||
payload = {}
|
||||
headers = {}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def user_info():
|
||||
"""
|
||||
登录用户信息
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=8"
|
||||
payload = {}
|
||||
headers = {}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def send_text():
|
||||
"""
|
||||
发送文本
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=2"
|
||||
payload = json.dumps({
|
||||
"wxid": "filehelper",
|
||||
"msg": "123"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def send_at():
|
||||
"""
|
||||
发送@消息
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=3"
|
||||
payload = json.dumps({
|
||||
"chatRoomId": "12333@chatroom",
|
||||
"wxids": "notify@all",
|
||||
"msg": "12333"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def send_img():
|
||||
"""
|
||||
发送图片
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=5"
|
||||
payload = json.dumps({
|
||||
"wxid": "filehelper",
|
||||
"imagePath": "C:/123.png"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def send_file():
|
||||
"""
|
||||
发送文件
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=6"
|
||||
payload = json.dumps({
|
||||
"wxid": "filehelper",
|
||||
"filePath": "C:/test.txt"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def hook_msg():
|
||||
"""
|
||||
hook 消息
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=9"
|
||||
payload = json.dumps({
|
||||
"port": "19099",
|
||||
"ip": "127.0.0.1"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def unhook_msg():
|
||||
"""
|
||||
取消消息hook
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=10"
|
||||
payload = {}
|
||||
headers = {}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def hook_img():
|
||||
"""
|
||||
hook 图片
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=11"
|
||||
payload = json.dumps({
|
||||
"imgDir": "C:\\img"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def unhook_img():
|
||||
"""
|
||||
取消hook 图片
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=12"
|
||||
payload = json.dumps({
|
||||
"imgDir": "C:\\img"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def hook_voice():
|
||||
"""
|
||||
hook 语音
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=56"
|
||||
payload = json.dumps({
|
||||
"msgId": 322456091115784000
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def unhook_voice():
|
||||
"""
|
||||
取消hook 语音
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=14"
|
||||
payload = {}
|
||||
headers = {}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def del_friend():
|
||||
"""
|
||||
删除好友
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=17"
|
||||
payload = json.dumps({
|
||||
"wxid": "wxid_1124423322"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def search_friend():
|
||||
"""
|
||||
网络搜素用户
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=19"
|
||||
payload = json.dumps({
|
||||
"keyword": "13812345678"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def add_friend():
|
||||
"""
|
||||
添加好友
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=20"
|
||||
payload = json.dumps({
|
||||
"wxid": "wxid_o11222334422"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def fetch_chat_room_members():
|
||||
"""
|
||||
群成员
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=25"
|
||||
payload = json.dumps({
|
||||
"chatRoomId": "2112222004@chatroom"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def get_member_nickname():
|
||||
"""
|
||||
群成员昵称
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=26"
|
||||
payload = json.dumps({
|
||||
"chatRoomId": "322333384@chatroom",
|
||||
"memberId": "wxid_4m1112222u22"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def del_member():
|
||||
"""
|
||||
删除群成员
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=27"
|
||||
payload = json.dumps({
|
||||
"chatRoomId": "31122263384@chatroom",
|
||||
"memberIds": "wxid_12223334422"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def add_member():
|
||||
"""
|
||||
增加群成员
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=28"
|
||||
payload = json.dumps({
|
||||
"chatRoomId": "1111163384@chatroom",
|
||||
"memberIds": "wxid_o12222222"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def modify_room_name():
|
||||
"""
|
||||
修改群昵称
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=31"
|
||||
payload = json.dumps({
|
||||
"chatRoomId": "222285428@chatroom",
|
||||
"wxid": "wxid_222222512",
|
||||
"nickName": "qqq"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def get_db_handlers():
|
||||
"""
|
||||
获取sqlite3的操作句柄
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=32"
|
||||
payload = {}
|
||||
headers = {}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def query_db_by_sql():
|
||||
"""
|
||||
查询数据库
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=34"
|
||||
payload = json.dumps({
|
||||
"dbHandle": 116201928,
|
||||
"sql": "select localId from MSG where MsgSvrID= 7533111101686156"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def hook_log():
|
||||
"""
|
||||
hook 日志
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=36"
|
||||
payload = {}
|
||||
headers = {}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def unhook_log():
|
||||
"""
|
||||
取消hook日志
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=37"
|
||||
payload = {}
|
||||
headers = {}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def forward():
|
||||
"""
|
||||
转发消息
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=40"
|
||||
payload = json.dumps({
|
||||
"wxid": "filehelper",
|
||||
"msgid": "705117679011122708"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def logout():
|
||||
"""
|
||||
退出登录
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=44"
|
||||
payload = {}
|
||||
headers = {}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def confirm_receipt():
|
||||
"""
|
||||
确认收款
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=45"
|
||||
payload = json.dumps({
|
||||
"wxid": "wxid_1111112622",
|
||||
"transcationId": "10000500012312222212243388865912",
|
||||
"transferId": "100005000120212222173123036"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def contact_list():
|
||||
"""
|
||||
好友列表
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=46"
|
||||
payload = {}
|
||||
headers = {}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def room_detail():
|
||||
"""
|
||||
群详情
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=47"
|
||||
payload = json.dumps({
|
||||
"chatRoomId": "199134446111@chatroom"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def ocr():
|
||||
"""
|
||||
ocr提取文字
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=49"
|
||||
payload = json.dumps({
|
||||
"imagePath": "C:\\WeChat Files\\b23e84997144dd12f21554b0.dat"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def pat():
|
||||
"""
|
||||
拍一拍
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=50"
|
||||
payload = json.dumps({
|
||||
"chatRoomId": "211111121004@chatroom",
|
||||
"wxid": "wxid_111111111422"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def top_msg():
|
||||
"""
|
||||
消息置顶
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=51"
|
||||
payload = json.dumps({
|
||||
"wxid": "wxid_o11114422",
|
||||
"msgid": 3728307145189195000
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def close_top_msg():
|
||||
"""
|
||||
取消置顶
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=52"
|
||||
payload = json.dumps({
|
||||
"chatRoomId": "213222231004@chatroom",
|
||||
"msgid": 3728307145189195000
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def sns_first():
|
||||
"""
|
||||
朋友圈首页
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=53"
|
||||
payload = {}
|
||||
headers = {}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def sns_next():
|
||||
"""
|
||||
朋友圈下一页
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=54"
|
||||
payload = json.dumps({
|
||||
"snsId": "14091988153735844377"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def query_nickname():
|
||||
"""
|
||||
查询联系人或群名称
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=55"
|
||||
|
||||
payload = json.dumps({
|
||||
"id": "wxid_1112p4422"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def download_msg_attach():
|
||||
"""
|
||||
下载消息附件
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=56"
|
||||
payload = json.dumps({
|
||||
"msgId": 6080100336053626000
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
def get_member_info():
|
||||
"""
|
||||
获取群/群成员信息
|
||||
:return:
|
||||
"""
|
||||
url = "127.0.0.1:19088/api/?type=57"
|
||||
payload = json.dumps({
|
||||
"wxid": "wxid_tx8k6tu21112"
|
||||
})
|
||||
headers = {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
print(response.text)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
check_login()
|
||||
user_info()
|
||||
send_text()
|
51
python/decrypt.py
Normal file
51
python/decrypt.py
Normal file
@ -0,0 +1,51 @@
|
||||
import ctypes
|
||||
import hashlib
|
||||
import hmac
|
||||
|
||||
# pip install pycryptodome
|
||||
from Crypto.Cipher import AES
|
||||
|
||||
|
||||
def decrypt(password, input_file, out_file):
|
||||
password = bytes.fromhex(password.replace(' ', ''))
|
||||
with open(input_file, 'rb') as (f):
|
||||
blist = f.read()
|
||||
print(len(blist))
|
||||
salt = blist[:16]
|
||||
key = hashlib.pbkdf2_hmac('sha1', password, salt, DEFAULT_ITER, KEY_SIZE)
|
||||
first = blist[16:DEFAULT_PAGESIZE]
|
||||
mac_salt = bytes([x ^ 58 for x in salt])
|
||||
mac_key = hashlib.pbkdf2_hmac('sha1', key, mac_salt, 2, KEY_SIZE)
|
||||
hash_mac = hmac.new(mac_key, digestmod='sha1')
|
||||
hash_mac.update(first[:-32])
|
||||
hash_mac.update(bytes(ctypes.c_int(1)))
|
||||
if hash_mac.digest() == first[-32:-12]:
|
||||
print('decrypt success')
|
||||
else:
|
||||
print('password error')
|
||||
return
|
||||
blist = [blist[i:i + DEFAULT_PAGESIZE] for i in range(DEFAULT_PAGESIZE, len(blist), DEFAULT_PAGESIZE)]
|
||||
with open(out_file, 'wb') as (f):
|
||||
f.write(SQLITE_FILE_HEADER)
|
||||
t = AES.new(key, AES.MODE_CBC, first[-48:-32])
|
||||
f.write(t.decrypt(first[:-48]))
|
||||
f.write(first[-48:])
|
||||
for i in blist:
|
||||
t = AES.new(key, AES.MODE_CBC, i[-48:-32])
|
||||
f.write(t.decrypt(i[:-48]))
|
||||
f.write(i[-48:])
|
||||
|
||||
|
||||
def main():
|
||||
password = '565735E30E474DA09250CB5AA047E3940FFA1C6F767C4263B13ABB512933DA49'
|
||||
input_file = 'C:/var/Applet.db'
|
||||
out_file = 'c:/var/out/Applet.db'
|
||||
decrypt(password, input_file, out_file)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
SQLITE_FILE_HEADER = bytes('SQLite format 3', encoding='ASCII') + bytes(1)
|
||||
KEY_SIZE = 32
|
||||
DEFAULT_PAGESIZE = 4096
|
||||
DEFAULT_ITER = 64000
|
||||
main()
|
26
python/http_server.py
Normal file
26
python/http_server.py
Normal file
@ -0,0 +1,26 @@
|
||||
from fastapi import FastAPI, Request
|
||||
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
# pip install fastapi
|
||||
# run command :uvicorn test:app --reload
|
||||
# 127.0.0.1:8000/api
|
||||
|
||||
@app.post("/api")
|
||||
def create_item(request: Request):
|
||||
print("recv msg")
|
||||
return {"code": 0, "msg": "success"}
|
||||
|
||||
|
||||
@app.middleware("http")
|
||||
async def TestCustomMiddleware(request: Request, call_next):
|
||||
the_headers = request.headers
|
||||
the_body = await request.json()
|
||||
|
||||
print(the_headers)
|
||||
print(the_body)
|
||||
|
||||
response = await call_next(request)
|
||||
|
||||
return response
|
10
python/readme.md
Normal file
10
python/readme.md
Normal file
@ -0,0 +1,10 @@
|
||||
### 常用的一些工具
|
||||
|
||||
|
||||
client.py : 快速测试dll的http接口。
|
||||
|
||||
decrpt.py : 微信数据库解密工具。password 为dll个人信息里返回的dbkey。
|
||||
|
||||
http_server.py : 一个简单的http server,用来接收hook的消息。
|
||||
|
||||
tcpserver.py: 一个简单的tcp server,用来接收hook的消息。
|
57
python/tcpserver.py
Normal file
57
python/tcpserver.py
Normal file
@ -0,0 +1,57 @@
|
||||
import json
|
||||
import threading
|
||||
import socketserver
|
||||
|
||||
|
||||
class ReceiveMsgSocketServer(socketserver.BaseRequestHandler):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def handle(self):
|
||||
conn = self.request
|
||||
while True:
|
||||
try:
|
||||
ptr_data = b""
|
||||
while True:
|
||||
data = conn.recv(1024)
|
||||
ptr_data += data
|
||||
if len(data) == 0 or data[-1] == 0xA:
|
||||
break
|
||||
|
||||
msg = json.loads(ptr_data)
|
||||
ReceiveMsgSocketServer.msg_callback(msg)
|
||||
|
||||
except OSError:
|
||||
break
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
conn.sendall("200 OK".encode())
|
||||
conn.close()
|
||||
|
||||
@staticmethod
|
||||
def msg_callback(msg):
|
||||
print(msg)
|
||||
|
||||
|
||||
def start_socket_server(port: int = 19099,
|
||||
request_handler=ReceiveMsgSocketServer,
|
||||
main_thread: bool = True) -> int or None:
|
||||
ip_port = ("127.0.0.1", port)
|
||||
try:
|
||||
s = socketserver.ThreadingTCPServer(ip_port, request_handler)
|
||||
if main_thread:
|
||||
s.serve_forever()
|
||||
else:
|
||||
socket_server = threading.Thread(target=s.serve_forever)
|
||||
socket_server.setDaemon(True)
|
||||
socket_server.start()
|
||||
return socket_server.ident
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return None
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
start_socket_server()
|
@ -7,7 +7,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D '_UNICODE' /D 'UNICODE'")
|
||||
|
||||
file(GLOB INJECT_CPP_FILES ${PROJECT_SOURCE_DIR}/src/*.cc ${PROJECT_SOURCE_DIR}/src/*.cpp)
|
||||
file(GLOB INJECT_CPP_FILES ${PROJECT_SOURCE_DIR}/*.cc ${PROJECT_SOURCE_DIR}/*.cpp)
|
||||
|
||||
add_executable (injector ${INJECT_CPP_FILES})
|
||||
|
@ -526,7 +526,7 @@ DWORD GetPIDForProcess(wchar_t* process)
|
||||
if (!hSnapshot) {
|
||||
return 0;
|
||||
}
|
||||
pe32.dwSize = sizeof(PROCESSENTRY32);
|
||||
pe32.dwSize = sizeof(PROCESSENTRY32W);
|
||||
for (working = Process32FirstW(hSnapshot, &pe32); working; working = Process32NextW(hSnapshot, &pe32))
|
||||
{
|
||||
if (!wcscmp(pe32.szExeFile, process))
|
||||
@ -933,7 +933,7 @@ int InjectDll(wchar_t* szPName, wchar_t* szDllPath)
|
||||
result = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
DWORD dErrorCode = GetLastError();
|
||||
printf("dll inject fail");
|
||||
printf("error code : %d ", dErrorCode);
|
1
spdlog
Submodule
1
spdlog
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit ad0e89cbfb4d0c1ce4d097e134eb7be67baebb36
|
@ -1,13 +1,14 @@
|
||||
/*
|
||||
#include "pch.h"
|
||||
/*
|
||||
base64.cpp and base64.h
|
||||
|
||||
base64 encoding and decoding with C++.
|
||||
More information at
|
||||
https://renenyffenegger.ch/notes/development/Base64/Encoding-and-decoding-base-64-with-cpp
|
||||
|
||||
Version: 2.rc.09 (release candidate)
|
||||
Version: 2.rc.08 (release candidate)
|
||||
|
||||
Copyright (C) 2004-2017, 2020-2022 René Nyffenegger
|
||||
Copyright (C) 2004-2017, 2020, 2021 Ren<EFBFBD><EFBFBD> Nyffenegger
|
||||
|
||||
This source code is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the author be held liable for any damages
|
||||
@ -27,7 +28,7 @@
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
René Nyffenegger rene.nyffenegger@adp-gmbh.ch
|
||||
Ren<EFBFBD><EFBFBD> Nyffenegger rene.nyffenegger@adp-gmbh.ch
|
||||
|
||||
*/
|
||||
|
||||
@ -41,27 +42,33 @@
|
||||
// two sets of base64 characters needs to be chosen.
|
||||
// They differ in their last two characters.
|
||||
//
|
||||
static const char* base64_chars[2] = {
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789"
|
||||
"+/",
|
||||
static const char *base64_chars[2] = {
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789"
|
||||
"+/",
|
||||
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789"
|
||||
"-_" };
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789"
|
||||
"-_"};
|
||||
|
||||
static unsigned int pos_of_char(const unsigned char chr) {
|
||||
static unsigned int pos_of_char(const unsigned char chr)
|
||||
{
|
||||
//
|
||||
// Return the position of chr within base64_encode()
|
||||
//
|
||||
|
||||
if (chr >= 'A' && chr <= 'Z') return chr - 'A';
|
||||
else if (chr >= 'a' && chr <= 'z') return chr - 'a' + ('Z' - 'A') + 1;
|
||||
else if (chr >= '0' && chr <= '9') return chr - '0' + ('Z' - 'A') + ('z' - 'a') + 2;
|
||||
else if (chr == '+' || chr == '-') return 62; // Be liberal with input and accept both url ('-') and non-url ('+') base 64 characters (
|
||||
else if (chr == '/' || chr == '_') return 63; // Ditto for '/' and '_'
|
||||
if (chr >= 'A' && chr <= 'Z')
|
||||
return chr - 'A';
|
||||
else if (chr >= 'a' && chr <= 'z')
|
||||
return chr - 'a' + ('Z' - 'A') + 1;
|
||||
else if (chr >= '0' && chr <= '9')
|
||||
return chr - '0' + ('Z' - 'A') + ('z' - 'a') + 2;
|
||||
else if (chr == '+' || chr == '-')
|
||||
return 62; // Be liberal with input and accept both url ('-') and non-url ('+') base 64 characters (
|
||||
else if (chr == '/' || chr == '_')
|
||||
return 63; // Ditto for '/' and '_'
|
||||
else
|
||||
//
|
||||
// 2020-10-23: Throw std::exception rather than const char*
|
||||
@ -70,17 +77,20 @@ static unsigned int pos_of_char(const unsigned char chr) {
|
||||
throw std::runtime_error("Input is not valid base64-encoded data.");
|
||||
}
|
||||
|
||||
static std::string insert_linebreaks(std::string str, size_t distance) {
|
||||
static std::string insert_linebreaks(std::string str, size_t distance)
|
||||
{
|
||||
//
|
||||
// Provided by https://github.com/JomaCorpFX, adapted by me.
|
||||
//
|
||||
if (!str.length()) {
|
||||
if (!str.length())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
size_t pos = distance;
|
||||
|
||||
while (pos < str.size()) {
|
||||
while (pos < str.size())
|
||||
{
|
||||
str.insert(pos, "\n");
|
||||
pos += distance + 1;
|
||||
}
|
||||
@ -89,26 +99,31 @@ static std::string insert_linebreaks(std::string str, size_t distance) {
|
||||
}
|
||||
|
||||
template <typename String, unsigned int line_length>
|
||||
static std::string encode_with_line_breaks(String s) {
|
||||
static std::string encode_with_line_breaks(String s)
|
||||
{
|
||||
return insert_linebreaks(base64_encode(s, false), line_length);
|
||||
}
|
||||
|
||||
template <typename String>
|
||||
static std::string encode_pem(String s) {
|
||||
static std::string encode_pem(String s)
|
||||
{
|
||||
return encode_with_line_breaks<String, 64>(s);
|
||||
}
|
||||
|
||||
template <typename String>
|
||||
static std::string encode_mime(String s) {
|
||||
static std::string encode_mime(String s)
|
||||
{
|
||||
return encode_with_line_breaks<String, 76>(s);
|
||||
}
|
||||
|
||||
template <typename String>
|
||||
static std::string encode(String s, bool url) {
|
||||
return base64_encode(reinterpret_cast<const unsigned char*>(s.data()), s.length(), url);
|
||||
static std::string encode(String s, bool url)
|
||||
{
|
||||
return base64_encode(reinterpret_cast<const unsigned char *>(s.data()), s.length(), url);
|
||||
}
|
||||
|
||||
std::string base64_encode(unsigned char const* bytes_to_encode, size_t in_len, bool url) {
|
||||
std::string base64_encode(unsigned char const *bytes_to_encode, size_t in_len, bool url)
|
||||
{
|
||||
|
||||
size_t len_encoded = (in_len + 2) / 3 * 4;
|
||||
|
||||
@ -123,29 +138,34 @@ std::string base64_encode(unsigned char const* bytes_to_encode, size_t in_len, b
|
||||
// the correct character set is chosen by subscripting
|
||||
// base64_chars with url.
|
||||
//
|
||||
const char* base64_chars_ = base64_chars[url];
|
||||
const char *base64_chars_ = base64_chars[url];
|
||||
|
||||
std::string ret;
|
||||
ret.reserve(len_encoded);
|
||||
|
||||
unsigned int pos = 0;
|
||||
|
||||
while (pos < in_len) {
|
||||
while (pos < in_len)
|
||||
{
|
||||
ret.push_back(base64_chars_[(bytes_to_encode[pos + 0] & 0xfc) >> 2]);
|
||||
|
||||
if (pos + 1 < in_len) {
|
||||
if (pos + 1 < in_len)
|
||||
{
|
||||
ret.push_back(base64_chars_[((bytes_to_encode[pos + 0] & 0x03) << 4) + ((bytes_to_encode[pos + 1] & 0xf0) >> 4)]);
|
||||
|
||||
if (pos + 2 < in_len) {
|
||||
if (pos + 2 < in_len)
|
||||
{
|
||||
ret.push_back(base64_chars_[((bytes_to_encode[pos + 1] & 0x0f) << 2) + ((bytes_to_encode[pos + 2] & 0xc0) >> 6)]);
|
||||
ret.push_back(base64_chars_[bytes_to_encode[pos + 2] & 0x3f]);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
ret.push_back(base64_chars_[(bytes_to_encode[pos + 1] & 0x0f) << 2]);
|
||||
ret.push_back(trailing_char);
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
|
||||
ret.push_back(base64_chars_[(bytes_to_encode[pos + 0] & 0x03) << 4]);
|
||||
ret.push_back(trailing_char);
|
||||
@ -155,20 +175,22 @@ std::string base64_encode(unsigned char const* bytes_to_encode, size_t in_len, b
|
||||
pos += 3;
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename String>
|
||||
static std::string decode(String const& encoded_string, bool remove_linebreaks) {
|
||||
static std::string decode(String encoded_string, bool remove_linebreaks)
|
||||
{
|
||||
//
|
||||
// decode(…) is templated so that it can be used with String = const std::string&
|
||||
// decode(<EFBFBD><EFBFBD>) is templated so that it can be used with String = const std::string&
|
||||
// or std::string_view (requires at least C++17)
|
||||
//
|
||||
|
||||
if (encoded_string.empty()) return std::string();
|
||||
if (encoded_string.empty())
|
||||
return std::string();
|
||||
|
||||
if (remove_linebreaks) {
|
||||
if (remove_linebreaks)
|
||||
{
|
||||
|
||||
std::string copy(encoded_string);
|
||||
|
||||
@ -190,7 +212,8 @@ static std::string decode(String const& encoded_string, bool remove_linebreaks)
|
||||
std::string ret;
|
||||
ret.reserve(approx_length_of_decoded_string);
|
||||
|
||||
while (pos < length_of_string) {
|
||||
while (pos < length_of_string)
|
||||
{
|
||||
//
|
||||
// Iterate over encoded input string in chunks. The size of all
|
||||
// chunks except the last one is 4 bytes.
|
||||
@ -204,33 +227,32 @@ static std::string decode(String const& encoded_string, bool remove_linebreaks)
|
||||
// The last chunk produces at least one and up to three bytes.
|
||||
//
|
||||
|
||||
size_t pos_of_char_1 = pos_of_char(encoded_string.at(pos + 1));
|
||||
size_t pos_of_char_1 = pos_of_char(encoded_string[pos + 1]);
|
||||
|
||||
//
|
||||
// Emit the first output byte that is produced in each chunk:
|
||||
//
|
||||
ret.push_back(static_cast<std::string::value_type>(((pos_of_char(encoded_string.at(pos + 0))) << 2) + ((pos_of_char_1 & 0x30) >> 4)));
|
||||
ret.push_back(static_cast<std::string::value_type>(((pos_of_char(encoded_string[pos + 0])) << 2) + ((pos_of_char_1 & 0x30) >> 4)));
|
||||
|
||||
if ((pos + 2 < length_of_string) && // Check for data that is not padded with equal signs (which is allowed by RFC 2045)
|
||||
encoded_string.at(pos + 2) != '=' &&
|
||||
encoded_string.at(pos + 2) != '.' // accept URL-safe base 64 strings, too, so check for '.' also.
|
||||
)
|
||||
if ((pos + 2 < length_of_string) && // Check for data that is not padded with equal signs (which is allowed by RFC 2045)
|
||||
encoded_string[pos + 2] != '=' &&
|
||||
encoded_string[pos + 2] != '.' // accept URL-safe base 64 strings, too, so check for '.' also.
|
||||
)
|
||||
{
|
||||
//
|
||||
// Emit a chunk's second byte (which might not be produced in the last chunk).
|
||||
//
|
||||
unsigned int pos_of_char_2 = pos_of_char(encoded_string.at(pos + 2));
|
||||
unsigned int pos_of_char_2 = pos_of_char(encoded_string[pos + 2]);
|
||||
ret.push_back(static_cast<std::string::value_type>(((pos_of_char_1 & 0x0f) << 4) + ((pos_of_char_2 & 0x3c) >> 2)));
|
||||
|
||||
if ((pos + 3 < length_of_string) &&
|
||||
encoded_string.at(pos + 3) != '=' &&
|
||||
encoded_string.at(pos + 3) != '.'
|
||||
)
|
||||
encoded_string[pos + 3] != '=' &&
|
||||
encoded_string[pos + 3] != '.')
|
||||
{
|
||||
//
|
||||
// Emit a chunk's third byte (which might not be produced in the last chunk).
|
||||
//
|
||||
ret.push_back(static_cast<std::string::value_type>(((pos_of_char_2 & 0x03) << 6) + pos_of_char(encoded_string.at(pos + 3))));
|
||||
ret.push_back(static_cast<std::string::value_type>(((pos_of_char_2 & 0x03) << 6) + pos_of_char(encoded_string[pos + 3])));
|
||||
}
|
||||
}
|
||||
|
||||
@ -240,19 +262,23 @@ static std::string decode(String const& encoded_string, bool remove_linebreaks)
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string base64_decode(std::string const& s, bool remove_linebreaks) {
|
||||
std::string base64_decode(std::string const &s, bool remove_linebreaks)
|
||||
{
|
||||
return decode(s, remove_linebreaks);
|
||||
}
|
||||
|
||||
std::string base64_encode(std::string const& s, bool url) {
|
||||
std::string base64_encode(std::string const &s, bool url)
|
||||
{
|
||||
return encode(s, url);
|
||||
}
|
||||
|
||||
std::string base64_encode_pem(std::string const& s) {
|
||||
std::string base64_encode_pem(std::string const &s)
|
||||
{
|
||||
return encode_pem(s);
|
||||
}
|
||||
|
||||
std::string base64_encode_mime(std::string const& s) {
|
||||
std::string base64_encode_mime(std::string const &s)
|
||||
{
|
||||
return encode_mime(s);
|
||||
}
|
||||
|
||||
@ -263,20 +289,24 @@ std::string base64_encode_mime(std::string const& s) {
|
||||
// Provided by Yannic Bonenberger (https://github.com/Yannic)
|
||||
//
|
||||
|
||||
std::string base64_encode(std::string_view s, bool url) {
|
||||
std::string base64_encode(std::string_view s, bool url)
|
||||
{
|
||||
return encode(s, url);
|
||||
}
|
||||
|
||||
std::string base64_encode_pem(std::string_view s) {
|
||||
std::string base64_encode_pem(std::string_view s)
|
||||
{
|
||||
return encode_pem(s);
|
||||
}
|
||||
|
||||
std::string base64_encode_mime(std::string_view s) {
|
||||
std::string base64_encode_mime(std::string_view s)
|
||||
{
|
||||
return encode_mime(s);
|
||||
}
|
||||
|
||||
std::string base64_decode(std::string_view s, bool remove_linebreaks) {
|
||||
std::string base64_decode(std::string_view s, bool remove_linebreaks)
|
||||
{
|
||||
return decode(s, remove_linebreaks);
|
||||
}
|
||||
|
||||
#endif // __cplusplus >= 201703L
|
||||
#endif // __cplusplus >= 201703L
|
@ -1,8 +1,8 @@
|
||||
//
|
||||
//
|
||||
// base64 encoding and decoding with C++.
|
||||
// Version: 2.rc.09 (release candidate)
|
||||
// Version: 2.rc.08 (release candidate)
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#ifndef BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A
|
||||
#define BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A
|
||||
|
||||
@ -10,14 +10,14 @@
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
#include <string_view>
|
||||
#endif // __cplusplus >= 201703L
|
||||
#endif // __cplusplus >= 201703L
|
||||
|
||||
std::string base64_encode(std::string const& s, bool url = false);
|
||||
std::string base64_encode_pem(std::string const& s);
|
||||
std::string base64_encode_mime(std::string const& s);
|
||||
std::string base64_encode(std::string const &s, bool url = false);
|
||||
std::string base64_encode_pem(std::string const &s);
|
||||
std::string base64_encode_mime(std::string const &s);
|
||||
|
||||
std::string base64_decode(std::string const& s, bool remove_linebreaks = false);
|
||||
std::string base64_encode(unsigned char const*, size_t len, bool url = false);
|
||||
std::string base64_decode(std::string const &s, bool remove_linebreaks = false);
|
||||
std::string base64_encode(unsigned char const *, size_t len, bool url = false);
|
||||
|
||||
#if __cplusplus >= 201703L
|
||||
//
|
||||
@ -30,6 +30,6 @@ std::string base64_encode_pem(std::string_view s);
|
||||
std::string base64_encode_mime(std::string_view s);
|
||||
|
||||
std::string base64_decode(std::string_view s, bool remove_linebreaks = false);
|
||||
#endif // __cplusplus >= 201703L
|
||||
#endif // __cplusplus >= 201703L
|
||||
|
||||
#endif /* BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A */
|
14
src/config.cc
Normal file
14
src/config.cc
Normal file
@ -0,0 +1,14 @@
|
||||
#include "pch.h"
|
||||
#include "config.h"
|
||||
|
||||
namespace wxhelper {
|
||||
Config::Config(/* args */) {}
|
||||
|
||||
Config::~Config() {}
|
||||
|
||||
void Config::Initialize() {
|
||||
port_ = GetPrivateProfileInt("config", "Port", 19088, "./config.ini");
|
||||
}
|
||||
int Config::GetPort() { return port_; }
|
||||
|
||||
} // namespace wxhelper
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user