-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArtemisVision.cs
80 lines (70 loc) · 2.61 KB
/
ArtemisVision.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using System.Collections.Generic;
using System.Linq;
namespace ArtemisSecurity
{
public static class ArtemisVision
{
private static readonly string ScreenshotDirectory = Path.Combine(Environment.CurrentDirectory, "C:\\Users\\Danie\\Desktop\\Artemis\\bin\\Debug\\tool_screenshots");
public static void CaptureAndAnalyzeScreen()
{
var screenshot = CaptureScreen();
SaveScreenshot(screenshot);
CompareWithKnownTools(screenshot);
}
private static Bitmap CaptureScreen()
{
Rectangle bounds = Screen.PrimaryScreen.Bounds;
Bitmap screenshot = new Bitmap(bounds.Width, bounds.Height);
using (Graphics g = Graphics.FromImage(screenshot))
{
g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
}
return screenshot;
}
private static void SaveScreenshot(Bitmap screenshot)
{
if (!Directory.Exists(ScreenshotDirectory))
{
Directory.CreateDirectory(ScreenshotDirectory);
}
string fileName = $"Screenshot_{DateTime.Now:yyyyMMdd_HHmmss}.png";
string filePath = Path.Combine(ScreenshotDirectory, fileName);
screenshot.Save(filePath);
}
private static void CompareWithKnownTools(Bitmap currentScreenshot)
{
var knownToolScreenshots = Directory.GetFiles(ScreenshotDirectory, "KnownTool_*.png");
foreach (var toolScreenshot in knownToolScreenshots)
{
using (var knownTool = new Bitmap(toolScreenshot))
{
if (CompareImages(currentScreenshot, knownTool))
{
Console.WriteLine($"Potential RE tool detected! Matches known tool: {Path.GetFileNameWithoutExtension(toolScreenshot)}");
// Add more actions here, such as logging or triggering an alert
}
}
}
}
private static bool CompareImages(Bitmap img1, Bitmap img2)
{
if (img1.Size != img2.Size)
return false;
for (int i = 0; i < img1.Width; i++)
{
for (int j = 0; j < img1.Height; j++)
{
if (img1.GetPixel(i, j) != img2.GetPixel(i, j))
{
return false;
}
}
}
return true;
}
}
}