suxuecode / wechatbaktool Goto Github PK
View Code? Open in Web Editor NEW基于C#的微信PC版聊天记录备份工具,提供图形界面,解密微信数据库并导出聊天记录。
License: GNU Affero General Public License v3.0
基于C#的微信PC版聊天记录备份工具,提供图形界面,解密微信数据库并导出聊天记录。
License: GNU Affero General Public License v3.0
发现聊天记录不是实时的,似乎微信把消息缓存了,必须要退出微信重新登录后才可以看到最新的消息,求师傅给出触发微信实时写入db的方案,已star~
我喜欢把公众号文章转发到文件传输助手里,但目前的导出的html上显示的是暂未支持的消息。请问有计划添加把转发的公众号文章的标题和链接导出的功能吗?
对代码做了一些优化,目前测试提高了近50倍(另外使用了缓存以及缩短了搜索范围),贴一下,作为参考:
/// <summary>
/// 内存过滤规则,例如:(state == MEM_COMMIT && (protect == PAGE_EXECUTE || protect == PAGE_EXECUTE_READ || protect == PAGE_EXECUTE_READ || protect == PAGE_READWRITE || protect == PAGE_READONLY))
/// </summary>
/// <param name="state"></param>
/// <param name="protect"></param>
/// <returns>返回值1:该内存页是否需要扫描;返回值2:是否使用内部默认扫描函数,true表示采用默认</returns>
public delegate (bool, bool) CustomMemoryFilter(uint state, uint protect);
/// <summary>
/// 自定义的字节序列数据搜索函数
/// </summary>
/// <param name="data"></param>
/// <param name="bytesToFind"></param>
/// <returns>相对偏移,负数表示未搜索到,否则是匹配的相对偏移量</returns>
public delegate int CustomSearcher(byte[] data, byte[] bytesToFind);
/// <summary>
/// 在进程所有内存空间搜索字节数组
/// </summary>
/// <param name="handle">进程句柄</param>
/// <param name="searchBytes">待搜索的字节数组</param>
/// <param name="customMemoryFilter">过滤内页面属性的条件</param>
/// <param name="customSearch">自定义搜索函数</param>
/// <returns></returns>
public static List<long> SearchProcessAllMemory(IntPtr handle, byte[] searchBytes, CustomMemoryFilter? customMemoryFilter, CustomSearcher? customSearch) {
List<long> addrList = new();
IntPtr minAddress = IntPtr.Zero;
IntPtr maxAddress = IntPtr.MaxValue;
int pos = 0;
bool shouldScan = false;
bool useDefaultScan = true;
while (minAddress < maxAddress) {
MEMORY_BASIC_INFORMATION64 memInfo;
int result = VirtualQueryEx(handle, minAddress, out memInfo, (uint)Marshal.SizeOf(typeof(MEMORY_BASIC_INFORMATION64)));
if (result == 0) { break; }
if (customMemoryFilter != null) {
(shouldScan, useDefaultScan) = customMemoryFilter(memInfo.State, memInfo.Protect);
} else {
shouldScan = (memInfo.State == MEM_COMMIT && (memInfo.Protect == PAGE_EXECUTE || memInfo.Protect == PAGE_EXECUTE_READ || memInfo.Protect == PAGE_EXECUTE_READ || memInfo.Protect == PAGE_READWRITE || memInfo.Protect == PAGE_READONLY));
}
if (shouldScan) {
byte[] buffer = new byte[(long)memInfo.RegionSize];
if (ReadProcessMemory(handle, memInfo.BaseAddress, buffer, buffer.Length, out _)) {
pos = -1;
if (useDefaultScan) {
pos = SearchBytes(buffer, searchBytes);
} else if (customSearch != null) {
pos = customSearch(buffer, searchBytes);
}
if (pos >= 0) { addrList.Add(memInfo.BaseAddress + pos); }
}
}
minAddress = memInfo.BaseAddress + (nint)memInfo.RegionSize;
}
return addrList;
}
/// <summary>
/// 在内存数据中查找字节序列,注意:搜索方法不回溯且每次递进8字节
/// </summary>
/// <param name="data"></param>
/// <param name="bytesToFind"></param>
/// <returns></returns>
private static int SearchBytes(byte[] data, byte[] bytesToFind) {
for (int i = 0; i < data.Length - bytesToFind.Length; i += sizeof(long)) {
for (int j = 0; j < bytesToFind.Length;) {
if (data[i + j] != bytesToFind[j]) {
break;
} else {
j++;
if (j == bytesToFind.Length) {
return i;
}
}
}
}
return -1;
}
外部使用时:
// 在进程的所有地址空间里搜索。讨巧:该字符串特征为0x10对齐,且内存页面属性为可读写,可以提高搜索速度。
byte[] searchBytes = Encoding.UTF8.GetBytes("-----BEGIN PUBLIC KEY-----");
var listAddr = NativeAPIHelper.SearchProcessAllMemory(handle, searchBytes,
(state, protect) => ((state == NativeAPI.MEM_COMMIT && protect == NativeAPI.PAGE_READWRITE), false),
(data, search) => HexPatternMatcherKMP.SearchBytes(data, search, 0x10)
);
// 对所有地址在指定某块内里搜索
List<int> listTargetAddr = new();
foreach (var address in listAddr) {
matchedOffset = HexPatternMatcherKMP.SearchNumber(session.CacheBuffer, address);
if (matchedOffset >= 0) { listTargetAddr.Add(matchedOffset); }
}
// 取较大的那个,该地址只比手机型号地址大0x28
matchedOffset = listTargetAddr.Max();
软件版本 0.9.7.2
windows微信版本:3.9.9.43
安装完毕微信,同步信息。分析的时候出现错误,显示no such table:ContactHeadImg1
旧版分析工具里能看到已删除好友的聊天记录,但是界面不能扩展看不到长句和图片,请问可否导出已删除好友的本地聊天记录呢
OS:WIN11
微信PC版:3.9.9.43
Error:Unable to load DLL 'libcrypto-1_1' or one of its dependencies: The specified module could not be found. (0x8007007E)
微信进程可以看到,微信号正确,
三个选项,均无法正常解密
存了很多个版本的ff,请问能否增加设置项调用自己的ff呢
从12年的聊天记录的电脑的硬盘还在。然后22年9月份的时候,电脑坏了,直接数据搞不回来了。
然后mac的硬盘是正常的,有拆开硬盘去看,是没问题的。
现在的数据只有从22年9月份开始,丢失了很多年的数据,好多还是家人的聊天记录,还有一些工作记录,
愿意付费。
有些场景会获取到密钥和.db文件,大佬在后续版本中是否可以支持离线解密并展示聊天记录
怎么指定日期和时间导出
我发现解密得到数据不是很及时,我想着做成windows服务挂载,但是用.net4.8运行的效率极其低,是不是因为.net 的框架版本问题导致的。
1.导出记录后 可以明文查看吗 如何操作使用?
2,对应记录在哪里,好像只导出对应联系人的网名,可以添加备注信息嘛!
在一台win7的电脑上成功导出了,是通过安装在移动硬盘上的软件导出的。
在另一台win11的电脑上新建工作区后,获取不到微信的进程
是因为操作系统版本的原因还是我没有安装微信到默认目录呢?
版本22H2 OS内部版本22621.2861 win11企业版
选中一个聊天内容中的多条记录,合并转发后,在baktool中提示附件不存在。
OS:WIN11
微信PC版:3.9.9.43
Error:Unable to load DLL 'libcrypto-1_1' or one of its dependencies: The specified module could not be found. (0x8007007E)
微信进程可以看到,微信号正确,
三个选项,均无法正常解密
版本:0.9.1.1
导出群聊中的消息或者 单联系人消息时,导出不了图片。在导出的聊天记录中,原本图片的消息显示为:图片转换出现错误或文件不存在
关于自定义用户名的路径并非wxid时,使用用户名推断查找无法解密。3.9.8.15
作者你好,微信每次更新后,基址都会变,有办法自动从进程中提取到代码吗?或者有通用的调试获取到微信的基址码吗?
因为手机上面的聊天记录更加全面,所以希望以后电脑能够解密手机备份到电脑上的聊天记录,这样的话就真的无敌了
模式可以参考:https://github.com/xaoyaoo/PyWxDump
建议把取证端和分析端分开,取证端只做必要信息的获取。
分析端参考 https://github.com/xaoyaoo/PyWxDump ,使用C#的简单易用的blazor框架搭建离线分析系统。
其他建议:代码有点混乱,可以使用chat gpt助手辅助,效率也高一些。
比如 我先导出了 一次我和某人的聊天记录 然后我将和他的记录在微信里面删除了 然后我再导出和他的新聊天记录 可不可以和之前的连接上呢
如果只支持一个版本的话,普适性太差了,好像可以自动获取基址的,python的pymem都能做到。不过我很喜欢作者的图形化思路!!!点赞
无法导出最近时间的聊天记录,能否把文件名显示出来
后面有支持mac版本的计划吗?
{"LocalId":80223,"MsgSequence":671824805,"Type":3,"SubType":0,"CreateTime":1554597543,"IsSender":false,"MsgSvrID":"8161939939925005935","StrTalker":"5227036437@chatroom","StrContent":"\n\n\t<img aeskey="e057c6c563ed7ef01312a09df4e7dc86" encryver="0" cdnthumbaeskey="e057c6c563ed7ef01312a09df4e7dc86" cdnthumburl="3053020100044c304a0201000204a910866d02032f53a302040b762d7002045ca946740425617570696d675f366333383038313933306130396337615f313535343539373438333333370204010818020201000400" cdnthumblength="5500" cdnthumbheight="120" cdnthumbwidth="88" cdnmidheight="0" cdnmidwidth="0" cdnhdheight="0" cdnhdwidth="0" cdnmidimgurl="3053020100044c304a0201000204a910866d02032f53a302040b762d7002045ca946740425617570696d675f366333383038313933306130396337615f313535343539373438333333370204010818020201000400" length="102439" md5="81e099ecf15915f076c426ac9b773f12" />\n\n","DisplayContent":"[界面未支持格式]Type=3","CompressContent":null,"BytesExtra":"CgQIBRABCgQIBhAAGhcIARITd3hpZF82d3ljbHdpMHo3YmcyMhq+AQgHErkBPG1zZ3NvdXJjZT48c2VxdWVuY2VfaWQ+NjcxODI0ODA1PC9zZXF1ZW5jZV9pZD4KCTxzaWxlbmNlPjA8L3NpbGVuY2U+Cgk8bWVtYmVyY291bnQ+MTA0PC9tZW1iZXJjb3VudD4KCTxOb3RBdXRvRG93bmxvYWRSYW5nZT4yMDowMC0yMjowMDswMDowMC0wMTowMDwvTm90QXV0b0Rvd25sb2FkUmFuZ2U+CjwvbXNnc291cmNlPgoaJAgCEiA0YzM2MjlmZTc1ZGRkZWFmMTRhN2EyMTQ4NDI1YWUxMxpPCAQSS2hlbmdkZW1hb3hpblxGaWxlU3RvcmFnZVxJbWFnZVwyMDE5LTA0XDM0ODJiYzRhZjY5YzY2ZjVhY2JkNjkxYzVmMWM0MjdhLmRhdBpXCAMSU2hlbmdkZW1hb3hpblxGaWxlU3RvcmFnZVxJbWFnZVxUaHVtYlwyMDE5LTA0XDY4MmRhZGI3ZjdiNDMxMzUzNjMxMzRhOTE1MjM5ZDUwX3QuZGF0","NickName":"xxxxxxxxxxxxxxxx"}System.IndexOutOfRangeException: Index was outside the bounds of the array.
at WechatBakTool.Helpers.DecryptionHelper.CheckFileType(Byte[] data) in D:\Code\WechatPCMsgBakTool\Helpers\DecryptionHelper.cs:line 347
at WechatBakTool.WXUserReader.DecryptAttachment(WXMsgType type, String path, String username) in D:\Code\WechatPCMsgBakTool\WXUserReader.cs:line 662
at WechatBakTool.WXUserReader.GetAttachment(WXMsgType type, WXMsg msg) in D:\Code\WechatPCMsgBakTool\WXUserReader.cs:line 605
at WechatBakTool.Export.HtmlExport.SetMsg(WXUserReader reader, WXContact contact, WorkspaceViewModel viewModel) in D:\Code\WechatPCMsgBakTool\Export\HtmlExport.cs:line 83
微信版本3.9.8.15
在同步最近消息登录后运行wt程序显示已解密。能获取到用户头像和群,但是聊天记录是空的
三种方式都试了,获取到的密钥为空,获取失败,wx版本:3.0.0.57
看到好多以前的聊天记录,人都不是好友了,有办法可以找出微信号吗?
小白一枚,想用来备份聊天记录,出现以上问题,求解答。
是可以从手机备份到pc版微信 然后用这个程序提取吗?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.