forked from zmrbak/PcWeChatHooK
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
361 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.29209.152 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "L069", "L069\L069.csproj", "{8A78B2DB-4F20-4866-BE5C-7A1913A66166}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{8A78B2DB-4F20-4866-BE5C-7A1913A66166}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{8A78B2DB-4F20-4866-BE5C-7A1913A66166}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{8A78B2DB-4F20-4866-BE5C-7A1913A66166}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{8A78B2DB-4F20-4866-BE5C-7A1913A66166}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {96D54C3A-D0F3-4C63-81DA-B3755B74DF76} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{8A78B2DB-4F20-4866-BE5C-7A1913A66166}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>L069</RootNamespace> | ||
<AssemblyName>L069</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="WxRoomList.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace L069 | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
WxRoomList wxRoomList = new WxRoomList(); | ||
wxRoomList.GetData(); | ||
|
||
Console.ReadLine(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// 有关程序集的一般信息由以下 | ||
// 控制。更改这些特性值可修改 | ||
// 与程序集关联的信息。 | ||
[assembly: AssemblyTitle("L069")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("L069")] | ||
[assembly: AssemblyCopyright("Copyright © 2019")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// 将 ComVisible 设置为 false 会使此程序集中的类型 | ||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 | ||
//请将此类型的 ComVisible 特性设置为 true。 | ||
[assembly: ComVisible(false)] | ||
|
||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID | ||
[assembly: Guid("8a78b2db-4f20-4866-be5c-7a1913a66166")] | ||
|
||
// 程序集的版本信息由下列四个值组成: | ||
// | ||
// 主版本 | ||
// 次版本 | ||
// 生成号 | ||
// 修订号 | ||
// | ||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 | ||
//通过使用 "*",如下所示: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,221 @@ | ||
using Microsoft.Win32; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace L069 | ||
{ | ||
public class WxRoomList | ||
{ | ||
Process wxProcess = null; | ||
int weChatBaseAdress = 0; | ||
int roomLinkOffset = 0x126E0A0; | ||
List<int> nodeAddressList = new List<int>(); | ||
int index = 0; | ||
public void GetData() | ||
{ | ||
WeChatStart(); | ||
WeChatCheck(); | ||
|
||
int linkPointer = GetWxMemoryInt(wxProcess.Handle, weChatBaseAdress + roomLinkOffset) + 0x678 + 0x64; | ||
Console.WriteLine("链表指针:\t0x" + linkPointer.ToString("X8")); | ||
Console.WriteLine("#######################################################"); | ||
|
||
GetLinkData(linkPointer); | ||
} | ||
|
||
private void GetLinkData(int LinkHeader) | ||
{ | ||
//群链表地址 | ||
int headerAddress = GetWxMemoryInt(wxProcess.Handle, LinkHeader); | ||
Console.WriteLine("头地址:\t0x" + headerAddress.ToString("X8")); | ||
if (headerAddress == 0) | ||
{ | ||
Console.WriteLine("请先登录微信"); | ||
return; | ||
} | ||
|
||
//群数量 | ||
int contractCount = GetWxMemoryInt(wxProcess.Handle, LinkHeader + 4); | ||
Console.WriteLine("节点数量:\t0x" + contractCount.ToString("X8")); | ||
nodeAddressList.Add(headerAddress); | ||
|
||
Console.WriteLine("#######################################################"); | ||
int header1 = GetWxMemoryInt(wxProcess.Handle, headerAddress); | ||
int header2 = GetWxMemoryInt(wxProcess.Handle, headerAddress + 4); | ||
int header3 = GetWxMemoryInt(wxProcess.Handle, headerAddress + 8); | ||
|
||
Console.WriteLine("分支1:\t\t0x" + header1.ToString("X8")); | ||
Console.WriteLine("分支2:\t\t0x" + header2.ToString("X8")); | ||
Console.WriteLine("分支3:\t\t0x" + header3.ToString("X8")); | ||
Console.WriteLine("#######################################################"); | ||
|
||
GetRoomInfo(header1, "0x" + headerAddress.ToString("X8")); | ||
GetRoomInfo(header2, "0x" + headerAddress.ToString("X8")); | ||
GetRoomInfo(header3, "0x" + headerAddress.ToString("X8")); | ||
} | ||
|
||
private void GetRoomInfo(int roomAddress, string log) | ||
{ | ||
foreach (var item in nodeAddressList) | ||
{ | ||
if (item == roomAddress) return; | ||
} | ||
nodeAddressList.Add(roomAddress); | ||
|
||
index++; | ||
Console.WriteLine("---------------" + index + "------------------"); | ||
log = log + "->" + "0x" + roomAddress.ToString("X8"); | ||
Console.WriteLine(log); | ||
|
||
//$ ==> 0C5F5360 | ||
int header1 = GetWxMemoryInt(wxProcess.Handle, roomAddress); | ||
//$+4 > 10D3C4A8 | ||
int header2 = GetWxMemoryInt(wxProcess.Handle, roomAddress + 4); | ||
//$+8 > 0C5F5360 | ||
int header3 = GetWxMemoryInt(wxProcess.Handle, roomAddress + 8); | ||
//$+C > 00000001 | ||
//$+10 > 10D5E720 UNICODE "10048068352@chatroom" | ||
//$+14 > 00000014 | ||
//$+18 > 00000020 | ||
String roomWxId = GetWxMemoryUnicodeString( | ||
wxProcess.Handle, | ||
GetWxMemoryInt(wxProcess.Handle, roomAddress + 0x10), | ||
GetWxMemoryInt(wxProcess.Handle, roomAddress + 0x14) | ||
); | ||
Console.WriteLine("群wxid:\t" + roomWxId); | ||
//$+1C > 00000000 | ||
//$+20 > 00000000 | ||
//$+24 > 0000400C | ||
//$+28 > 10D5E7C0 UNICODE "10048068352@chatroom" | ||
//$+2C > 00000014 | ||
//$+30 > 00000020 | ||
//$+34 > 00000000 | ||
//$+38 > 00000000 | ||
//$+3C > 10DBEA70 UNICODE "^Gzhaoqingming1929^Gwxid_juxacm8a5ysr22^Gwxid_2aii" | ||
//$+40 > 00000D54 | ||
//$+44 > 00001000 | ||
String wxids = GetWxMemoryUnicodeString( | ||
wxProcess.Handle, | ||
GetWxMemoryInt(wxProcess.Handle, roomAddress + 0x3c), | ||
GetWxMemoryInt(wxProcess.Handle, roomAddress + 0x40) | ||
); | ||
var wxidlist = wxids.Split(new String[] { "^G" }, StringSplitOptions.RemoveEmptyEntries); | ||
Console.WriteLine("微信群成员数量:"+ wxidlist.Length); | ||
int i = 0; | ||
foreach (var wxid in wxidlist) | ||
{ | ||
i++; | ||
Console.WriteLine("wxid\t" + i.ToString("X8") + "(" + i + ")" + "\t" + wxid); | ||
} | ||
//$+48 > 00000000 | ||
//$+4C > 00000000 | ||
//$+50 > 10D5E680 UNICODE "^G^G陈家英13071209807耶格^G陈^G" | ||
//$+54 > 00000019 | ||
//$+58 > 00000020 | ||
//$+5C > 00000000 | ||
//$+60 > 00000000 | ||
//$+64 > 00000009 | ||
//$+68 > 10D57D78 UNICODE "zhaoqingming1929" | ||
//$+6C > 00000010 | ||
//$+70 > 00000010 | ||
String roomMaster = GetWxMemoryUnicodeString( | ||
wxProcess.Handle, | ||
GetWxMemoryInt(wxProcess.Handle, roomAddress + 0x68), | ||
GetWxMemoryInt(wxProcess.Handle, roomAddress + 0x6c) | ||
); | ||
Console.WriteLine("群主wxid:\t" + roomMaster); | ||
|
||
GetRoomInfo(header1, log); | ||
GetRoomInfo(header2, log); | ||
GetRoomInfo(header3, log); | ||
} | ||
|
||
private void WeChatCheck() | ||
{ | ||
if (wxProcess == null) return; | ||
Console.WriteLine("进程PID:\t" + wxProcess.Id); | ||
Console.WriteLine("窗口标题:\t" + wxProcess.MainWindowTitle); | ||
Console.WriteLine("启动时间:\t" + wxProcess.StartTime.ToString("yyyy-MM-dd HH:mm:ss")); | ||
Console.WriteLine("微信目录:\t" + System.IO.Path.GetDirectoryName(wxProcess.MainModule.FileName)); | ||
|
||
var modules = (from ProcessModule module in wxProcess.Modules | ||
where module.ModuleName.ToLower() == "WeChatWin.dll".ToLower() | ||
select module).ToList(); | ||
if (modules == null || modules.Count() == 0) | ||
{ | ||
return; | ||
} | ||
weChatBaseAdress = (int)modules[0].BaseAddress; | ||
Console.WriteLine("微信基址:\t" + "0x" + weChatBaseAdress.ToString("X8")); | ||
|
||
String wxVersion = modules[0].FileVersionInfo.FileVersion; | ||
Console.WriteLine("微信版本:\t" + wxVersion); | ||
|
||
if (wxVersion != "2.6.8.65") | ||
{ | ||
Console.WriteLine("当前微信版本不支持!"); | ||
Console.WriteLine("请使用版本为2.6.8.65的微信!"); | ||
Console.ReadLine(); | ||
Environment.Exit(0); | ||
} | ||
} | ||
|
||
private void WeChatStart() | ||
{ | ||
var processes = Process.GetProcessesByName("WeChat"); | ||
//微信未启动 | ||
if (processes == null || processes.Length == 0) | ||
{ | ||
//启动微信 | ||
RegistryKey registryKey = Registry.CurrentUser; | ||
//算机\HKEY_CURRENT_USER\Software\Tencent\WeChat | ||
RegistryKey software = registryKey.OpenSubKey("Software\\Tencent\\WeChat"); | ||
object InstallPath = software.GetValue("InstallPath"); | ||
String wxPath = InstallPath.ToString() + "\\WeChat.exe"; | ||
registryKey.Close(); | ||
|
||
wxProcess=Process.Start(wxPath); | ||
Thread.Sleep(500); | ||
} | ||
else | ||
{ | ||
wxProcess = processes[0]; | ||
} | ||
} | ||
|
||
public static String GetWxMemoryUnicodeString(IntPtr hProcess, int lpBaseAddress, int nSize = 100) | ||
{ | ||
byte[] data = new byte[nSize * 2]; | ||
if (ReadProcessMemory(hProcess, (IntPtr)lpBaseAddress, data, nSize * 2, 0) == 0) | ||
{ | ||
return ""; | ||
} | ||
return Encoding.Unicode.GetString(data); | ||
} | ||
|
||
|
||
public static int GetWxMemoryInt(IntPtr hProcess, int lpBaseAddress) | ||
{ | ||
byte[] data = new byte[4]; | ||
if (ReadProcessMemory(hProcess, (IntPtr)lpBaseAddress, data, 4, 0) == 0) | ||
{ | ||
return 0; | ||
} | ||
return BitConverter.ToInt32(data, 0); | ||
} | ||
|
||
[DllImport("kernel32.dll", SetLastError = true)] | ||
static extern int ReadProcessMemory( | ||
IntPtr hProcess, | ||
IntPtr lpBaseAddress, | ||
[Out] byte[] lpBuffer, | ||
int dwSize, | ||
int lpNumberOfBytesRead); | ||
} | ||
} |