提交 d542f34d 编写于 作者: L ljc545w

优化目录树

上级 f68111cf
/Debug
*.exp
*.pdb
*.lib
*/Debug/
*/Release/
*/SOCKET_Debug/
*/SOCKET_Release/
*/Win32/
*/x64/
build/
Debug/
!/Release
Release/
SOCKET_Debug/
SOCKET_Release/
Win32/
x64/
*.rar
/.vs/
/x64
*/obj/
/wxRobot/bin/Debug/
/wxRobot/bin/Release/*.pdb
*/__pycache__/
packages
obj/
packages/
mongoose.c
mongoose.h
json.hpp
# py
__pycache__/
# Visual Studio
.vs
*.exp
*.pdb
*.lib
# VSCode
.vscode
# JetBrians IDE
......
......@@ -71,6 +71,8 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IgnoreImportLibrary>true</IgnoreImportLibrary>
<LinkIncremental>true</LinkIncremental>
<CopyLocalDeploymentContent>false</CopyLocalDeploymentContent>
<CopyCppRuntimeToOutputDir>false</CopyCppRuntimeToOutputDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<IgnoreImportLibrary>true</IgnoreImportLibrary>
......@@ -79,6 +81,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IgnoreImportLibrary>true</IgnoreImportLibrary>
<LinkIncremental>false</LinkIncremental>
<CopyLocalDeploymentContent>true</CopyLocalDeploymentContent>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IgnoreImportLibrary>true</IgnoreImportLibrary>
......@@ -114,6 +117,10 @@
<SubSystem>Windows</SubSystem>
<RegisterOutput>true</RegisterOutput>
</Link>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
......@@ -177,6 +184,9 @@
<OptimizeReferences>true</OptimizeReferences>
<RegisterOutput>true</RegisterOutput>
</Link>
<PostBuildEvent>
<Command>xcopy /y /d "$(TargetPath)" "$(SolutionDir)build\com\"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
......@@ -337,4 +347,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
\ No newline at end of file
</Project>
......@@ -5,21 +5,8 @@ VisualStudioVersion = 16.0.31605.320
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CWeChatRobot", "CWeChatRobot\WeChatRobotCOM.vcxproj", "{F54A8A7E-C2C0-4FD8-B625-59C77FF613BA}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WeChatTools", "WeChatTools\WeChatTools.vcxproj", "{3F7198C7-68D1-4BBA-9BF2-B7FC67A9426E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DWeChatRobot", "DWeChatRobot\DWeChatRobot.vcxproj", "{C0FC8DAB-0590-46AC-9270-6FEA45D52390}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "wxRobot", "wxRobot", "{8E5B7B88-AB21-4B97-BAC1-956A35E33671}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Python", "Python", "{9533FA77-5AB8-473D-83D5-55E07137401E}"
ProjectSection(SolutionItems) = preProject
Python\wxRobot.py = Python\wxRobot.py
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CSharp", "CSharp", "{4DE1F624-3F17-44E8-9B1F-28D88285D25F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wxRobot", "wxRobot\wxRobot.csproj", "{10504CFA-6D19-4A97-8728-11BCE6C2499F}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wxDriver", "wxDriver\wxDriver.vcxproj", "{B8740C2A-CBE7-4873-9669-E0DFEC4A3B8D}"
EndProject
Global
......@@ -60,28 +47,6 @@ Global
{F54A8A7E-C2C0-4FD8-B625-59C77FF613BA}.SOCKET_Release|x64.Build.0 = Release|x64
{F54A8A7E-C2C0-4FD8-B625-59C77FF613BA}.SOCKET_Release|x86.ActiveCfg = Release|Win32
{F54A8A7E-C2C0-4FD8-B625-59C77FF613BA}.SOCKET_Release|x86.Build.0 = Release|Win32
{3F7198C7-68D1-4BBA-9BF2-B7FC67A9426E}.Debug|Any CPU.ActiveCfg = Debug|Win32
{3F7198C7-68D1-4BBA-9BF2-B7FC67A9426E}.Debug|x64.ActiveCfg = Debug|x64
{3F7198C7-68D1-4BBA-9BF2-B7FC67A9426E}.Debug|x64.Build.0 = Debug|x64
{3F7198C7-68D1-4BBA-9BF2-B7FC67A9426E}.Debug|x86.ActiveCfg = Debug|Win32
{3F7198C7-68D1-4BBA-9BF2-B7FC67A9426E}.Debug|x86.Build.0 = Debug|Win32
{3F7198C7-68D1-4BBA-9BF2-B7FC67A9426E}.Release|Any CPU.ActiveCfg = Release|Win32
{3F7198C7-68D1-4BBA-9BF2-B7FC67A9426E}.Release|x64.ActiveCfg = Release|x64
{3F7198C7-68D1-4BBA-9BF2-B7FC67A9426E}.Release|x64.Build.0 = Release|x64
{3F7198C7-68D1-4BBA-9BF2-B7FC67A9426E}.Release|x86.ActiveCfg = Release|Win32
{3F7198C7-68D1-4BBA-9BF2-B7FC67A9426E}.Release|x86.Build.0 = Release|Win32
{3F7198C7-68D1-4BBA-9BF2-B7FC67A9426E}.SOCKET_DEBUG|Any CPU.ActiveCfg = Release|x64
{3F7198C7-68D1-4BBA-9BF2-B7FC67A9426E}.SOCKET_DEBUG|Any CPU.Build.0 = Release|x64
{3F7198C7-68D1-4BBA-9BF2-B7FC67A9426E}.SOCKET_DEBUG|x64.ActiveCfg = Release|x64
{3F7198C7-68D1-4BBA-9BF2-B7FC67A9426E}.SOCKET_DEBUG|x64.Build.0 = Release|x64
{3F7198C7-68D1-4BBA-9BF2-B7FC67A9426E}.SOCKET_DEBUG|x86.ActiveCfg = Release|Win32
{3F7198C7-68D1-4BBA-9BF2-B7FC67A9426E}.SOCKET_DEBUG|x86.Build.0 = Release|Win32
{3F7198C7-68D1-4BBA-9BF2-B7FC67A9426E}.SOCKET_Release|Any CPU.ActiveCfg = Release|x64
{3F7198C7-68D1-4BBA-9BF2-B7FC67A9426E}.SOCKET_Release|Any CPU.Build.0 = Release|x64
{3F7198C7-68D1-4BBA-9BF2-B7FC67A9426E}.SOCKET_Release|x64.ActiveCfg = Release|x64
{3F7198C7-68D1-4BBA-9BF2-B7FC67A9426E}.SOCKET_Release|x64.Build.0 = Release|x64
{3F7198C7-68D1-4BBA-9BF2-B7FC67A9426E}.SOCKET_Release|x86.ActiveCfg = Release|Win32
{3F7198C7-68D1-4BBA-9BF2-B7FC67A9426E}.SOCKET_Release|x86.Build.0 = Release|Win32
{C0FC8DAB-0590-46AC-9270-6FEA45D52390}.Debug|Any CPU.ActiveCfg = Debug|Win32
{C0FC8DAB-0590-46AC-9270-6FEA45D52390}.Debug|x64.ActiveCfg = Debug|x64
{C0FC8DAB-0590-46AC-9270-6FEA45D52390}.Debug|x64.Build.0 = Debug|x64
......@@ -102,30 +67,6 @@ Global
{C0FC8DAB-0590-46AC-9270-6FEA45D52390}.SOCKET_Release|x64.Build.0 = SOCKET_Release|x64
{C0FC8DAB-0590-46AC-9270-6FEA45D52390}.SOCKET_Release|x86.ActiveCfg = SOCKET_Release|Win32
{C0FC8DAB-0590-46AC-9270-6FEA45D52390}.SOCKET_Release|x86.Build.0 = SOCKET_Release|Win32
{10504CFA-6D19-4A97-8728-11BCE6C2499F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{10504CFA-6D19-4A97-8728-11BCE6C2499F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10504CFA-6D19-4A97-8728-11BCE6C2499F}.Debug|x64.ActiveCfg = Debug|Any CPU
{10504CFA-6D19-4A97-8728-11BCE6C2499F}.Debug|x64.Build.0 = Debug|Any CPU
{10504CFA-6D19-4A97-8728-11BCE6C2499F}.Debug|x86.ActiveCfg = Debug|Any CPU
{10504CFA-6D19-4A97-8728-11BCE6C2499F}.Debug|x86.Build.0 = Debug|Any CPU
{10504CFA-6D19-4A97-8728-11BCE6C2499F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10504CFA-6D19-4A97-8728-11BCE6C2499F}.Release|Any CPU.Build.0 = Release|Any CPU
{10504CFA-6D19-4A97-8728-11BCE6C2499F}.Release|x64.ActiveCfg = Release|Any CPU
{10504CFA-6D19-4A97-8728-11BCE6C2499F}.Release|x64.Build.0 = Release|Any CPU
{10504CFA-6D19-4A97-8728-11BCE6C2499F}.Release|x86.ActiveCfg = Release|Any CPU
{10504CFA-6D19-4A97-8728-11BCE6C2499F}.Release|x86.Build.0 = Release|Any CPU
{10504CFA-6D19-4A97-8728-11BCE6C2499F}.SOCKET_DEBUG|Any CPU.ActiveCfg = Release|Any CPU
{10504CFA-6D19-4A97-8728-11BCE6C2499F}.SOCKET_DEBUG|Any CPU.Build.0 = Release|Any CPU
{10504CFA-6D19-4A97-8728-11BCE6C2499F}.SOCKET_DEBUG|x64.ActiveCfg = Release|Any CPU
{10504CFA-6D19-4A97-8728-11BCE6C2499F}.SOCKET_DEBUG|x64.Build.0 = Release|Any CPU
{10504CFA-6D19-4A97-8728-11BCE6C2499F}.SOCKET_DEBUG|x86.ActiveCfg = Release|Any CPU
{10504CFA-6D19-4A97-8728-11BCE6C2499F}.SOCKET_DEBUG|x86.Build.0 = Release|Any CPU
{10504CFA-6D19-4A97-8728-11BCE6C2499F}.SOCKET_Release|Any CPU.ActiveCfg = Release|Any CPU
{10504CFA-6D19-4A97-8728-11BCE6C2499F}.SOCKET_Release|Any CPU.Build.0 = Release|Any CPU
{10504CFA-6D19-4A97-8728-11BCE6C2499F}.SOCKET_Release|x64.ActiveCfg = Release|Any CPU
{10504CFA-6D19-4A97-8728-11BCE6C2499F}.SOCKET_Release|x64.Build.0 = Release|Any CPU
{10504CFA-6D19-4A97-8728-11BCE6C2499F}.SOCKET_Release|x86.ActiveCfg = Release|Any CPU
{10504CFA-6D19-4A97-8728-11BCE6C2499F}.SOCKET_Release|x86.Build.0 = Release|Any CPU
{B8740C2A-CBE7-4873-9669-E0DFEC4A3B8D}.Debug|Any CPU.ActiveCfg = Debug|Win32
{B8740C2A-CBE7-4873-9669-E0DFEC4A3B8D}.Debug|x64.ActiveCfg = Debug|x64
{B8740C2A-CBE7-4873-9669-E0DFEC4A3B8D}.Debug|x64.Build.0 = Debug|x64
......@@ -152,11 +93,6 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{9533FA77-5AB8-473D-83D5-55E07137401E} = {8E5B7B88-AB21-4B97-BAC1-956A35E33671}
{4DE1F624-3F17-44E8-9B1F-28D88285D25F} = {8E5B7B88-AB21-4B97-BAC1-956A35E33671}
{10504CFA-6D19-4A97-8728-11BCE6C2499F} = {4DE1F624-3F17-44E8-9B1F-28D88285D25F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {20BD2B3B-13AA-4C38-8216-127895041F93}
EndGlobalSection
......
......@@ -140,12 +140,14 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetName>$(ProjectName)</TargetName>
<CopyLocalDeploymentContent>true</CopyLocalDeploymentContent>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='SOCKET_Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetName>SWeChatRobot</TargetName>
<IntDir>$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)Release\socket\</OutDir>
<CopyLocalDeploymentContent>true</CopyLocalDeploymentContent>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
......@@ -208,6 +210,10 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
<PostBuildEvent>
<Command>xcopy /y /d "$(TargetPath)" "$(SolutionDir)build\com\"
xcopy /y /d "$(OutDir)..\Python\com\wxRobot.py" "$(SolutionDir)build\com\"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='SOCKET_Release|Win32'">
<ClCompile>
......@@ -228,6 +234,10 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
<PostBuildEvent>
<Command>xcopy /y /d "$(TargetPath)" "$(SolutionDir)build\http\"
xcopy /y /d "$(OutDir)..\..\Python\http\wxDriver.py" "$(SolutionDir)build\http\"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
......
......@@ -142,7 +142,7 @@ static void dealMessage(DWORD messageAddr)
string jstr = jMsg.dump() + '\n';
#ifdef USE_COM
// 通过连接点,将消息广播给客户端
VARIANT vsaValue = (_variant_t)jstr.c_str();
VARIANT vsaValue = (_variant_t)utf8_to_unicode(jstr.c_str()).c_str();
PostComMessage(jMsg["pid"].get<int>(), WX_MESSAGE, msgid, &vsaValue);
#endif
// 为保证线程安全,需要手动管理内存
......
comtypes==1.1.11
psutil==5.9.0
\ No newline at end of file
comtypes==1.1.11
psutil==5.9.0
import ctypes
import json
import copy
import threading
import requests
import base64
import socketserver
if ctypes.sizeof(ctypes.c_void_p) == ctypes.sizeof(ctypes.c_ulonglong):
driver = ctypes.cdll.LoadLibrary('./wxDriver64.dll')
else:
driver = ctypes.cdll.LoadLibrary('./wxDriver.dll')
new_wechat = driver.new_wechat
new_wechat.argtypes = None
new_wechat.restype = ctypes.c_int
start_listen = driver.start_listen
start_listen.argtypes = [ctypes.c_int,ctypes.c_int]
start_listen.restype = ctypes.c_int
stop_listen = driver.stop_listen
stop_listen.argtypes = [ctypes.c_int]
stop_listen.restype = ctypes.c_int
class WECHAT_HTTP_APIS:
# login check
WECHAT_IS_LOGIN = 0 # 登录检查
# self info
WECHAT_GET_SELF_INFO = 1 # 获取个人信息
# send message
WECHAT_MSG_SEND_TEXT = 2 # 发送文本
WECHAT_MSG_SEND_AT = 3 # 发送群艾特
WECHAT_MSG_SEND_CARD = 4 # 分享好友名片
WECHAT_MSG_SEND_IMAGE = 5 # 发送图片
WECHAT_MSG_SEND_FILE = 6 # 发送文件
WECHAT_MSG_SEND_ARTICLE = 7 # 发送xml文章
WECHAT_MSG_SEND_APP = 8 # 发送小程序
# receive message
WECHAT_MSG_START_HOOK = 9 # 开启接收消息HOOK,只支持socket监听
WECHAT_MSG_STOP_HOOK = 10 # 关闭接收消息HOOK
WECHAT_MSG_START_IMAGE_HOOK = 11 # 开启图片消息HOOK
WECHAT_MSG_STOP_IMAGE_HOOK = 12 # 关闭图片消息HOOK
WECHAT_MSG_START_VOICE_HOOK = 13 # 开启语音消息HOOK
WECHAT_MSG_STOP_VOICE_HOOK = 14 # 关闭语音消息HOOK
# contact
WECHAT_CONTACT_GET_LIST = 15 # 获取联系人列表
WECHAT_CONTACT_CHECK_STATUS = 16 # 检查是否被好友删除
WECHAT_CONTACT_DEL = 17 # 删除好友
WECHAT_CONTACT_SEARCH_BY_CACHE = 18 # 从内存中获取好友信息
WECHAT_CONTACT_SEARCH_BY_NET = 19 # 网络搜索用户信息
WECHAT_CONTACT_ADD_BY_WXID = 20 # wxid加好友
WECHAT_CONTACT_ADD_BY_V3 = 21 # v3数据加好友
WECHAT_CONTACT_ADD_BY_PUBLIC_ID = 22 # 关注公众号
WECHAT_CONTACT_VERIFY_APPLY = 23 # 通过好友请求
WECHAT_CONTACT_EDIT_REMARK = 24 # 修改备注
# chatroom
WECHAT_CHATROOM_GET_MEMBER_LIST = 25 # 获取群成员列表
WECHAT_CHATROOM_GET_MEMBER_NICKNAME = 26 # 获取指定群成员昵称
WECHAT_CHATROOM_DEL_MEMBER = 27 # 删除群成员
WECHAT_CHATROOM_ADD_MEMBER = 28 # 添加群成员
WECHAT_CHATROOM_SET_ANNOUNCEMENT = 29 # 设置群公告
WECHAT_CHATROOM_SET_CHATROOM_NAME = 30 # 设置群聊名称
WECHAT_CHATROOM_SET_SELF_NICKNAME = 31 # 设置群内个人昵称
# database
WECHAT_DATABASE_GET_HANDLES = 32 # 获取数据库句柄
WECHAT_DATABASE_BACKUP = 33 # 备份数据库
WECHAT_DATABASE_QUERY = 34 # 数据库查询
# version
WECHAT_SET_VERSION = 35 # 修改微信版本号
# log
WECHAT_LOG_START_HOOK = 36 # 开启日志信息HOOK
WECHAT_LOG_STOP_HOOK = 37 # 关闭日志信息HOOK
APIS = WECHAT_HTTP_APIS
# http api 参数模板
class WECHAT_HTTP_API_PARAM_TEMPLATES:
__HTTP_API_PARAM_TEMPLATE = {
# login check
APIS.WECHAT_IS_LOGIN: {},
# self info
APIS.WECHAT_GET_SELF_INFO: {},
# send message
APIS.WECHAT_MSG_SEND_TEXT: {"wxid": "",
"msg": ""},
# wxids需要以`,`分隔,例如`wxid1,wxid2,wxid3`
APIS.WECHAT_MSG_SEND_AT: {"chatroom_id":"",
"wxids": "",
"msg": "",
"auto_nickname": 1},
APIS.WECHAT_MSG_SEND_CARD: {"receiver":"",
"shared_wxid":"",
"nickname":""},
APIS.WECHAT_MSG_SEND_IMAGE: {"receiver":"",
"img_path":""},
APIS.WECHAT_MSG_SEND_FILE: {"receiver":"",
"file_path":""},
APIS.WECHAT_MSG_SEND_ARTICLE: {"wxid":"",
"title":"",
"abstract":"",
"url":"",
"img_path":""},
APIS.WECHAT_MSG_SEND_APP: {"wxid":"",
"appid":""},
# receive message
APIS.WECHAT_MSG_START_HOOK: {"port": 10808},
APIS.WECHAT_MSG_STOP_HOOK: {},
APIS.WECHAT_MSG_START_IMAGE_HOOK: {"save_path":""},
APIS.WECHAT_MSG_STOP_IMAGE_HOOK: {},
APIS.WECHAT_MSG_START_VOICE_HOOK: {"save_path":""},
APIS.WECHAT_MSG_STOP_VOICE_HOOK: {},
# contact
APIS.WECHAT_CONTACT_GET_LIST: {},
APIS.WECHAT_CONTACT_CHECK_STATUS: {"wxid":""},
APIS.WECHAT_CONTACT_DEL: {"wxid":""},
APIS.WECHAT_CONTACT_SEARCH_BY_CACHE: {"wxid":""},
APIS.WECHAT_CONTACT_SEARCH_BY_NET: {"keyword":""},
APIS.WECHAT_CONTACT_ADD_BY_WXID: {"wxid":"",
"msg":""},
APIS.WECHAT_CONTACT_ADD_BY_V3: {"v3":"",
"msg":"",
"add_type": 0x6},
APIS.WECHAT_CONTACT_ADD_BY_PUBLIC_ID: {"public_id":""},
APIS.WECHAT_CONTACT_VERIFY_APPLY: {"v3":"",
"v4":""},
APIS.WECHAT_CONTACT_EDIT_REMARK: {"wxid":"",
"remark":""},
# chatroom
APIS.WECHAT_CHATROOM_GET_MEMBER_LIST: {"chatroom_id":""},
APIS.WECHAT_CHATROOM_GET_MEMBER_NICKNAME: {"chatroom_id":"",
"wxid":""},
# wxids需要以`,`分隔,例如`wxid1,wxid2,wxid3`
APIS.WECHAT_CHATROOM_DEL_MEMBER: {"chatroom_id":"",
"wxids":""},
# wxids需要以`,`分隔,例如`wxid1,wxid2,wxid3`
APIS.WECHAT_CHATROOM_ADD_MEMBER: {"chatroom_id":"",
"wxids":""},
APIS.WECHAT_CHATROOM_SET_ANNOUNCEMENT: {"chatroom_id":"",
"announcement":""},
APIS.WECHAT_CHATROOM_SET_CHATROOM_NAME: {"chatroom_id":"",
"chatroom_name":""},
APIS.WECHAT_CHATROOM_SET_SELF_NICKNAME: {"chatroom_id":"",
"nickname":""},
# database
APIS.WECHAT_DATABASE_GET_HANDLES: {},
APIS.WECHAT_DATABASE_BACKUP: {"db_handle":0,
"save_path":""},
APIS.WECHAT_DATABASE_QUERY: {"db_handle":0,
"sql":""},
# version
APIS.WECHAT_SET_VERSION: {"version": "3.7.0.30"},
# log
APIS.WECHAT_LOG_START_HOOK: {},
APIS.WECHAT_LOG_STOP_HOOK: {},
}
def get_http_template(self, api_number):
try:
return copy.deepcopy(self.__HTTP_API_PARAM_TEMPLATE[api_number])
except KeyError:
raise ValueError("There is no interface numbered %s." % api_number)
get_http_template = WECHAT_HTTP_API_PARAM_TEMPLATES().get_http_template
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.decode('utf-8'))
ReceiveMsgSocketServer.msg_callback(msg)
except OSError:
break
except json.JSONDecodeError:
pass
conn.sendall("200 OK".encode())
conn.close()
@staticmethod
def msg_callback(msg):
# 附加信息是protobuf格式,需要自行处理
msg['extrainfo'] = base64.b64decode(msg['extrainfo'])
# TODO: 在这里写额外的消息处理逻辑
print(msg)
def post_wechat_http_api(api,port,data = {}):
url = "http://127.0.0.1:{}/api/?type={}".format(port,api)
resp = requests.post(url = url,data = json.dumps(data))
return resp.json()
def get_wechat_http_api(api,port,data = {}):
url = "http://127.0.0.1:{}/api/?type={}".format(port,api)
resp = requests.get(url = url,params = data)
return resp.json()
def get_wechat_pid_list() -> list:
import psutil
pid_list = []
process_list = psutil.pids()
for pid in process_list:
try:
if psutil.Process(pid).name() == 'WeChat.exe':
pid_list.append(pid)
except psutil.NoSuchProcess:
pass
return pid_list
def start_socket_server(port: int = 10808,
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
def test(test_port):
post_wechat_http_api(APIS.WECHAT_LOG_START_HOOK,port = test_port)
if post_wechat_http_api(APIS.WECHAT_IS_LOGIN,port = test_port)["is_login"] == 1:
print(post_wechat_http_api(APIS.WECHAT_GET_SELF_INFO,port = test_port))
data = {"wxid":"filehelper","msg":"hello http"}
post_wechat_http_api(APIS.WECHAT_MSG_SEND_TEXT,data = data,port = test_port)
data = {"receiver":'filehelper',"shared_wxid":"filehelper","nickname":"文件传输助手"}
post_wechat_http_api(APIS.WECHAT_MSG_SEND_CARD,data = data,port = test_port)
data = {"receiver":'filehelper',"img_path":r"D:\VS2019C++\MyWeChatRobot\test\测试图片.png"}
post_wechat_http_api(APIS.WECHAT_MSG_SEND_IMAGE,data = data,port = test_port)
data = {"receiver":'filehelper',"file_path":r"D:\VS2019C++\MyWeChatRobot\test\测试文件"}
post_wechat_http_api(APIS.WECHAT_MSG_SEND_FILE,data = data,port = test_port)
data = {"wxid":'filehelper',
"title":"百度",
"abstract":"百度一下,你就知道",
"url":"https://www.baidu.com/",
"img_path":""}
post_wechat_http_api(APIS.WECHAT_MSG_SEND_ARTICLE,data = data,port = test_port)
print(post_wechat_http_api(APIS.WECHAT_CONTACT_GET_LIST,port = test_port))
data = {"wxid":"filehelper"}
print(post_wechat_http_api(APIS.WECHAT_CONTACT_CHECK_STATUS,data = data,port = test_port))
dbs = post_wechat_http_api(APIS.WECHAT_DATABASE_GET_HANDLES,port = test_port)
db_handle = dbs['data'][0]['handle']
sql = "select * from Contact limit 1;"
data = {"db_handle":db_handle,"sql":sql}
res = post_wechat_http_api(APIS.WECHAT_DATABASE_QUERY,data = data,port = test_port)
print(res)
post_wechat_http_api(APIS.WECHAT_LOG_STOP_HOOK,port = test_port)
if __name__ == '__main__':
port = 8000
pids = get_wechat_pid_list()
if len(pids) == 0:
pids.append(new_wechat())
start_listen(pids[0],port)
post_wechat_http_api(APIS.WECHAT_LOG_START_HOOK,8000)
post_wechat_http_api(APIS.WECHAT_MSG_START_HOOK,8000,{"port":10808})
start_socket_server()
stop_listen(pids[0])
......@@ -32,14 +32,14 @@ PC微信机器人,实现以下功能:
# 目录说明
`./CWeChatRobot`:COM组件的实现代码
`./DWeChatRobot`:注入的DLL实现代码,根据平台配置可编译出socket版和COM版
`./wxRobot`: 包含C#的调用示例
`./old_projects`: 包含C#的调用示例以及3.7.0.26版本的E语言调用
`./Python`:python示例和接口测试文件
`./wxDriver`:driver的实现代码,有些函数具有一定的学习意义
`./Release/CWeChatRobot.exe`:编译的COM组件
`./Release/DWeChatRobot.dll`:编译的DLL文件
`./Release/socket`:包含wxDriver.dll和socket接口的DLL
`./Release/WeChatTools.exe`:用于调试时注入或卸载DLL程序,具体参阅相关代码
# 注册COM
# 快速启动
以管理员权限执行以下命令:
```shell
# 安装
......@@ -49,11 +49,11 @@ CWeChatRobot.exe /unregserver
```
# 调用
**Python:**
参考[wxRobot.py](/Python/wxRobot.py)
参考[wxRobot.py](/Python/com/wxRobot.py)
**C#:**
参考[ComWechatRobotCsharp](https://github.com/RingoStudio/ComWechatRobotCsharp),感谢@RingoStudio 的贡献
**易语言:**
参考[ESDK](/ESDK),感谢@lovezm 的贡献
参考[ESDK](/old_projects/ESDK),感谢@lovezm 的贡献
# 更多功能
1. 尝试添加issue中的功能
......@@ -118,11 +118,11 @@ CWeChatRobot.exe /unregserver
2. 重构COM中的部分实现
## 2022.08.13
1. 现在消息HOOK内容包含消息ID
2. 完成发送消息的http接口,可参考[wxDriver.py](/Release/socket/wxDriver.py),其他接口还需要一点时间
2. 完成发送消息的http接口,可参考[wxDriver.py](/Python/http/wxDriver.py),其他接口还需要一点时间
3. 新增项目配置文件,感谢@amchii 提供的方法
## 2022.08.21
1. 所有功能http接口封装完成,可接受get、post请求
2. 提供http接口调用示例,参考[wxDriver.py](/Release/socket/wxDriver.py)
2. 提供http接口调用示例,参考[wxDriver.py](/Python/http/wxDriver.py)
## 2022.08.25
1. 接收消息格式修改为json,现在也可以获取到扩展信息,可从扩展信息中获取到文件保存路径或被艾特人wxid
2. 优化获取个人信息,获取好友信息接口
......
#include "base.h"
HANDLE hProcess = NULL;
bool isFileExists_stat(string& name) {
bool isFileExists_stat(string &name)
{
struct stat buffer;
return (stat(name.c_str(), &buffer) == 0);
}
......@@ -9,23 +10,24 @@ bool isFileExists_stat(string& name) {
string wstring2string(wstring wstr)
{
std::string result;
//获取缓冲区大小,并申请空间,缓冲区大小事按字节计算的
//获取缓冲区大小,并申请空间,缓冲区大小事按字节计算的
int len = WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), wstr.size(), NULL, 0, NULL, NULL);
char* buffer = new char[len + 1];
//宽字节编码转换成多字节编码
char *buffer = new char[len + 1];
//宽字节编码转换成多字节编码
WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), wstr.size(), buffer, len, NULL, NULL);
buffer[len] = '\0';
//删除缓冲区并返回值
//删除缓冲区并返回值
result.append(buffer);
delete[] buffer;
return result;
}
bool InjectDll(DWORD dwId, WCHAR* szPath)//参数1:目标进程PID 参数2:DLL路径
bool InjectDll(DWORD dwId, WCHAR *szPath) //参数1:目标进程PID 参数2:DLL路径
{
if (!hProcess)
return 1;
if (GetWeChatRobotBase() != 0) {
if (GetWeChatRobotBase() != 0)
{
printf("请勿重复注入\n");
return 1;
}
......@@ -44,17 +46,20 @@ bool InjectDll(DWORD dwId, WCHAR* szPath)//
{
WriteProcessMemory(hProcess, pRemoteAddress, szPath, wcslen(szPath) * 2 + 2, &dwWriteSize);
}
else {
else
{
printf("写入失败!\n");
return 1;
}
//三、 创建一个远程线程,让目标进程调用LoadLibrary
HANDLE hThread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)LoadLibrary, pRemoteAddress, NULL, NULL);
if (hThread) {
WaitForSingleObject(hThread, -1);
if (hThread)
{
WaitForSingleObject(hThread, -1);
}
else {
else
{
printf("调用失败!\n");
return 1;
}
......@@ -64,13 +69,15 @@ bool InjectDll(DWORD dwId, WCHAR* szPath)//
return 0;
}
void Inject(DWORD dwPid, wchar_t* wStr) {
void Inject(DWORD dwPid, wchar_t *wStr)
{
wchar_t dllpath[MAX_PATH];
wchar_t workPath[MAX_PATH];
wchar_t* pworkPath = _wgetcwd(workPath, MAX_PATH);
wchar_t *pworkPath = _wgetcwd(workPath, MAX_PATH);
swprintf_s(dllpath, MAX_PATH, L"%ws%ws%ws", pworkPath, L"\\", wStr);
string name = wstring2string((wstring)dllpath);
if (!isFileExists_stat(name)) {
if (!isFileExists_stat(name))
{
wstring info = L"请检查目标文件路径!";
MessageBox(NULL, info.c_str(), _T("警告"), MB_ICONWARNING);
return;
......@@ -79,38 +86,44 @@ void Inject(DWORD dwPid, wchar_t* wStr) {
InjectDll(dwPid, dllpath);
}
BOOL RemoveDll(DWORD dwId) {
BOOL RemoveDll(DWORD dwId)
{
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwId);
LPVOID pRemoteAddress = VirtualAllocEx(hProcess, NULL, 1, MEM_COMMIT, PAGE_READWRITE);
DWORD dwWriteSize = 0;
HANDLE hThread = NULL;
DWORD dwHandle, dwID;
LPVOID pFunc = NULL;
if(pRemoteAddress)
if (pRemoteAddress)
WriteProcessMemory(hProcess, pRemoteAddress, dllname, wcslen(dllname) * 2 + 2, &dwWriteSize);
else {
else
{
printf("写入失败!\n");
return 1;
}
pFunc = GetModuleHandleW;
hThread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)pFunc, pRemoteAddress, 0, &dwID);
if (hThread) {
if (hThread)
{
WaitForSingleObject(hThread, INFINITE);
GetExitCodeThread(hThread, &dwHandle);
}
else {
else
{
printf("GetModuleHandleW调用失败!\n");
return 1;
}
CloseHandle(hThread);
// 释放console窗口,不然关闭console的同时微信也会退出
pFunc = FreeConsole;
hThread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)pFunc, NULL, 0, &dwID);
if (hThread) {
if (hThread)
{
WaitForSingleObject(hThread, INFINITE);
}
else {
else
{
printf("FreeConsole调用失败!\n");
return 1;
}
......@@ -119,10 +132,12 @@ BOOL RemoveDll(DWORD dwId) {
// 使目标进程调用FreeLibrary,卸载DLL
pFunc = FreeLibrary;
hThread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)pFunc, (LPVOID)dwHandle, 0, &dwID);
if (hThread) {
if (hThread)
{
WaitForSingleObject(hThread, INFINITE);
}
else {
else
{
printf("FreeLibrary调用失败!\n");
return 1;
}
......
......@@ -151,4 +151,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
\ No newline at end of file
</Project>
......@@ -34,4 +34,4 @@
<Filter>通用函数</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>
\ No newline at end of file
</Project>
#include "base.h"
DWORD GetWeChatRobotBase() {
DWORD GetWeChatRobotBase()
{
if (!hProcess)
return 0;
DWORD dwWriteSize = 0;
......@@ -12,14 +13,16 @@ DWORD GetWeChatRobotBase() {
DWORD dwHandle, dwID;
LPVOID pFunc = GetModuleHandleW;
HANDLE hThread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)pFunc, pRemoteAddress, 0, &dwID);
if (hThread) {
if (hThread)
{
WaitForSingleObject(hThread, INFINITE);
GetExitCodeThread(hThread, &dwHandle);
}
else {
else
{
return 0;
}
CloseHandle(hThread);
VirtualFreeEx(hProcess, pRemoteAddress, 0, MEM_RELEASE);
return dwHandle;
}
\ No newline at end of file
}
......@@ -13,12 +13,12 @@
using namespace std;
void Inject(DWORD dwPid, wchar_t* wStr);
bool isFileExists_stat(string& name);
void Inject(DWORD dwPid, wchar_t *wStr);
bool isFileExists_stat(string &name);
string wstring2string(wstring wstr);
BOOL RemoveDll(DWORD dwId);
extern HANDLE hProcess;
DWORD GetWeChatRobotBase();
#define dllname L"DWeChatRobot.dll"
#define SendImageOffset 0x000110BE
\ No newline at end of file
#define SendImageOffset 0x000110BE
#include "main.h"
int _tmain(int nargv, WCHAR* argvs[])
int _tmain(int nargv, WCHAR *argvs[])
{
DWORD dwId = 0;
HWND hCalc = FindWindow(NULL, L"微信");
DWORD dwPid = 0;
DWORD dwRub = GetWindowThreadProcessId(hCalc, &dwPid);
if (!dwPid) {
if (!dwPid)
{
wstring info = L"请先启动目标进程!";
MessageBox(NULL, info.c_str(), _T("警告"), MB_ICONWARNING);
return 1;
}
wchar_t* wStr = NULL;
if (nargv == 1) {
wchar_t *wStr = NULL;
if (nargv == 1)
{
return 1;
}
else if (nargv == 2) {
else if (nargv == 2)
{
wStr = argvs[1];
Inject(dwPid, argvs[1]);
}
else if (nargv == 3 && !((wstring)argvs[1]).compare(L"-r")) {
else if (nargv == 3 && !((wstring)argvs[1]).compare(L"-r"))
{
wStr = argvs[2];
RemoveDll(dwPid);
}
return 0;
}
\ No newline at end of file
}
#pragma once
#include "base.h"
\ No newline at end of file
#include "base.h"
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
\ No newline at end of file
</configuration>
......@@ -83,10 +83,9 @@ namespace wxRobot
wx.CStopReceiveMessage();
}
System.Object[,,] FriendList = wx.CGetFriendList() as System.Object[,,];
int length = FriendList.GetLength(0);
for (int i = 0; i < 1/*length*/; i++)
for (int i = 0; i < 1 /*length*/; i++)
{
Console.WriteLine(FriendList[i, 1, 1]);
}
......@@ -126,7 +125,6 @@ namespace wxRobot
Subscription = 3,
}
public class WxUserInfo
{
/// <summary>
......
......@@ -5,24 +5,24 @@ using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("wxRobot")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("wxRobot")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly:AssemblyTitle("wxRobot")]
[assembly:AssemblyDescription("")]
[assembly:AssemblyConfiguration("")]
[assembly:AssemblyCompany("")]
[assembly:AssemblyProduct("wxRobot")]
[assembly:AssemblyCopyright("Copyright © 2022")]
[assembly:AssemblyTrademark("")]
[assembly:AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
[assembly:ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("10504cfa-6d19-4a97-8728-11bce6c2499f")]
[assembly:Guid("10504cfa-6d19-4a97-8728-11bce6c2499f")]
// 程序集的版本信息由下列四个值组成:
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
......@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly:AssemblyVersion("1.0.0.0")]
[assembly:AssemblyFileVersion("1.0.0.0")]
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
</packages>
\ No newline at end of file
</packages>
......@@ -65,4 +65,4 @@
</COMReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
</Project>
......@@ -79,6 +79,7 @@
<LinkIncremental>false</LinkIncremental>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
<OutDir>$(SolutionDir)$(Configuration)\socket\</OutDir>
<CopyLocalProjectReference>true</CopyLocalProjectReference>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
......@@ -89,6 +90,7 @@
<LinkIncremental>false</LinkIncremental>
<TargetName>$(ProjectName)64</TargetName>
<OutDir>$(SolutionDir)$(Configuration)\socket\</OutDir>
<CopyLocalProjectReference>true</CopyLocalProjectReference>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
......@@ -123,6 +125,10 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
<PostBuildEvent>
<Command>xcopy /y /d "$(TargetPath)" "$(SolutionDir)build\http\"
xcopy /y /d "$(OutDir)$(TargetName).lib" "$(SolutionDir)build\http\"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
......@@ -157,6 +163,10 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
<PostBuildEvent>
<Command>xcopy /y /d "$(TargetPath)" "$(SolutionDir)build\http\"
xcopy /y /d "$(OutDir)$(TargetName).lib" "$(SolutionDir)build\http\"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="driver.h" />
......@@ -182,4 +192,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
\ No newline at end of file
</Project>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册