Skip to content

Commit

Permalink
新增四个功能和修复bug 详情请查看README
Browse files Browse the repository at this point in the history
  • Loading branch information
GuiShou committed Sep 18, 2019
1 parent b9df063 commit 7e64b74
Show file tree
Hide file tree
Showing 33 changed files with 382 additions and 27 deletions.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[TOC]

## 注意

最近很多人吐槽说项目代码问题太多,我后面会开始陆续完善和修复bug,并且不定期增加新功能。
Expand Down Expand Up @@ -43,6 +45,14 @@
2. 聊天记录本地备份
3. 将成品编译方式修改为静态编译 无需安装VS环境

### 2019-9-18

1. 新增打开浏览器功能
2. 新增微信收款语音到账提示
3. 新增对邀请和移除群聊消息的解析(群成员邀请统计功能雏形)
4. 新增保存联系人到文本*(菜单->设置->保存联系人)
5. 修复图片解密失败bug

## 实现功能

![WeChatHelper](assets/WeChatHelper.png)
Expand Down Expand Up @@ -138,10 +148,4 @@ PC微信逆向:两种姿势教你解密数据库文件:https://blog.csdn.net

## 声明

**本项目仅供技术研究,请勿用于任何商业用途,请勿用于非法用途,如有任何人凭此做何非法事情,均于作者无关,特此声明。**

## 项目地址

https://github.com/TonyChen56/WeChatRobot

开源不易,求个star
**本项目仅供技术研究,请勿用于任何商业用途,请勿用于非法用途,如有任何人凭此做何非法事情,均于作者无关,特此声明。**
Binary file added 成品/Debug/WeChatHelper.dll
Binary file not shown.
Binary file added 成品/Debug/WeChatRobot.exe
Binary file not shown.
Binary file added 成品/Debug/微信收款音效.mp3
Binary file not shown.
Binary file added 成品/Release/WeChatHelper.dll
Binary file not shown.
Binary file not shown.
Binary file added 成品/Release/微信收款音效.mp3
Binary file not shown.
Binary file removed 成品/WeChatHelper.dll
Binary file not shown.
25 changes: 23 additions & 2 deletions 源码/WeChatHelper/WeChatHelper/ChatRecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "ChatRecord.h"
#include "FriendList.h"
#include "CAutoFunction.h"
#include <stdio.h>
#pragma comment(lib,"Shlwapi.lib")
using namespace std;

Expand Down Expand Up @@ -34,6 +35,7 @@ struct Message
wchar_t wxid[40]; //微信ID/群ID
wchar_t msgSender[40]; //消息发送者
wchar_t content[200]; //消息内容
BOOL isMoney = FALSE; //是否是收款消息
};


Expand Down Expand Up @@ -169,6 +171,7 @@ void SendWxMessage()
//文件
//转账
//链接
//收款
memcpy(msg->type, L"共享实时位置、文件、转账、链接", sizeof(L"共享实时位置、文件、转账、链接"));
isOther = TRUE;
break;
Expand Down Expand Up @@ -228,7 +231,6 @@ void SendWxMessage()
LPVOID pWxid = *((LPVOID *)(**msgAddress + 0x40));
swprintf_s(msg->wxid, L"%s", (wchar_t*)pWxid);


//如果是群消息
if (isFriendMsg == FALSE)
{
Expand Down Expand Up @@ -277,6 +279,12 @@ void SendWxMessage()
isSendTuLing = FALSE;
}
}
//如果微信ID为gh_3dfda90e39d6 说明是收款消息
else if ((StrCmpW(msg->wxid, L"gh_3dfda90e39d6") == 0))
{
swprintf_s(msg->content, L"%s", L"微信收款到账");
msg->isMoney = TRUE;
}
else
{
//如果微信ID中带有gh 说明是公众号
Expand Down Expand Up @@ -348,7 +356,20 @@ void SendWxMessage()
}
else if (isSystemMessage == TRUE)
{
swprintf_s(msg->content, L"%s", L"收到红包或系统消息,请在手机上查看");
wchar_t tempbuff[0x1000];
LPVOID pContent = *((LPVOID *)(**msgAddress + 0x68));
swprintf_s(tempbuff, L"%s", (wchar_t*)pContent);

//在这里处理加入群聊消息
if ((StrStrW(tempbuff, L"移出了群聊")||StrStrW(tempbuff, L"加入了群聊")))
{
wcscpy_s(msg->content, wcslen(tempbuff) + 1, tempbuff);
}
else
{
swprintf_s(msg->content, L"%s", L"收到红包或系统消息,请在手机上查看");
}

}
//过滤完所有消息之后
else
Expand Down
81 changes: 81 additions & 0 deletions 源码/WeChatHelper/WeChatHelper/FriendList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,4 +560,85 @@ void SendXmlCard(wchar_t* RecverWxid, wchar_t* SendWxid, wchar_t* NickName)
call callAdd
add esp, 0xC
}
}



//************************************************************
// 函数名称: wstringToString
// 函数说明: 将wstring转成String
// 作 者: GuiShou
// 时 间: 2019/9/17
// 参 数: wstr
// 返 回 值: string
//************************************************************
std::string wstringToString(const std::wstring& wstr)
{
LPCWSTR pwszSrc = wstr.c_str();
int nLen = WideCharToMultiByte(CP_ACP, 0, pwszSrc, -1, NULL, 0, NULL, NULL);
if (nLen == 0)
return std::string("");

char* pszDst = new char[nLen];
if (!pszDst)
return std::string("");

WideCharToMultiByte(CP_ACP, 0, pwszSrc, -1, pszDst, nLen, NULL, NULL);
std::string str(pszDst);
delete[] pszDst;
pszDst = NULL;

return str;
}


//************************************************************
// 函数名称: SaveToTxtFie
// 函数说明: 保存好友列表到文件
// 作 者: GuiShou
// 时 间: 2019/9/17
// 参 数: void
// 返 回 值: void
//************************************************************
void SaveToTxtFie()
{
wstring wxUserFileName = L"WxUserLists.txt";

DWORD index = 0;

//作为输出文件打开
ofstream ofile;
ofile.open(wxUserFileName, ios_base::trunc | ios_base::binary | ios_base::in);

for (auto& userInfoOld : userInfoList)
{
wstring wxid1 = get<0>(userInfoOld);
wstring wxName = get<1>(userInfoOld);
wstring nickName = get<3>(userInfoOld);

if (wxid1 == L"" && wxName == L"" && nickName == L"") continue;

index++;

wstring userText = L"";
userText.append(to_wstring(index))
.append(L"\t")
.append(wxid1)
.append(L"\t")
.append(wxName)
.append(L"\t")
.append(nickName)
.append(L"\r\n");


string strintStr = wstringToString(userText);
char const* pos = (char const*)strintStr.c_str();

////写入文件
ofile.write(pos, strintStr.length());

}
ofile.flush();
ofile.close();
ShellExecute(NULL, NULL, L"notepad.exe", wxUserFileName.c_str(), L".\\", SW_SHOW);
}
3 changes: 3 additions & 0 deletions 源码/WeChatHelper/WeChatHelper/FriendList.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include <string>

void HookGetFriendList(); //HOOK获取好友列表的call
void GetUserListInfo(); //获取好友列表
Expand All @@ -9,4 +10,6 @@
void SendImageMessage(wchar_t* wxid, wchar_t* filepath);//发送图片消息
void DeleteUser(wchar_t* wxid); //删除好友
void SendXmlCard(wchar_t* RecverWxid, wchar_t* SendWxid, wchar_t* NickName); //发送XML名片
void SaveToTxtFie(); //保存联系人到文件
std::string wstringToString(const std::wstring& wstr);

42 changes: 42 additions & 0 deletions 源码/WeChatHelper/WeChatHelper/Function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,46 @@ void AntiRevoke()

//恢复属性
VirtualProtect((LPVOID)dwPathcAddr, 5, dwOldAttr, &dwOldAttr);
}

//************************************************************
// 函数名称: OpenUrl
// 函数说明: 打开微信浏览器
// 作 者: GuiShou
// 时 间: 2019/9/10
// 参 数: void
// 返 回 值: void
//************************************************************
void OpenUrl(wchar_t * Url)
{
struct wechatText
{
wchar_t* pStr;
int strLen;
int iStrLen;

};


wechatText pUrl = { 0 };
pUrl.pStr = Url;
pUrl.strLen = wcslen(Url);
pUrl.iStrLen = wcslen(Url) * 2;
char* asmpUrl = (char*)&pUrl.pStr;
DWORD dwWeChatWinAddr = (DWORD)GetModuleHandle(L"WeChatWin.dll");
DWORD callAdd1 = dwWeChatWinAddr + 0x481900;
DWORD callAdd2 = dwWeChatWinAddr + 0x67C060;
__asm {
pushad
sub esp, 0x14
mov eax, asmpUrl
mov ecx, esp
push eax
call callAdd1
call callAdd2
add esp, 0x14
popad
}


}
3 changes: 1 addition & 2 deletions 源码/WeChatHelper/WeChatHelper/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
wchar_t * UTF8ToUnicode(const char* str); //将UTF8编码转为Unicode(微信默认编码为UTF8)
void AddWxUser(wchar_t* wxid, wchar_t* msg); //添加好友
void AntiRevoke(); //防撤回


void OpenUrl(wchar_t * Url); //打开微信浏览器


5 changes: 3 additions & 2 deletions 源码/WeChatHelper/WeChatHelper/WeChatHelper.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
Expand Down Expand Up @@ -115,12 +115,13 @@
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<Optimization>Disabled</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;WECHATHELPER_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down
13 changes: 13 additions & 0 deletions 源码/WeChatHelper/WeChatHelper/WndMsgLoop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,19 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
DelRoomMember(msg->roomid, msg->memberwxid);
}
break;
//打开URL
case WM_OpenUrl:
{
OpenUrl((wchar_t*)pCopyData->lpData);
}
break;
//保存联系人
case WM_SaveFriendList:
{
SaveToTxtFie();
}
break;

default:
break;
}
Expand Down
2 changes: 2 additions & 0 deletions 源码/WeChatHelper/WeChatHelper/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@
#define WM_AlreadyLogin 21
#define WM_SendAtMsg 22
#define WM_DelRoomMember 23
#define WM_OpenUrl 24
#define WM_SaveFriendList 25
21 changes: 18 additions & 3 deletions 源码/WeChatRobot/WeChatRobot/CChatRecords.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "WeChatRobot.h"
#include "CChatRecords.h"
#include "afxdialogex.h"

#include "stdafx.h"
#include "WeChatRobot.h"
#include "CChatRecords.h"
Expand All @@ -21,8 +20,9 @@
#include <windows.h>
#include "Wininet.h"
#pragma comment(lib,"Wininet.lib")

#include <fstream>
#include <mmsystem.h> //多媒体播放所需的头文件
#pragma comment(lib,"winmm.lib") //多媒体播放所需的库文件

DWORD g_index=0;

Expand Down Expand Up @@ -77,7 +77,6 @@ wchar_t * StringToWchar_t(const std::string & str)
wchar_t * m_chatroommmsg = new wchar_t[str.size() * 2]; //
memset(m_chatroommmsg, 0, str.size() * 2);
setlocale(LC_ALL, "zh_CN.UTF-8");
//setlocale(LC_CTYPE, "chs");
swprintf(m_chatroommmsg, str.size() * 2, L"%S", str.c_str());

return m_chatroommmsg;
Expand Down Expand Up @@ -130,6 +129,7 @@ struct Message
wchar_t wxid[40]; //微信ID/群ID
wchar_t msgSender[40]; //消息发送者
wchar_t content[200]; //消息内容
BOOL isMoney = FALSE; //是否是收款消息
};


Expand Down Expand Up @@ -206,6 +206,21 @@ afx_msg LRESULT CChatRecords::OnShowmessage(WPARAM wParam, LPARAM lParam)
m_ChatRecord.SetItemText(g_index, 3, msg->msgSender);
m_ChatRecord.SetItemText(g_index, 4, msg->content);

if (msg->isMoney==TRUE)
{
//如果是收款消息 播放音效
if (GetFileAttributesA("微信收款音效.mp3")==INVALID_FILE_ATTRIBUTES)
{
MessageBoxA(NULL, "未找到微信收款音效文件 无法播放语音提示", "Tip", 0);
}
else
{
mciSendString(L"open 微信收款音效.mp3", 0, 0, 0);
mciSendString(L"play 微信收款音效.mp3", 0, 0, 0);
}

}

std::string type = Wchar_tToString(msg->type);
std::string wxid = Wchar_tToString(msg->wxid);
std::string source = Wchar_tToString(msg->source);
Expand Down
4 changes: 3 additions & 1 deletion 源码/WeChatRobot/WeChatRobot/CDecryptImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ void CDecryptImage::OnBnClickedDecryptimage()
MessageBox(L"图片不存在 请重试");
return;
}
UpdateData(TRUE);

//检测密钥是否存在
if (m_key=="")
{
Expand Down Expand Up @@ -99,7 +101,7 @@ void CDecryptImage::OnBnClickedDecryptimage()
MessageBoxA(NULL, "读取文件失败", "错误", 0);
return;
}
UpdateData(TRUE);

unsigned int hexkey = 0;
USES_CONVERSION;
sscanf_s(W2A(m_key), "%x", &hexkey);
Expand Down
Loading

0 comments on commit 7e64b74

Please sign in to comment.