浏览代码

v0.9.7.1 Release!
1.优化批量导出时的体验。现在起记录为空的用户将不会被导出。
2.修复批量导出的部分问题。

Suxue 1 年之前
父节点
当前提交
76def416e6
共有 8 个文件被更改,包括 71 次插入20 次删除
  1. 1 1
      Export/ExportInterface.cs
  2. 8 4
      Export/HtmlExport.cs
  3. 2 1
      Export/TXTExport.cs
  4. 13 2
      Helpers/DecryptionHelper.cs
  5. 7 1
      Pages/CreateWork.xaml.cs
  6. 35 7
      Pages/Manager.xaml.cs
  7. 2 1
      README.md
  8. 3 3
      WechatBakTool.csproj

+ 1 - 1
Export/ExportInterface.cs

@@ -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);
         void SetEnd();
         void Save(string path = "");
     }

+ 8 - 4
Export/HtmlExport.cs

@@ -28,7 +28,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,7 +50,7 @@ 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)
         {
             if (Session == null)
                 throw new Exception("请初始化模版:Not Use InitTemplate");
@@ -60,11 +59,16 @@ namespace WechatBakTool.Export
             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)
             {
@@ -340,7 +344,7 @@ namespace WechatBakTool.Export
             }
             streamWriter.Close();
             streamWriter.Dispose();
-                
+            return true;
         }
         private static DateTime TimeStampToDateTime(long timeStamp, bool inMilli = false)
         {

+ 2 - 1
Export/TXTExport.cs

@@ -40,7 +40,7 @@ namespace WechatBakTool.Export
             
         }
 
-        public void SetMsg(WXUserReader reader, WXContact session, WorkspaceViewModel viewModel)
+        public bool SetMsg(WXUserReader reader, WXContact session, WorkspaceViewModel viewModel)
         {
             if (Contact == null)
                 throw new Exception("请初始化模版:Not Use InitTemplate");
@@ -146,6 +146,7 @@ namespace WechatBakTool.Export
                 msgCount++;
                 viewModel.ExportCount = msgCount.ToString();
             }
+            return true;
         }
 
         private static DateTime TimeStampToDateTime(long timeStamp, bool inMilli = false)

+ 13 - 2
Helpers/DecryptionHelper.cs

@@ -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);
 

+ 7 - 1
Pages/CreateWork.xaml.cs

@@ -156,7 +156,13 @@ namespace WechatBakTool.Pages
             {
                 if (File.Exists("auth.txt"))
                 {
-
+                    string auth = File.ReadAllText("auth.txt");
+                    // 我已知晓手动模式可能潜在的法律及道德风险,我明白非法使用将要承担相关法律责任。
+                    if (DecryptionHelper.GetMD5(auth) == "295f634af60d61dfa52a5f35849ac42b")
+                    {
+                        MessageBox.Show("已经创建空的配置文件,请完善该配置文件后,点击开始解密","提示");
+                        MessageBox.Show("该功能现阶段暂未启用","错误");
+                    }
                 }
                 else
                 {

+ 35 - 7
Pages/Manager.xaml.cs

@@ -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;
@@ -30,6 +31,8 @@ namespace WechatBakTool.Pages
     {
         private WorkspaceViewModel workspaceViewModel = new WorkspaceViewModel();
         public WXUserReader? UserReader;
+        private List<WXContact>? ExpContacts;
+        private bool Suspend = false;
         public Manager()
         {
             DataContext = workspaceViewModel;
@@ -61,15 +64,25 @@ namespace WechatBakTool.Pages
                 });
                 if (UserReader != null)
                 {
-                    List<WXContact>? contacts = UserReader.GetWXContacts().ToList();
-                    foreach (var contact in contacts)
+                    if (!Suspend)
+                        ExpContacts = UserReader.GetWXContacts().ToList();
+                    else
+                        Suspend = false;
+
+                    foreach (var contact in ExpContacts!)
                     {
+                        if (Suspend)
+                        {
+                            workspaceViewModel.ExportCount = "已暂停";
+                            return;
+                        }
+                            
                         if (group && contact.UserName.Contains("@chatroom"))
                         {
                             workspaceViewModel.WXContact = contact;
                             ExportMsg(contact);
                         }
-                        if (user)
+                        if (user && !contact.UserName.Contains("@chatroom") && !contact.UserName.Contains("gh_"))
                         {
                             workspaceViewModel.WXContact = contact;
                             ExportMsg(contact);
@@ -83,12 +96,27 @@ namespace WechatBakTool.Pages
         private void ExportMsg(WXContact contact)
         {
             workspaceViewModel.ExportCount = "";
-            string path = Path.Combine(Main2.CurrentUserBakConfig!.UserWorkspacePath, contact.UserName + ".html");
+            // string path = Path.Combine(Main2.CurrentUserBakConfig!.UserWorkspacePath, contact.UserName + ".html");
+            string name = contact.NickName;
+            name = name.Replace(@"\", "");
+            name = Regex.Replace(name, "[ \\[ \\] \\^ \\-_*×――(^)$%~!/@#$…&%¥—+=<>《》|!!???::•`·、。,;,.;\"‘’“”-]", "");
+            string path = Path.Combine(
+                Main2.CurrentUserBakConfig!.UserWorkspacePath,
+                string.Format(
+                    "{0}-{1}.html",
+                    contact.UserName,
+                    contact.Remark == "" ? name : contact.Remark
+                )
+            );
+
             IExport export = new HtmlExport();
             export.InitTemplate(contact, path);
-            export.SetMsg(UserReader!, contact, workspaceViewModel);
-            export.SetEnd();
-            export.Save(path);
+            if(export.SetMsg(UserReader!, contact, workspaceViewModel))
+            {
+                export.SetEnd();
+                export.Save(path);
+            }
+            
         }
 
         private void btn_emoji_download_Click(object sender, RoutedEventArgs e)

+ 2 - 1
README.md

@@ -22,6 +22,7 @@
 > [!NOTE]
 > 反馈群:815054692<br/>
 > 如果觉得不错,欢迎右上角点个star!这是对作者的鼓励,谢谢!<br/>
+> 进群请先Star项目,然后问答消息留id<br/>
 <br/>
 
 ### 免责声明
@@ -73,7 +74,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)

+ 3 - 3
WechatBakTool.csproj

@@ -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.1</AssemblyVersion>
+    <FileVersion>0.9.7.1</FileVersion>
+    <Version>0.9.7.1</Version>
   </PropertyGroup>
 
   <ItemGroup>