8 Commits

Author SHA1 Message Date
suxue
c66a539d48 v0.9.7.7
1.完善了的版本支持
2.修复了导出时非法文件名及XML字符问题
2025-04-21 11:30:06 +08:00
suxue
51da1fd0ae v0.9.7.6 Release!
1.完善了版本支持。
2.修改了解密界面的推荐,目前仅固定地址查找稳定。
3.修复了部分一些小BUG
2024-09-19 10:02:27 +08:00
Suxue
4213395c9f v0.9.7.5 Release!
1.支持3.9.10.19版本
2024-04-20 10:01:11 +08:00
Suxue
b43a517322 v0.9.7.4 Release!
1.完善批量导出时支持时间范围选择。1
2024-04-08 10:42:55 +08:00
Suxue
5637af45f3 v0.9.7.3 Release!
1.新增导出时间范围选择
2024-03-26 23:48:04 +08:00
Suxue
5cb9cd922b 更新version.json 2024-02-02 10:36:50 +08:00
Suxue
dca42a7849 v0.9.7.2 Release!
1.保底支持3.9.9.27版本。
2.新增批量导出暂停功能。
2024-01-25 13:54:01 +08:00
Suxue
76def416e6 v0.9.7.1 Release!
1.优化批量导出时的体验。现在起记录为空的用户将不会被导出。
2.修复批量导出的部分问题。
2024-01-10 23:32:22 +08:00
21 changed files with 488 additions and 94 deletions

View File

@@ -0,0 +1,25 @@
<Window x:Class="WechatBakTool.Dialog.MsgDatetimePicker"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WechatBakTool.Dialog"
xmlns:local2="clr-namespace:WechatBakTool.ViewModel"
WindowStartupLocation="CenterScreen"
mc:Ignorable="d"
Title="选择导出日期" Height="350" Width="330">
<Window.Resources>
<local2:DateTypeConverter x:Key="dateTypeConverter" />
</Window.Resources>
<Grid>
<RadioButton GroupName="Date" Content="全部" HorizontalAlignment="Left" Margin="45,60,0,0" VerticalAlignment="Top" IsChecked="{Binding DateType, Converter={StaticResource ResourceKey=dateTypeConverter}, ConverterParameter=1}"/>
<RadioButton GroupName="Date" Content="昨天" HorizontalAlignment="Left" Margin="45,90,0,0" VerticalAlignment="Top" IsChecked="{Binding DateType, Converter={StaticResource ResourceKey=dateTypeConverter}, ConverterParameter=2}"/>
<RadioButton GroupName="Date" Content="指定日期" HorizontalAlignment="Left" Margin="45,120,0,0" VerticalAlignment="Top" IsChecked="{Binding DateType, Converter={StaticResource ResourceKey=dateTypeConverter}, ConverterParameter=3}"/>
<DatePicker HorizontalAlignment="Left" Margin="45,140,0,0" VerticalAlignment="Top" SelectedDate="{Binding PickDate}"/>
<RadioButton GroupName="Date" Content="指定范围日期" HorizontalAlignment="Left" Margin="45,180,0,0" VerticalAlignment="Top" IsChecked="{Binding DateType, Converter={StaticResource ResourceKey=dateTypeConverter}, ConverterParameter=4}"/>
<DatePicker Margin="45,200,0,0" VerticalAlignment="Top" SelectedDate="{Binding StartDate}" HorizontalAlignment="Left" Width="100"/>
<DatePicker Margin="185,200,0,0" VerticalAlignment="Top" SelectedDate="{Binding EndDate}" HorizontalAlignment="Left" Width="100"/>
<Label Content="至" Margin="0,200,0,0" VerticalAlignment="Top" HorizontalAlignment="Center" Width="22"/>
<Button Content="提交" Margin="100,265,0,0" VerticalAlignment="Top" Height="40" Click="Button_Click" HorizontalAlignment="Left" Width="140"/>
</Grid>
</Window>

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using WechatBakTool.ViewModel;
namespace WechatBakTool.Dialog
{
/// <summary>
/// MsgDatetimePicker.xaml 的交互逻辑
/// </summary>
public partial class MsgDatetimePicker : Window
{
public MsgDatetimePicker(DatetimePickerViewModel viewModel)
{
DataContext = viewModel;
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
DialogResult = true;
Close();
}
}
}

View File

@@ -11,7 +11,7 @@ namespace WechatBakTool.Export
public interface IExport
{
void InitTemplate(WXContact session,string path);
void SetMsg(WXUserReader reader, WXContact session, WorkspaceViewModel viewModel);
bool SetMsg(WXUserReader reader, WXContact session, WorkspaceViewModel viewModel, DatetimePickerViewModel dateModel);
void SetEnd();
void Save(string path = "");
}

View File

@@ -13,6 +13,7 @@ using WechatBakTool.ViewModel;
using System.Security.Policy;
using System.Windows;
using System.Xml.Linq;
using WechatBakTool.Helpers;
namespace WechatBakTool.Export
{
@@ -28,7 +29,6 @@ namespace WechatBakTool.Export
HtmlBody += string.Format("<div class=\"msg\"><p class=\"nickname\"><b>与 {0}({1}) 的聊天记录</b></p>", Session.NickName, Session.UserName);
HtmlBody += string.Format("<div class=\"msg\"><p class=\"nickname\"><b>导出时间:{0}</b></p><hr/>", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
File.WriteAllText(Path, HtmlBody);
}
public void InitTemplate(WXContact contact, string p)
@@ -51,20 +51,25 @@ namespace WechatBakTool.Export
File.AppendAllText(Path, HtmlBody);
}
public void SetMsg(WXUserReader reader, WXContact contact,WorkspaceViewModel viewModel)
public bool SetMsg(WXUserReader reader, WXContact contact,WorkspaceViewModel viewModel, DatetimePickerViewModel dateModel)
{
if (Session == null)
throw new Exception("请初始化模版Not Use InitTemplate");
List<WXMsg>? msgList = reader.GetWXMsgs(contact.UserName);
List<WXMsg>? msgList = reader.GetWXMsgs(contact.UserName, dateModel);
if (msgList == null)
throw new Exception("获取消息失败,请确认数据库读取正常");
if(msgList.Count == 0)
{
viewModel.ExportCount = "没有消息,忽略";
return false;
}
msgList.Sort((x, y) => x.CreateTime.CompareTo(y.CreateTime));
bool err = false;
int msgCount = 0;
HtmlBody = "";
StreamWriter streamWriter = new StreamWriter(Path, true);
foreach (var msg in msgList)
{
@@ -140,7 +145,7 @@ namespace WechatBakTool.Export
string xml = Encoding.UTF8.GetString(data);
if (!string.IsNullOrEmpty(xml))
{
xml = xml.Replace("\n", "");
xml = StringHelper.CleanInvalidXmlChars(xml);
XmlDocument xmlObj = new XmlDocument();
xmlObj.LoadXml(xml);
if (xmlObj.DocumentElement != null)
@@ -207,7 +212,7 @@ namespace WechatBakTool.Export
string xml = Encoding.UTF8.GetString(data);
if (!string.IsNullOrEmpty(xml))
{
xml = xml.Replace("\n", "");
xml = StringHelper.CleanInvalidXmlChars(xml);
XmlDocument xmlObj = new XmlDocument();
xmlObj.LoadXml(xml);
if (xmlObj.DocumentElement != null)
@@ -259,7 +264,7 @@ namespace WechatBakTool.Export
string xml = Encoding.UTF8.GetString(data);
if (!string.IsNullOrEmpty(xml))
{
xml = xml.Replace("\n", "");
xml = StringHelper.CleanInvalidXmlChars(xml);
XmlDocument xmlObj = new XmlDocument();
xmlObj.LoadXml(xml);
if (xmlObj.DocumentElement != null)
@@ -340,7 +345,7 @@ namespace WechatBakTool.Export
}
streamWriter.Close();
streamWriter.Dispose();
return true;
}
private static DateTime TimeStampToDateTime(long timeStamp, bool inMilli = false)
{

View File

@@ -40,12 +40,12 @@ namespace WechatBakTool.Export
}
public void SetMsg(WXUserReader reader, WXContact session, WorkspaceViewModel viewModel)
public bool SetMsg(WXUserReader reader, WXContact session, WorkspaceViewModel viewModel, DatetimePickerViewModel dateModel)
{
if (Contact == null)
throw new Exception("请初始化模版Not Use InitTemplate");
List<WXMsg>? msgList = reader.GetWXMsgs(Contact.UserName);
List<WXMsg>? msgList = reader.GetWXMsgs(Contact.UserName, dateModel);
if (msgList == null)
throw new Exception("获取消息失败,请确认数据库读取正常");
@@ -146,6 +146,7 @@ namespace WechatBakTool.Export
msgCount++;
viewModel.ExportCount = msgCount.ToString();
}
return true;
}
private static DateTime TimeStampToDateTime(long timeStamp, bool inMilli = false)

View File

@@ -138,7 +138,18 @@ namespace WechatBakTool.Helpers
}
return null;
}
public static string GetMD5(string text)
{
MD5 md5 = MD5.Create();
byte[] bs = Encoding.UTF8.GetBytes(text);
byte[] hs = md5.ComputeHash(bs);
StringBuilder sb = new StringBuilder();
foreach(byte b in hs)
{
sb.Append(b.ToString("x2"));
}
return sb.ToString();
}
public static void DecryptDB(string file, string to_file, byte[] password_bytes)
{
//数据库头16字节是盐值
@@ -227,7 +238,7 @@ namespace WechatBakTool.Helpers
byte[] reserved_byte = new byte[reserved];
fileStream.Seek((page_no * DEFAULT_PAGESIZE) + DEFAULT_PAGESIZE - reserved, SeekOrigin.Begin);
fileStream.Read(reserved_byte, 0, Convert.ToInt32(reserved));
reserved_byte.CopyTo(decryped_page_bytes, Convert.ToInt32(DEFAULT_PAGESIZE - reserved));
reserved_byte.CopyTo(decryped_page_bytes, DEFAULT_PAGESIZE - reserved);
tofileStream.Write(decryped_page_bytes, 0, decryped_page_bytes.Length);

View File

@@ -13,18 +13,18 @@ namespace WechatBakTool.Helpers
[DllImport("Kernel32.dll", CharSet = CharSet.Unicode)]
private static extern uint QueryDosDevice([In] string lpDeviceName, [Out] StringBuilder lpTargetPath, [In] int ucchMax);
public static string FromDevicePath(string devicePath)
public static string? FromDevicePath(string devicePath)
{
var drive = Array.Find(
DriveInfo.GetDrives(), d =>
devicePath.StartsWith(d.GetDevicePath() + "\\", StringComparison.InvariantCultureIgnoreCase)
);
return drive != null ?
devicePath.ReplaceFirst(drive.GetDevicePath(), drive.GetDriveLetter()) :
devicePath.ReplaceFirst(drive.GetDevicePath()!, drive.GetDriveLetter()) :
null;
}
private static string GetDevicePath(this DriveInfo driveInfo)
private static string? GetDevicePath(this DriveInfo driveInfo)
{
var devicePathBuilder = new StringBuilder(128);
return QueryDosDevice(driveInfo.GetDriveLetter(), devicePathBuilder, devicePathBuilder.Capacity + 1) != 0 ?

46
Helpers/StringHelper.cs Normal file
View File

@@ -0,0 +1,46 @@
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
namespace WechatBakTool.Helpers
{
public static class StringHelper
{
/// <summary>
/// 清理XML中的非法字符
/// </summary>
/// <param name="input">需要清理的字符串</param>
/// <returns>清理后的字符串</returns>
public static string CleanInvalidXmlChars(string input)
{
if (string.IsNullOrEmpty(input))
return input;
// #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
// 这里使用正则表达式匹配非法字符并替换
return Regex.Replace(input, @"[^\u0009\u000A\u000D\u0020-\uD7FF\uE000-\uFFFD]", "");
}
/// <summary>
/// 替换文件名中的非法字符为指定字符
/// </summary>
/// <param name="fileName">原始文件名</param>
/// <param name="replacement">用于替换非法字符的字符,默认为 "-"</param>
/// <returns>清理后的文件名</returns>
public static string SanitizeFileName(string fileName, char replacement = '-')
{
if (string.IsNullOrEmpty(fileName))
return fileName;
// 处理Windows系统中文件名不允许的特殊字符
char[] invalidFileNameChars = Path.GetInvalidFileNameChars();
foreach (char invalidChar in invalidFileNameChars)
{
fileName = fileName.Replace(invalidChar, '-');
}
return fileName;
}
}
}

View File

@@ -80,6 +80,8 @@ namespace WechatBakTool
MainFrame.Navigate(new Uri("pack://application:,,,/Pages/Welcome.xaml?datatime=" + DateTime.Now.Ticks));
return;
}
CurrentUserBakConfig = config;
if (!config.Decrypt)
{
MessageBox.Show("请先到创建工作区进行解密");
@@ -87,7 +89,6 @@ namespace WechatBakTool
return;
}
CurrentUserBakConfig = config;
MainFrame.Navigate(new Uri("pack://application:,,,/Pages/Workspace.xaml?datatime=" + DateTime.Now.Ticks));
}

View File

@@ -25,6 +25,8 @@ namespace WechatBakTool.Model
public string Account { get; set; } = "";
public string Friends_Number { get; set; } = "-";
public string Msg_Number { get; set; } = "-";
public string Key { get; set; } = "";
public bool Manual { get; set; } = false;
}
public class WXCount
@@ -82,8 +84,6 @@ namespace WechatBakTool.Model
public string Content { get; set; } = "";
[Column("nTime")]
public int LastTime { get; set; }
public int ReadCount { get; set; }
public int LastMsgId { get; set; }
}
[Table("SessionAttachInfo")]

7
NuGet.config Normal file
View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>

View File

@@ -26,9 +26,9 @@
<TextBox IsEnabled="{Binding IsEnable}" x:Name="txt_username" Margin="35,300,0,0" Width="280" HorizontalAlignment="Left" VerticalAlignment="Top" BorderThickness="0,0,0,1" Text="{Binding UserName}" />
<Label Margin="30,350,0,0" Content="请选择解密方式:" FontWeight="Bold" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<RadioButton Margin="35,380,0,0" Content="固定地址查找【保底】" HorizontalAlignment="Left" VerticalAlignment="Top" GroupName="rb_find_key" HorizontalContentAlignment="Center" IsEnabled="{Binding IsEnable}" VerticalContentAlignment="Center" IsChecked="{Binding KeyType, Converter={StaticResource ResourceKey=getKeyConverterKey}, ConverterParameter=1}" />
<RadioButton Margin="35,380,0,0" Content="固定地址查找【推荐】" HorizontalAlignment="Left" VerticalAlignment="Top" GroupName="rb_find_key" HorizontalContentAlignment="Center" IsEnabled="{Binding IsEnable}" VerticalContentAlignment="Center" IsChecked="{Binding KeyType, Converter={StaticResource ResourceKey=getKeyConverterKey}, ConverterParameter=1}" />
<RadioButton Margin="35,405,0,0" Content="用户名推断查找【不稳定】" HorizontalAlignment="Left" VerticalAlignment="Top" GroupName="rb_find_key" HorizontalContentAlignment="Center" IsEnabled="{Binding IsEnable}" VerticalContentAlignment="Center" IsChecked="{Binding KeyType, Converter={StaticResource ResourceKey=getKeyConverterKey}, ConverterParameter=2}"/>
<RadioButton Margin="35,430,0,0" Content="公钥头推断查找【推荐】" HorizontalAlignment="Left" VerticalAlignment="Top" GroupName="rb_find_key" HorizontalContentAlignment="Center" IsEnabled="{Binding IsEnable}" VerticalContentAlignment="Center" IsChecked="{Binding KeyType, Converter={StaticResource ResourceKey=getKeyConverterKey}, ConverterParameter=3}"/>
<RadioButton Margin="35,430,0,0" Content="公钥头推断查找【不稳定】" HorizontalAlignment="Left" VerticalAlignment="Top" GroupName="rb_find_key" HorizontalContentAlignment="Center" IsEnabled="{Binding IsEnable}" VerticalContentAlignment="Center" IsChecked="{Binding KeyType, Converter={StaticResource ResourceKey=getKeyConverterKey}, ConverterParameter=3}"/>
<Button Name="btn_create_worksapce" Margin="0,0,35,50" Height="60" Width="100" HorizontalAlignment="Right" VerticalAlignment="Bottom" Content="创建工作区" BorderThickness="0" IsEnabled="{Binding IsEnable}" Background="#2775b6" Foreground="White" Click="btn_create_worksapce_Click">
<Button.Resources>

View File

@@ -1,4 +1,5 @@
using System;
using JiebaNet.Segmenter.Common;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@@ -13,7 +14,6 @@ using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WechatBakTool.Helpers;
using WechatBakTool.Model;
using WechatBakTool.ViewModel;
@@ -29,9 +29,20 @@ namespace WechatBakTool.Pages
public CreateWork()
{
DataContext = ViewModel;
InitializeComponent();
GetWechatProcessInfos();
isManualProcess();
}
private void isManualProcess()
{
if(Main2.CurrentUserBakConfig!= null)
{
cb_manual.IsChecked = Main2.CurrentUserBakConfig.Manual;
}
}
private void GetWechatProcessInfos()
{
@@ -55,7 +66,7 @@ namespace WechatBakTool.Pages
ProcessInfo info = new ProcessInfo();
info.ProcessId = p.Id.ToString();
info.ProcessName = p.ProcessName;
info.DBPath = DevicePathMapper.FromDevicePath(name);
info.DBPath = DevicePathMapper.FromDevicePath(name)!;
ViewModel.ProcessInfos.Add(info);
}
}
@@ -97,9 +108,9 @@ namespace WechatBakTool.Pages
private void btn_create_worksapce_Click(object sender, RoutedEventArgs e)
{
ViewModel.IsEnable = false;
bool m = (bool)cb_manual.IsChecked!;
Task.Run(() => {
if (ViewModel.KeyType != -1)
if (ViewModel.KeyType != -1 && !m)
{
if (ViewModel.SelectProcess != null)
{
@@ -141,6 +152,17 @@ namespace WechatBakTool.Pages
}
}
}
else if (m)
{
WXWorkspace wXWorkspace = new WXWorkspace(Main2.CurrentUserBakConfig!);
ViewModel.LabelStatus = "开始解密数据库";
wXWorkspace.DecryptDB("", -1, ViewModel,Main2.CurrentUserBakConfig!.Key);
Dispatcher.Invoke(() =>
{
MessageBox.Show("解密完成");
((Main2)Window.GetWindow(this)).LoadWorkspace();
});
}
else
{
MessageBox.Show("请选择Key获取方式", "错误");
@@ -152,11 +174,41 @@ namespace WechatBakTool.Pages
private void cb_manual_Checked(object sender, RoutedEventArgs e)
{
MessageBox.Show("该功能仅限用于网络安全研究用途使用,红队同学请在合规授权下进行相关操作","重要提醒!!!!!!!!!");
if(Main2.CurrentUserBakConfig != null)
{
if (Main2.CurrentUserBakConfig.Manual)
{
return;
}
}
if (MessageBox.Show("我确认获取到合规授权,仅用于网络安全用途使用", "信息确认", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
if (File.Exists("auth.txt"))
{
string auth = File.ReadAllText("auth.txt");
/*
*
* pwd:
* 我已知晓手动模式可能潜在的法律及道德风险,我明白非法使用将要承担相关法律责任。
* tips:
* 请不要公开宣传手动模式,不提供任何使用解答,谢谢。
* 不要编写任何关于手动模式的教程,避免非法传播使用。
*
*/
if (DecryptionHelper.GetMD5(auth) == "295f634af60d61dfa52a5f35849ac42b")
{
string genHash = DateTime.Now.ToString();
string md5 = DecryptionHelper.GetMD5(genHash);
UserBakConfig config = new UserBakConfig();
config.Hash = md5;
string workspacePath = Path.Combine(Directory.GetCurrentDirectory(), "workspace");
config.UserWorkspacePath = Path.Combine(workspacePath, md5);
WXWorkspace workspace = new WXWorkspace(config);
workspace.ManualInit();
MessageBox.Show("已经创建空的配置文件,请完善该配置文件后,点击开始解密","提示");
}
}
else
{

View File

@@ -6,6 +6,7 @@ using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
@@ -17,7 +18,9 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Xml;
using WechatBakTool.Dialog;
using WechatBakTool.Export;
using WechatBakTool.Helpers;
using WechatBakTool.Model;
using WechatBakTool.ViewModel;
@@ -30,6 +33,9 @@ namespace WechatBakTool.Pages
{
private WorkspaceViewModel workspaceViewModel = new WorkspaceViewModel();
public WXUserReader? UserReader;
private List<WXContact>? ExpContacts;
private bool Suspend = false;
private int Status = 0;
public Manager()
{
DataContext = workspaceViewModel;
@@ -48,6 +54,32 @@ namespace WechatBakTool.Pages
private void btn_export_all_Click(object sender, RoutedEventArgs e)
{
DatetimePickerViewModel datePickViewModel = new DatetimePickerViewModel();
if (Status == 0)
{
MsgDatetimePicker picker = new MsgDatetimePicker(datePickViewModel);
datePickViewModel.DateType = 1;
datePickViewModel.PickDate = DateTime.Now.AddDays(-1);
if (picker.ShowDialog() != true)
{
return;
}
}
// 0 未开始
if(Status == 0 || Status == 2)
{
Suspend = false;
btn_export_all.Content = "暂停";
}
// 1 进行中
else if (Status == 1)
{
// 开启暂停
Suspend = true;
Status = 2;
btn_export_all.Content = "继续";
return;
}
Task.Run(() =>
{
bool group = false, user = false;
@@ -61,34 +93,67 @@ namespace WechatBakTool.Pages
});
if (UserReader != null)
{
List<WXContact>? contacts = UserReader.GetWXContacts().ToList();
foreach (var contact in contacts)
if (Status == 0)
ExpContacts = UserReader.GetWXContacts().ToList();
else
Suspend = false;
List<WXContact> process = new List<WXContact>();
foreach (var contact in ExpContacts!)
{
if (Suspend)
{
foreach(WXContact p in process)
{
ExpContacts.Remove(p);
}
workspaceViewModel.ExportCount = "已暂停";
return;
}
Status = 1;
if (group && contact.UserName.Contains("@chatroom"))
{
workspaceViewModel.WXContact = contact;
ExportMsg(contact);
ExportMsg(contact, datePickViewModel);
}
if (user)
if (user && !contact.UserName.Contains("@chatroom") && !contact.UserName.Contains("gh_"))
{
workspaceViewModel.WXContact = contact;
ExportMsg(contact);
ExportMsg(contact, datePickViewModel);
}
process.Add(contact);
}
Status = 0;
btn_export_all.Content = "导出";
MessageBox.Show("批量导出完成", "提示");
}
});
}
private void ExportMsg(WXContact contact)
private void ExportMsg(WXContact contact, DatetimePickerViewModel dt)
{
workspaceViewModel.ExportCount = "";
string path = Path.Combine(Main2.CurrentUserBakConfig!.UserWorkspacePath, contact.UserName + ".html");
// string path = Path.Combine(Main2.CurrentUserBakConfig!.UserWorkspacePath, contact.UserName + ".html");
string fileName = StringHelper.SanitizeFileName(string.Format(
"{0}-{1}.html",
contact.UserName,
contact.Remark == "" ? contact.NickName : contact.Remark
));
string path = Path.Combine(
Main2.CurrentUserBakConfig!.UserWorkspacePath,
fileName
);
IExport export = new HtmlExport();
export.InitTemplate(contact, path);
export.SetMsg(UserReader!, contact, workspaceViewModel);
export.SetEnd();
export.Save(path);
if (export.SetMsg(UserReader!, contact, workspaceViewModel, dt))
{
export.SetEnd();
export.Save(path);
}
}
private void btn_emoji_download_Click(object sender, RoutedEventArgs e)

View File

@@ -29,6 +29,7 @@ using Newtonsoft.Json;
using System.Drawing.Imaging;
using System.Threading;
using System.Runtime.CompilerServices;
using WechatBakTool.Dialog;
namespace WechatBakTool.Pages
{
@@ -158,29 +159,6 @@ namespace WechatBakTool.Pages
Debug.WriteLine(ViewModel.SearchString);
}
private void btn_export_Click(object sender, RoutedEventArgs e)
{
if(ViewModel.WXContact == null || UserReader == null)
{
MessageBox.Show("请选择联系人", "错误");
return;
}
try
{
string path = Path.Combine(Main2.CurrentUserBakConfig!.UserWorkspacePath, ViewModel.WXContact.UserName + ".txt");
IExport export = new TXTExport();
export.InitTemplate(ViewModel.WXContact, path);
export.SetMsg(UserReader, ViewModel.WXContact, ViewModel);
export.SetEnd();
export.Save(path);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
MessageBox.Show("导出完成");
}
private void btn_open_workspace_Click(object sender, RoutedEventArgs e)
{
@@ -201,7 +179,20 @@ namespace WechatBakTool.Pages
MessageBox.Show("请选择导出方式", "错误");
return;
}
if(ViewModel.SelectExportItem.Value == 3)
DatetimePickerViewModel datePickViewModel = new DatetimePickerViewModel();
Dispatcher.Invoke(() =>
{
MsgDatetimePicker picker = new MsgDatetimePicker(datePickViewModel);
datePickViewModel.DateType = 1;
datePickViewModel.PickDate = DateTime.Now.AddDays(-1);
if (picker.ShowDialog() != true)
{
return;
}
});
if (ViewModel.SelectExportItem.Value == 3)
{
if(UserReader != null && ViewModel.WXContact != null)
{
@@ -279,16 +270,14 @@ namespace WechatBakTool.Pages
return;
}
string name = ViewModel.WXContact.NickName;
name = name.Replace(@"\", "");
name = Regex.Replace(name, "[ \\[ \\] \\^ \\-_*×――(^)$%~!/@#$…&%¥—+=<>《》|!??::•`·、。,;,.;\"‘’“”-]", "");
string fileName = StringHelper.SanitizeFileName(string.Format(
"{0}-{1}",
ViewModel.WXContact.UserName,
ViewModel.WXContact.Remark == "" ? ViewModel.WXContact.NickName : ViewModel.WXContact.Remark
));
string path = Path.Combine(
Main2.CurrentUserBakConfig!.UserWorkspacePath,
string.Format(
"{0}-{1}",
ViewModel.WXContact.UserName,
ViewModel.WXContact.Remark == "" ? name : ViewModel.WXContact.Remark
)
fileName
);
IExport export;
@@ -307,7 +296,7 @@ namespace WechatBakTool.Pages
export = new HtmlExport();
}
export.InitTemplate(ViewModel.WXContact, path);
export.SetMsg(UserReader, ViewModel.WXContact, ViewModel);
export.SetMsg(UserReader, ViewModel.WXContact, ViewModel, datePickViewModel);
export.SetEnd();
export.Save(path);
#if DEBUG

View File

@@ -22,6 +22,7 @@
> [!NOTE]
> 反馈群815054692<br/>
> 如果觉得不错欢迎右上角点个star这是对作者的鼓励谢谢<br/>
> 进群请先Star项目然后问答消息留id<br/>
<br/>
### 免责声明
@@ -59,6 +60,12 @@ A工作区->右键->管理,就见了。<br/>
Q解密工作区提示no such teble:MSG怎么办<br/>
A基本上都是因为刚迁移完缓存没写入到数据库导致的建议迁移完重启一次微信后再创建工作区<br/>
<br/>
Q解密工作区提示no such teble:XXXXXXX怎么办<br/>
A这个原因基本上是因为解密失败导致的回落使用固定地址查找方式解密请确保你的微信版本在version.json内支持<br/>
<br/>
Q解密时提示Unable to load DLL 'libcrypto-1_1' or one of its dependencies怎么办<br/>
A这个是因为加解密库的运行环境不满足安装vc++2015 x64运行库后再尝试<br/>
<br/>
### 使用说明
0.安装.NET Desktop Runtime(注意是6.0版本的Desktop Runtime如已经安装忽略)<br/>
@@ -73,7 +80,7 @@ A基本上都是因为刚迁移完缓存没写入到数据库导致的
### 参考/引用
项目在开发过程中参考了以下项目或资料,有引用相关代码,如有需要,推荐您可以去参考下相关资料:
1. C#使用OpenSSL解密微信数据库这里注意一下64位适配问题注意dll引用 [Mr0x01/WXDBDecrypt.NET](https://github.com/Mr0x01/WXDBDecrypt.NET)<br/>
1. C#使用OpenSSL解密微信数据库这里注意一下64位适配问题注意dll引用另外解密的资源优化不是很好可以参考一下我改写的C#还需要注意一下超大文件的问题 [Mr0x01/WXDBDecrypt.NET](https://github.com/Mr0x01/WXDBDecrypt.NET)<br/>
2. C#使用地址获取微信Key [AdminTest0/SharpWxDump](https://github.com/AdminTest0/SharpWxDump)
3. 解密微信语音我是直接调用解密反正都要ffmpeg多一个也是多多两个也是多懒得头铁实现 [kn007/silk-v3-decoder](https://github.com/kn007/silk-v3-decoder)
4. 解密微信图片 [吾爱破解chenhahacjl/微信 DAT 图片解密 C#](https://www.52pojie.cn/forum.php?mod=viewthread&tid=1507922)

View File

@@ -0,0 +1,39 @@
using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using WechatBakTool.Model;
namespace WechatBakTool.ViewModel
{
public partial class DatetimePickerViewModel : ObservableObject
{
[ObservableProperty]
private DateTime startDate = DateTime.Now.AddMonths(-1);
[ObservableProperty]
private DateTime endDate = DateTime.Now;
[ObservableProperty]
private DateTime pickDate = DateTime.Now.AddDays(-1);
[ObservableProperty]
private int dateType = 1;
}
public class DateTypeConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return (int.Parse(parameter.ToString()!) == (int)value);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return (bool)value ? parameter : Binding.DoNothing;
}
}
}

View File

@@ -22,6 +22,7 @@ using System.Net.Http;
using System.Reflection.Metadata;
using System.Threading;
using Newtonsoft.Json;
using WechatBakTool.ViewModel;
namespace WechatBakTool
{
@@ -51,6 +52,10 @@ namespace WechatBakTool
continue;
SQLiteConnection con = new SQLiteConnection(item);
string dbName = fileInfo.Name.Split('.')[0];
if (DBInfo.ContainsKey(dbName))
{
continue;
}
DBInfo.Add(dbName, con);
}
}
@@ -379,6 +384,40 @@ namespace WechatBakTool
}
return tmp;
}
public List<WXMsg>? GetWXMsgs(string uid, DatetimePickerViewModel dateModel)
{
List<WXMsg> tmp = new List<WXMsg>();
for (int i = 0; i <= 99; i++)
{
SQLiteConnection? con = getCon("MSG" + i.ToString());
if (con == null)
return tmp;
List<WXMsg>? wXMsgs = null;
string query = "";
if (dateModel.DateType == 2 || dateModel.DateType == 3)
{
query = "select * from MSG where StrTalker=? and date(createtime,'unixepoch') = ?";
wXMsgs = con.Query<WXMsg>(query, uid, dateModel.PickDate.ToString("yyyy-MM-dd"));
}
else if(dateModel.DateType == 4 )
{
query = "select * from MSG where StrTalker=? and date(createtime,'unixepoch') >= ? and date(createtime,'unixepoch') <= ?";
wXMsgs = con.Query<WXMsg>(query, uid, dateModel.StartDate.ToString("yyyy-MM-dd"), dateModel.EndDate.ToString("yyyy-MM-dd"));
}
else
{
query = "select * from MSG where StrTalker=?";
wXMsgs = con.Query<WXMsg>(query, uid);
}
tmp.AddRange(ProcessMsg(wXMsgs, uid));
}
return tmp;
}
private List<WXMsg> ProcessMsg(List<WXMsg> msgs,string uid)
{
foreach (WXMsg w in msgs)

View File

@@ -104,32 +104,42 @@ namespace WechatBakTool
{
return UserBakConfig;
}
public static void SaveConfig(UserBakConfig userBakConfig)
public static void SaveConfig(UserBakConfig userBakConfig, bool manual = false)
{
if(userBakConfig.UserWorkspacePath != "")
{
DirectoryInfo directoryInfo = new DirectoryInfo(userBakConfig.UserWorkspacePath);
if(directoryInfo.Parent != null)
{
string json_path = Path.Combine(directoryInfo.Parent.FullName, userBakConfig.UserName + ".json");
string json_path = Path.Combine(directoryInfo.Parent.FullName, userBakConfig.Manual ? userBakConfig.Hash + ".json" : userBakConfig.UserName + ".json");
string json = JsonConvert.SerializeObject(userBakConfig);
File.WriteAllText(json_path, json);
}
}
}
private string Init(string path,bool manual,string account = "")
public void ManualInit()
{
Init("", true, "");
}
private string Init(string path,bool manual = false,string account = "")
{
string curPath = AppDomain.CurrentDomain.BaseDirectory;
string md5 = GetMd5Hash(path);
string[] paths = path.Split(new string[] { "/", "\\" }, StringSplitOptions.None);
string username = paths[paths.Length - 1];
UserBakConfig.UserResPath = path;
UserBakConfig.UserWorkspacePath = Path.Combine(curPath, "workspace", md5);
UserBakConfig.Hash = md5;
UserBakConfig.UserName = username;
UserBakConfig.Account = account;
if (!manual)
{
string md5 = GetMd5Hash(path);
string[] paths = path.Split(new string[] { "/", "\\" }, StringSplitOptions.None);
string username = paths[paths.Length - 1];
UserBakConfig.UserResPath = path;
UserBakConfig.UserWorkspacePath = Path.Combine(curPath, "workspace", md5);
UserBakConfig.Hash = md5;
UserBakConfig.UserName = username;
UserBakConfig.Account = account;
}
if (!Directory.Exists(UserBakConfig.UserResPath))
UserBakConfig.Manual = manual;
if (!Directory.Exists(UserBakConfig.UserResPath) && !manual)
{
return "用户资源文件夹不存在,如需使用离线数据,请从工作区读取";
}
@@ -141,6 +151,7 @@ namespace WechatBakTool
string db = Path.Combine(UserBakConfig.UserWorkspacePath, "OriginalDB");
string decDb = Path.Combine(UserBakConfig.UserWorkspacePath, "DecDB");
if (!Directory.Exists(db))
{
Directory.CreateDirectory (db);
@@ -149,7 +160,7 @@ namespace WechatBakTool
{
Directory.CreateDirectory(decDb);
}
SaveConfig(UserBakConfig);
SaveConfig(UserBakConfig, manual);
return "";
}

View File

@@ -6,9 +6,9 @@
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>0.9.7.0</AssemblyVersion>
<FileVersion>0.9.7.0</FileVersion>
<Version>0.9.7.0</Version>
<AssemblyVersion>0.9.7.7</AssemblyVersion>
<FileVersion>0.9.7.7</FileVersion>
<Version>0.9.7.7</Version>
</PropertyGroup>
<ItemGroup>

View File

@@ -2,17 +2,77 @@
{
"Version": "3.9.6.33",
"BaseAddr": 62031872
},{
"Version":"3.9.7.25",
},
{
"Version": "3.9.7.25",
"BaseAddr": 63484032
},{
"Version":"3.9.7.29",
},
{
"Version": "3.9.7.29",
"BaseAddr": 63488256
},{
"Version":"3.9.8.15",
},
{
"Version": "3.9.8.15",
"BaseAddr": 64997904
},{
"Version":"3.9.8.25",
},
{
"Version": "3.9.8.25",
"BaseAddr": 65002192
},
{
"Version": "3.9.9.27",
"BaseAddr": 68066576
},
{
"Version": "3.9.9.35",
"BaseAddr": 68066576
},
{
"Version": "3.9.9.43",
"BaseAddr": 68067216
},
{
"Version": "3.9.10.19",
"BaseAddr": 95131040
},
{
"Version": "3.9.10.27",
"BaseAddr": 95126928
},
{
"Version": "3.9.11.19",
"BaseAddr": 93551568
},
{
"Version": "3.9.11.23",
"BaseAddr": 93700920
},
{
"Version": "3.9.11.25",
"BaseAddr": 93702352
},
{
"Version": "3.9.12.15",
"BaseAddr": 93814816
},
{
"Version": "3.9.12.17",
"BaseAddr": 93836256
},
{
"Version": "3.9.12.31",
"BaseAddr": 94518176
},
{
"Version": "3.9.12.37",
"BaseAddr": 94522080
},
{
"Version": "3.9.12.45",
"BaseAddr": 94505056
},
{
"Version": "3.9.12.51",
"BaseAddr": 94556448
}
]