Embedd_Server_Config(string path, string content)
10 | {
11 | try
12 | {
13 | using (FileStream fs = new FileStream(path, FileMode.Append, FileAccess.Write))
14 | using (BinaryWriter writer = new BinaryWriter(fs))
15 | {
16 | writer.Write(Encoding.UTF8.GetBytes("SERVERCONFIGMARKER")); // Marker schreiben
17 | writer.Write(Encoding.UTF8.GetBytes(await Base64.Handler.Encode(content))); // Base64-String anhängen
18 | }
19 |
20 | return true;
21 | }
22 | catch (Exception ex)
23 | {
24 | Logging.Handler.Error("NetLock_RMM_Server.Helper.Compiler.Ressource_Manipulation.Write_Ressource", "General error", ex.ToString());
25 | Console.WriteLine(ex.ToString());
26 | return false;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/NetLock RMM Agent Comm/Global/Configuration/Agent.cs:
--------------------------------------------------------------------------------
1 | namespace Global.Configuration
2 | {
3 | public class Agent
4 | {
5 | public static bool debug_mode { get; set; } = false; //enables/disables logging
6 | public static bool ssl { get; set; } = false;
7 | public static string package_guid { get; set; } = String.Empty;
8 | public static string communication_servers { get; set; } = String.Empty;
9 | public static string remote_servers { get; set; } = String.Empty;
10 | public static string update_servers { get; set; } = String.Empty;
11 | public static string trust_servers { get; set; } = String.Empty;
12 | public static string file_servers { get; set; } = String.Empty;
13 | public static string tenant_guid { get; set; } = String.Empty;
14 | public static string location_guid { get; set; } = String.Empty;
15 | public static string language { get; set; } = String.Empty;
16 | public static string http_https { get; set; } = String.Empty;
17 | public static string device_name { get; set; } = String.Empty;
18 | public static string hwid { get; set; } = String.Empty;
19 | public static string platform { get; set; } = String.Empty;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/NetLock RMM Agent Health/Global/Configuration/Agent.cs:
--------------------------------------------------------------------------------
1 | namespace Global.Configuration
2 | {
3 | public class Agent
4 | {
5 | public static bool debug_mode { get; set; } = false; //enables/disables logging
6 | public static bool ssl { get; set; } = false;
7 | public static string package_guid { get; set; } = String.Empty;
8 | public static string communication_servers { get; set; } = String.Empty;
9 | public static string remote_servers { get; set; } = String.Empty;
10 | public static string update_servers { get; set; } = String.Empty;
11 | public static string trust_servers { get; set; } = String.Empty;
12 | public static string file_servers { get; set; } = String.Empty;
13 | public static string tenant_guid { get; set; } = String.Empty;
14 | public static string location_guid { get; set; } = String.Empty;
15 | public static string language { get; set; } = String.Empty;
16 | public static string http_https { get; set; } = String.Empty;
17 | public static string device_name { get; set; } = String.Empty;
18 | public static string hwid { get; set; } = String.Empty;
19 | public static string platform { get; set; } = String.Empty;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/NetLock RMM Tray Icon/NetLock RMM Tray Icon.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.14.36310.24 d17.14
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetLock RMM Tray Icon", "NetLock RMM Tray Icon.csproj", "{2CA4D400-9860-4051-BF8E-8660E54E2280}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {2CA4D400-9860-4051-BF8E-8660E54E2280}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {2CA4D400-9860-4051-BF8E-8660E54E2280}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {2CA4D400-9860-4051-BF8E-8660E54E2280}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {2CA4D400-9860-4051-BF8E-8660E54E2280}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {B1BE7AE1-D43C-41B0-AC79-8DB4B5A6AFD0}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/NetLock RMM Web Console.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.10.35013.160
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetLock RMM Web Console", "NetLock RMM Web Console.csproj", "{C49D8A10-3530-483D-AE9B-71F451C13206}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {C49D8A10-3530-483D-AE9B-71F451C13206}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {C49D8A10-3530-483D-AE9B-71F451C13206}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {C49D8A10-3530-483D-AE9B-71F451C13206}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {C49D8A10-3530-483D-AE9B-71F451C13206}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {E55F4080-5913-4AFB-A0DC-102B8110AADC}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/launchsettings.json",
3 | "iisSettings": {
4 | "windowsAuthentication": false,
5 | "anonymousAuthentication": true,
6 | "iisExpress": {
7 | "applicationUrl": "http://localhost:32855",
8 | "sslPort": 44321
9 | }
10 | },
11 | "profiles": {
12 | "http": {
13 | "commandName": "Project",
14 | "dotnetRunMessages": true,
15 | "launchBrowser": true,
16 | "applicationUrl": "http://localhost:5000",
17 | "environmentVariables": {
18 | "ASPNETCORE_ENVIRONMENT": "Development"
19 | }
20 | },
21 | "https": {
22 | "commandName": "Project",
23 | "dotnetRunMessages": true,
24 | "launchBrowser": true,
25 | "applicationUrl": "https://localhost:7253;http://localhost:5131",
26 | "environmentVariables": {
27 | "ASPNETCORE_ENVIRONMENT": "Development"
28 | }
29 | },
30 | "IIS Express": {
31 | "commandName": "IISExpress",
32 | "launchBrowser": true,
33 | "environmentVariables": {
34 | "ASPNETCORE_ENVIRONMENT": "Development"
35 | }
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/Classes/Setup/DNS.cs:
--------------------------------------------------------------------------------
1 | using System.Net;
2 |
3 | namespace NetLock_RMM_Web_Console.Classes.Setup
4 | {
5 | public class DNS
6 | {
7 | public static async Task<(bool, string)> Check_Dns_Forward_Reverse(string host)
8 | {
9 | try
10 | {
11 | IPAddress[] addresses = await Dns.GetHostAddressesAsync(host);
12 |
13 | foreach (var ip in addresses)
14 | {
15 | IPHostEntry reverse = await Dns.GetHostEntryAsync(ip);
16 |
17 | if (!reverse.HostName.Equals(host, StringComparison.OrdinalIgnoreCase))
18 | {
19 | return (false, reverse.HostName); // Hostnames do not match
20 | }
21 | else
22 | {
23 | return (true, reverse.HostName);
24 | }
25 | }
26 |
27 | return (false, "No IP addresses found.");
28 | }
29 | catch (Exception ex)
30 | {
31 | Logging.Handler.Error("DNS", "Check_Dns_Forward_Reverse", ex.Message);
32 | return (false, "Undefined.");
33 | }
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/NetLock-RMM-Server/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "http": {
4 | "commandName": "Project",
5 | "launchUrl": "swagger",
6 | "environmentVariables": {
7 | "ASPNETCORE_ENVIRONMENT": "Development"
8 | },
9 | "dotnetRunMessages": true,
10 | "applicationUrl": "http://localhost:7080"
11 | },
12 | "https": {
13 | "commandName": "Project",
14 | "launchBrowser": true,
15 | "launchUrl": "swagger",
16 | "environmentVariables": {
17 | "ASPNETCORE_ENVIRONMENT": "Development"
18 | },
19 | "dotnetRunMessages": true,
20 | "applicationUrl": "https://localhost:7173;http://localhost:5054"
21 | },
22 | "IIS Express": {
23 | "commandName": "IISExpress",
24 | "launchBrowser": true,
25 | "launchUrl": "swagger",
26 | "environmentVariables": {
27 | "ASPNETCORE_ENVIRONMENT": "Development"
28 | }
29 | }
30 | },
31 | "$schema": "http://json.schemastore.org/launchsettings.json",
32 | "iisSettings": {
33 | "windowsAuthentication": false,
34 | "anonymousAuthentication": true,
35 | "iisExpress": {
36 | "applicationUrl": "http://localhost:28260",
37 | "sslPort": 44374
38 | }
39 | },
40 | "agent_versions": {
41 | "windows": "1.0.0.0"
42 | }
43 | }
--------------------------------------------------------------------------------
/NetLock RMM Agent Remote/Initialization/Health.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.IO;
7 | using System.Diagnostics;
8 | using NetLock_RMM_Agent_Remote;
9 | using Global.Helper;
10 |
11 | namespace Global.Initialization
12 | {
13 | internal class Health
14 | {
15 | // Check if the directories are in place
16 | public static void Check_Directories()
17 | {
18 | try
19 | {
20 | // Program Data
21 | if (!Directory.Exists(Application_Paths.program_data))
22 | Directory.CreateDirectory(Application_Paths.program_data);
23 |
24 | // Logs
25 | if (!Directory.Exists(Application_Paths.program_data_logs))
26 | Directory.CreateDirectory(Application_Paths.program_data_logs);
27 |
28 | // Scripts
29 | if (!Directory.Exists(Application_Paths.program_data_scripts))
30 | Directory.CreateDirectory(Application_Paths.program_data_scripts);
31 | }
32 | catch (Exception ex)
33 | {
34 | Logging.Error("Initialization.Health.Check_Directories", "", ex.ToString());
35 | }
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/Components/Pages/Error.razor:
--------------------------------------------------------------------------------
1 | @page "/Error"
2 | @using System.Diagnostics
3 |
4 | Error
5 |
6 | Error.
7 | An error occurred while processing your request.
8 |
9 | @if (ShowRequestId)
10 | {
11 |
12 | Request ID: @RequestId
13 |
14 | }
15 |
16 | Development Mode
17 |
18 | Swapping to Development environment will display more detailed information about the error that occurred.
19 |
20 |
21 | The Development environment shouldn't be enabled for deployed applications.
22 | It can result in displaying sensitive information from exceptions to end users.
23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development
24 | and restarting the app.
25 |
26 |
27 | @code{
28 | [CascadingParameter]
29 | private HttpContext? HttpContext { get; set; }
30 |
31 | private string? RequestId { get; set; }
32 | private bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
33 |
34 | protected override void OnInitialized() =>
35 | RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier;
36 | }
37 |
--------------------------------------------------------------------------------
/NetLock-RMM-Server/HWID_System/disk.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Management;
3 |
4 | namespace _x101.HWID_System
5 | {
6 | internal class DiskId
7 | {
8 | [System.Reflection.ObfuscationAttribute(Feature = "Virtualization", Exclude = false)]
9 |
10 | public static string GetDiskId()
11 | {
12 | return GetDiskId("");
13 | }
14 | private static string GetDiskId(string diskLetter)
15 | {
16 | //Find first drive
17 | if (string.IsNullOrEmpty(diskLetter))
18 | {
19 | foreach (var compDrive in DriveInfo.GetDrives())
20 | {
21 | if (compDrive.IsReady)
22 | {
23 | diskLetter = compDrive.RootDirectory.ToString();
24 | break;
25 | }
26 | }
27 | }
28 | if (!string.IsNullOrEmpty(diskLetter) && diskLetter.EndsWith(":\\"))
29 | {
30 | //C:\ -> C
31 | diskLetter = diskLetter.Substring(0, diskLetter.Length - 2);
32 | }
33 | var disk = new ManagementObject(@"win32_logicaldisk.deviceid=""" + diskLetter + @":""");
34 | disk.Get();
35 |
36 | var volumeSerial = disk["VolumeSerialNumber"].ToString();
37 | disk.Dispose();
38 |
39 | return volumeSerial;
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/NetLock RMM Agent Comm/HWID_System/disk.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Management;
3 |
4 | namespace _x101.HWID_System
5 | {
6 | internal class DiskId
7 | {
8 | [System.Reflection.ObfuscationAttribute(Feature = "Virtualization", Exclude = false)]
9 |
10 | public static string GetDiskId()
11 | {
12 | return GetDiskId("");
13 | }
14 | private static string GetDiskId(string diskLetter)
15 | {
16 | //Find first drive
17 | if (string.IsNullOrEmpty(diskLetter))
18 | {
19 | foreach (var compDrive in DriveInfo.GetDrives())
20 | {
21 | if (compDrive.IsReady)
22 | {
23 | diskLetter = compDrive.RootDirectory.ToString();
24 | break;
25 | }
26 | }
27 | }
28 | if (!string.IsNullOrEmpty(diskLetter) && diskLetter.EndsWith(":\\"))
29 | {
30 | //C:\ -> C
31 | diskLetter = diskLetter.Substring(0, diskLetter.Length - 2);
32 | }
33 | var disk = new ManagementObject(@"win32_logicaldisk.deviceid=""" + diskLetter + @":""");
34 | disk.Get();
35 |
36 | var volumeSerial = disk["VolumeSerialNumber"].ToString();
37 | disk.Dispose();
38 |
39 | return volumeSerial;
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/NetLock RMM Agent Remote/HWID_System/disk.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Management;
3 |
4 | namespace _x101.HWID_System
5 | {
6 | internal class DiskId
7 | {
8 | [System.Reflection.ObfuscationAttribute(Feature = "Virtualization", Exclude = false)]
9 |
10 | public static string GetDiskId()
11 | {
12 | return GetDiskId("");
13 | }
14 | private static string GetDiskId(string diskLetter)
15 | {
16 | //Find first drive
17 | if (string.IsNullOrEmpty(diskLetter))
18 | {
19 | foreach (var compDrive in DriveInfo.GetDrives())
20 | {
21 | if (compDrive.IsReady)
22 | {
23 | diskLetter = compDrive.RootDirectory.ToString();
24 | break;
25 | }
26 | }
27 | }
28 | if (!string.IsNullOrEmpty(diskLetter) && diskLetter.EndsWith(":\\"))
29 | {
30 | //C:\ -> C
31 | diskLetter = diskLetter.Substring(0, diskLetter.Length - 2);
32 | }
33 | var disk = new ManagementObject(@"win32_logicaldisk.deviceid=""" + diskLetter + @":""");
34 | disk.Get();
35 |
36 | var volumeSerial = disk["VolumeSerialNumber"].ToString();
37 | disk.Dispose();
38 |
39 | return volumeSerial;
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/NetLock RMM Agent Comm/NetLock RMM Agent Comm.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.12.35514.174
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetLock RMM Agent Comm", "NetLock RMM Agent Comm.csproj", "{74DA604D-11A8-4A67-B1B3-735AE8704648}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Debug|x64 = Debug|x64
12 | Release|Any CPU = Release|Any CPU
13 | Release|x64 = Release|x64
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {74DA604D-11A8-4A67-B1B3-735AE8704648}.Debug|Any CPU.ActiveCfg = Debug|x64
17 | {74DA604D-11A8-4A67-B1B3-735AE8704648}.Debug|Any CPU.Build.0 = Debug|x64
18 | {74DA604D-11A8-4A67-B1B3-735AE8704648}.Debug|x64.ActiveCfg = Debug|x64
19 | {74DA604D-11A8-4A67-B1B3-735AE8704648}.Debug|x64.Build.0 = Debug|x64
20 | {74DA604D-11A8-4A67-B1B3-735AE8704648}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {74DA604D-11A8-4A67-B1B3-735AE8704648}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {74DA604D-11A8-4A67-B1B3-735AE8704648}.Release|x64.ActiveCfg = Release|x64
23 | {74DA604D-11A8-4A67-B1B3-735AE8704648}.Release|x64.Build.0 = Release|x64
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/NetLock RMM Agent Installer/Linux/Helper/Linux.cs:
--------------------------------------------------------------------------------
1 | using Helper;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Linux.Helper
9 | {
10 | internal class Linux
11 | {
12 | // Helper method to create service files dynamically
13 | public static void CreateServiceFile(string serviceFilePath, string serviceName, string executablePath, string workingDirectory, string logFilePath)
14 | {
15 | // Wenn der Pfad Leerzeichen enthält, setzen wir ihn in doppelte Anführungszeichen
16 | string formattedExecutablePath = $"\"{executablePath}\"";
17 |
18 | string serviceContent = @$"[Unit]
19 | Description={serviceName}
20 | After=network.target
21 |
22 | [Service]
23 | ExecStart={formattedExecutablePath}
24 | Restart=always
25 | RestartSec=5s
26 | User=root
27 | WorkingDirectory={workingDirectory}
28 | KillSignal=SIGINT
29 | StandardOutput=append:{logFilePath}
30 | StandardError=append:{logFilePath}
31 | LimitNOFILE=65536
32 |
33 | [Install]
34 | WantedBy=multi-user.target
35 | ";
36 |
37 | // Write the service file
38 | System.IO.File.WriteAllText(serviceFilePath, serviceContent);
39 |
40 | // Set correct permissions
41 | Bash.Execute_Script("Setting correct permissions", false,
42 | $"chmod 644 {serviceFilePath}");
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/NetLock-RMM-Server/Helper/Base64.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 |
3 | namespace Base64
4 | {
5 | internal class Handler
6 | {
7 | public static async Task Encode(string content)
8 | {
9 | byte[] data = Encoding.UTF8.GetBytes(content);
10 | return await Task.Run(() => Convert.ToBase64String(data));
11 | }
12 |
13 | public static async Task Decode(string encodedContent)
14 | {
15 | try
16 | {
17 | byte[] data = Convert.FromBase64String(encodedContent);
18 | return await Task.Run(() => Encoding.UTF8.GetString(data));
19 | }
20 | catch (Exception ex)
21 | {
22 | Logging.Handler.Error("Base64.Handler.Decode", "", ex.Message);
23 | return "";
24 | }
25 | }
26 |
27 |
28 | /*public static void Write_File(string path, string base64)
29 | {
30 | try
31 | {
32 | File.WriteAllText(path, DecodeAsync(base64));
33 | }
34 | catch (Exception ex)
35 | {
36 | Logging.Handler.Error("Helper.Base64.Write_File", "failed", "Details: " + Environment.NewLine +
37 | "Path: " + path + Environment.NewLine +
38 | "Base64: " + base64 + Environment.NewLine +
39 | "Error: " + ex.Message);
40 | }
41 | }*/
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/NetLock RMM Agent Remote/NetLock RMM Agent Remote.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.12.35514.174
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetLock RMM Agent Remote", "NetLock RMM Agent Remote.csproj", "{00844A40-E629-40A5-B49C-5477B222044A}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Debug|x64 = Debug|x64
12 | Release|Any CPU = Release|Any CPU
13 | Release|x64 = Release|x64
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {00844A40-E629-40A5-B49C-5477B222044A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {00844A40-E629-40A5-B49C-5477B222044A}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {00844A40-E629-40A5-B49C-5477B222044A}.Debug|x64.ActiveCfg = Debug|x64
19 | {00844A40-E629-40A5-B49C-5477B222044A}.Debug|x64.Build.0 = Debug|x64
20 | {00844A40-E629-40A5-B49C-5477B222044A}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {00844A40-E629-40A5-B49C-5477B222044A}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {00844A40-E629-40A5-B49C-5477B222044A}.Release|x64.ActiveCfg = Release|x64
23 | {00844A40-E629-40A5-B49C-5477B222044A}.Release|x64.Build.0 = Release|x64
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/Classes/File Server/Handler.cs:
--------------------------------------------------------------------------------
1 | using MySqlConnector;
2 | using System.Data.Common;
3 |
4 | namespace NetLock_RMM_Web_Console.Classes.File_Server
5 | {
6 | public class Handler
7 | {
8 | // Get password of file by guid from database
9 | public static async Task Get_File_Password_By_Guid(string guid)
10 | {
11 | try
12 | {
13 | string password = "";
14 | using (var conn = new MySqlConnection(Configuration.MySQL.Connection_String))
15 | {
16 | conn.Open();
17 | using (var cmd = new MySqlCommand("SELECT password FROM files WHERE guid = @guid", conn))
18 | {
19 | cmd.Parameters.AddWithValue("@guid", guid);
20 | using (var reader = cmd.ExecuteReader())
21 | {
22 | if (reader.Read())
23 | {
24 | password = reader.GetString(0);
25 | }
26 | }
27 | }
28 | }
29 | return password;
30 | }
31 | catch (Exception ex)
32 | {
33 | Logging.Handler.Error("File_Server.Handler.Get_File_Password_By_Guid", guid, ex.ToString());
34 | return String.Empty;
35 | }
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/NetLock RMM Tray Icon/NetLock RMM Tray Icon.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | WinExe
4 | net8.0
5 | enable
6 | true
7 | app.manifest
8 | true
9 | NetLock_RMM_Tray_Icon
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | None
20 | All
21 |
22 |
23 |
24 |
25 |
26 |
27 | Always
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/NetLock RMM Agent Comm/NetLock RMM Agent Comm.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | enable
6 | enable
7 | dotnet-NetLock_RMM_Agent_Comm-996a4a14-ff4d-462b-835a-8048ee189bfc
8 | NetLock_RMM_Agent_Comm
9 | NetLock_RMM_Agent_Comm
10 | AnyCPU;x64
11 |
12 |
13 |
14 | bin\Debug\net8.0\
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/NetLock RMM Agent Remote/Windows/Helper/ScreenControl/Shlwapi.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | namespace Windows.Helper.ScreenControl;
4 |
5 | // https://docs.microsoft.com/en-us/windows/win32/api/shlwapi/nf-shlwapi-isos
6 | public class Shlwapi
7 | {
8 | [DllImport("shlwapi.dll", SetLastError = true)]
9 | [return: MarshalAs(UnmanagedType.Bool)]
10 | public static extern bool IsOS(OsType osType);
11 | }
12 |
13 | public enum OsType
14 | {
15 | OS_WINDOWS = 0,
16 | OS_NT = 1,
17 | OS_WIN95ORGREATER = 2,
18 | OS_NT4ORGREATER = 3,
19 | OS_WIN98ORGREATER = 5,
20 | OS_WIN98_GOLD = 6,
21 | OS_WIN2000ORGREATER = 7,
22 | OS_WIN2000PRO = 8,
23 | OS_WIN2000SERVER = 9,
24 | OS_WIN2000ADVSERVER = 10,
25 | OS_WIN2000DATACENTER = 11,
26 | OS_WIN2000TERMINAL = 12,
27 | OS_EMBEDDED = 13,
28 | OS_TERMINALCLIENT = 14,
29 | OS_TERMINALREMOTEADMIN = 15,
30 | OS_WIN95_GOLD = 16,
31 | OS_MEORGREATER = 17,
32 | OS_XPORGREATER = 18,
33 | OS_HOME = 19,
34 | OS_PROFESSIONAL = 20,
35 | OS_DATACENTER = 21,
36 | OS_ADVSERVER = 22,
37 | OS_SERVER = 23,
38 | OS_TERMINALSERVER = 24,
39 | OS_PERSONALTERMINALSERVER = 25,
40 | OS_FASTUSERSWITCHING = 26,
41 | OS_WELCOMELOGONUI = 27,
42 | OS_DOMAINMEMBER = 28,
43 | OS_ANYSERVER = 29,
44 | OS_WOW6432 = 30,
45 | OS_WEBSERVER = 31,
46 | OS_SMALLBUSINESSSERVER = 32,
47 | OS_TABLETPC = 33,
48 | OS_SERVERADMINUI = 34,
49 | OS_MEDIACENTER = 35,
50 | OS_APPLIANCE = 36,
51 | }
52 |
--------------------------------------------------------------------------------
/NetLock RMM Agent Remote/NetLock RMM Agent Remote.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net8.0
5 | enable
6 | enable
7 | dotnet-NetLock_RMM_Agent_Remote-069835b7-0e4e-42de-bf97-f65bf75bb24d
8 | NetLock_RMM_Agent_Remote
9 | NetLock_RMM_Agent_Remote
10 | AnyCPU;x64
11 |
12 |
13 |
14 |
15 | true
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/NetLock-RMM-User-Process/NetLock RMM User Process.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.10.35013.160
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetLock RMM User Process", "NetLock RMM User Process.csproj", "{F4AB4F9E-D0FE-4DFD-A6A1-BEC5C464EB0D}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Debug|x64 = Debug|x64
12 | Release|Any CPU = Release|Any CPU
13 | Release|x64 = Release|x64
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {F4AB4F9E-D0FE-4DFD-A6A1-BEC5C464EB0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {F4AB4F9E-D0FE-4DFD-A6A1-BEC5C464EB0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {F4AB4F9E-D0FE-4DFD-A6A1-BEC5C464EB0D}.Debug|x64.ActiveCfg = Debug|x64
19 | {F4AB4F9E-D0FE-4DFD-A6A1-BEC5C464EB0D}.Debug|x64.Build.0 = Debug|x64
20 | {F4AB4F9E-D0FE-4DFD-A6A1-BEC5C464EB0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {F4AB4F9E-D0FE-4DFD-A6A1-BEC5C464EB0D}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {F4AB4F9E-D0FE-4DFD-A6A1-BEC5C464EB0D}.Release|x64.ActiveCfg = Release|x64
23 | {F4AB4F9E-D0FE-4DFD-A6A1-BEC5C464EB0D}.Release|x64.Build.0 = Release|x64
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {DE2A22C4-4B10-4879-A3AE-5349CC927269}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/Components/Routes.razor:
--------------------------------------------------------------------------------
1 | @inject NavigationManager NavigationManager
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | Sorry, you're not authorized to view this page.
10 |
11 | @{
12 | NavigationManager.NavigateTo("/", true);
13 | }
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | Not found
27 |
28 | Sorry, there's nothing at this address.
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/NetLock RMM Agent Comm/Global/Helper/Process_User.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Diagnostics;
7 | using System.IO;
8 | using System.Security.Cryptography;
9 | using System.Runtime.InteropServices;
10 | using System.Security.Principal;
11 |
12 | namespace Global.Helper
13 | {
14 | internal class Process_User
15 | {
16 | public static string Get(Process process)
17 | {
18 | IntPtr processHandle = IntPtr.Zero;
19 | try
20 | {
21 | OpenProcessToken(process.Handle, 8, out processHandle);
22 | WindowsIdentity wi = new WindowsIdentity(processHandle);
23 | string user = wi.Name;
24 | return user.Contains(@"\") ? user.Substring(user.IndexOf(@"\") + 1) : user;
25 | }
26 | catch
27 | {
28 | return null;
29 | }
30 | finally
31 | {
32 | if (processHandle != IntPtr.Zero)
33 | {
34 | CloseHandle(processHandle);
35 | }
36 | }
37 | }
38 |
39 | [DllImport("advapi32.dll", SetLastError = true)]
40 | private static extern bool OpenProcessToken(IntPtr ProcessHandle, uint DesiredAccess, out IntPtr TokenHandle);
41 | [DllImport("kernel32.dll", SetLastError = true)]
42 | [return: MarshalAs(UnmanagedType.Bool)]
43 | private static extern bool CloseHandle(IntPtr hObject);
44 |
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Warning",
5 | "Microsoft": "Error",
6 | "Microsoft.Hosting.Lifetime": "Warning"
7 | },
8 | "Custom": {
9 | "Enabled": true
10 | }
11 | },
12 | "AllowedHosts": "*",
13 | "Kestrel": {
14 | "Endpoint": {
15 | "Http": {
16 | "Enabled": true,
17 | "Port": 5000
18 | },
19 | "Https": {
20 | "Enabled": false,
21 | "Port": 5001,
22 | "Force": false,
23 | "Hsts": {
24 | "Enabled": false
25 | },
26 | "Certificate": {
27 | "Path": "C:\\temp\\localhost.pfx",
28 | "Password": ""
29 | }
30 | }
31 | },
32 | "KnownProxies": []
33 | },
34 | "NetLock_Remote_Server": {
35 | "Server": "127.0.0.1",
36 | "Port": 7080,
37 | "UseSSL": false
38 | },
39 | "NetLock_File_Server": {
40 | "Server": "127.0.0.1",
41 | "Port": 7080,
42 | "UseSSL": false
43 | },
44 | "MySQL": {
45 | "Server": "127.0.0.1",
46 | "Port": 3306,
47 | "Database": "netlock",
48 | "User": "root",
49 | "Password": "Bochum234",
50 | "SslMode": "None",
51 | "AdditionalConnectionParameters": "AllowPublicKeyRetrieval=True;"
52 | },
53 | "Webinterface": {
54 | "Language": "en-US",
55 | "Membership_Reminder": false,
56 | "PublicOverrideUrl": "http://localhost:7080"
57 | },
58 | "Members_Portal_Api": {
59 | "Enabled": true,
60 | "Cloud": false,
61 | "ApiKeyOverride": "2b77005b-61a3-4fa8-83c9-5b9f3621f758-ba910728-1b53-4cb5-9159-3eb4140a2eed",
62 | "ServerGuid": "Test-Guid"
63 | }
64 | }
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/Classes/Setup/Directories.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace NetLock_RMM_Web_Console.Classes.Setup
3 | {
4 | public class Directories
5 | {
6 | public static void Check_Directories()
7 | {
8 | // Create the directories if they do not exist
9 | if (!Directory.Exists(Application_Paths.logs_dir))
10 | Directory.CreateDirectory(Application_Paths.logs_dir);
11 |
12 | if (!Directory.Exists(Application_Paths.internal_dir))
13 | Directory.CreateDirectory(Application_Paths.internal_dir);
14 |
15 | if (!Directory.Exists(Application_Paths.internal_temp_dir))
16 | Directory.CreateDirectory(Application_Paths.internal_temp_dir);
17 |
18 | if(!Directory.Exists(Application_Paths._private_files_devices))
19 | Directory.CreateDirectory(Application_Paths._private_files_devices);
20 |
21 | if (!Directory.Exists(Application_Paths.certificates_path))
22 | Directory.CreateDirectory(Application_Paths.certificates_path);
23 |
24 | if (!Directory.Exists(Application_Paths.internal_recordings_dir))
25 | Directory.CreateDirectory(Application_Paths.internal_recordings_dir);
26 | }
27 |
28 | public static void Delete_Directories()
29 | {
30 | if (Directory.Exists(Application_Paths.internal_temp_dir))
31 | Directory.Delete(Application_Paths.internal_temp_dir, true);
32 |
33 | if (Directory.Exists(Application_Paths.logs_dir))
34 | Directory.Delete(Application_Paths.logs_dir, true);
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/Components/Pages/Collections/Scripts/Community Scripts/Publish_Dialog.razor:
--------------------------------------------------------------------------------
1 | @using System.Security.Claims
2 |
3 | @inject AuthenticationStateProvider AuthenticationStateProvider
4 | @inject NavigationManager NavigationManager
5 | @inject IDialogService DialogService
6 |
7 |
8 |
9 |
10 |
11 | If you'd like community members to be able to contact you with feedback, you may include your contact details.
12 |
13 |
14 | Cancel
15 | Publish
16 |
17 |
18 |
19 | @code {
20 | [CascadingParameter] IMudDialogInstance MudDialog { get; set; }
21 | public string FirstInput { get; set; } = string.Empty;
22 |
23 | protected override async Task OnInitializedAsync()
24 | {
25 | // Get the current user from the authentication state
26 | var user = (await AuthenticationStateProvider.GetAuthenticationStateAsync()).User;
27 |
28 | // Check if user is authenticated
29 | if (user?.Identity is not { IsAuthenticated: true })
30 | {
31 | NavigationManager.NavigateTo("/login", true);
32 | return;
33 | }
34 | }
35 |
36 | void Submit()
37 | {
38 | MudDialog.Close(DialogResult.Ok(FirstInput));
39 | }
40 |
41 | void Cancel()
42 | {
43 | MudDialog.Cancel();
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/NetLock-RMM-Server/Helper/Random.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Randomizer
8 | {
9 | public class Handler
10 | {
11 | public static string Generate_Password(bool special, int length)
12 | {
13 | string chars = null;
14 |
15 | System.Random random = new System.Random();
16 | if (special)
17 | chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!§$%&/()=?*[]#-";
18 | else
19 | chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
20 |
21 | return new string(Enumerable.Repeat(chars, length).Select(s => s[random.Next(s.Length)]).ToArray());
22 | }
23 |
24 | public static string Token(bool special, int length)
25 | {
26 | string chars = null;
27 |
28 | System.Random random = new System.Random();
29 | if (special)
30 | chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!§$%&/()=?*[]#-";
31 | else
32 | chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
33 |
34 | return new string(Enumerable.Repeat(chars, length).Select(s => s[random.Next(s.Length)]).ToArray());
35 | }
36 |
37 | public static string Windows_Credentials(int length)
38 | {
39 | string chars = null;
40 |
41 | System.Random random = new System.Random();
42 | chars = "abcdefghijklmnopqrstuvwxyz0123456789";
43 |
44 | return new string(Enumerable.Repeat(chars, length).Select(s => s[random.Next(s.Length)]).ToArray());
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/Components/Shared/Export_Data_Dialog.razor:
--------------------------------------------------------------------------------
1 | @using MySqlConnector;
2 | @using System.Data.Common;
3 | @using System.Text.Json;
4 |
5 | @inject NavigationManager NavigationManager
6 | @inject ILocalStorageService localStorage
7 | @inject IDialogService DialogService
8 | @inject ISnackbar Snackbar
9 | @inject IStringLocalizer Localizer
10 |
11 |
12 |
13 | @Localizer["export_data"]
14 |
15 |
16 | @Localizer["text"]
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | @Localizer["cancel"]
25 | @Localizer["export"]
26 |
27 |
28 |
29 |
30 | @code {
31 |
32 | private string type = "Spreadsheet (.xlsx)";
33 |
34 | [CascadingParameter]
35 | private IMudDialogInstance MudDialog { get; set; } = default!;
36 |
37 | private bool Form_Valid()
38 | {
39 | if (String.IsNullOrEmpty(type))
40 | return true;
41 | else
42 | return false;
43 | }
44 |
45 | private void OK()
46 | {
47 | this.MudDialog.Close(DialogResult.Ok(type));
48 | }
49 |
50 | private void Cancel() => MudDialog.Cancel();
51 | }
--------------------------------------------------------------------------------
/NetLock RMM Agent Remote/Global/Configuration/Agent.cs:
--------------------------------------------------------------------------------
1 | namespace Global.Configuration
2 | {
3 | public class Agent
4 | {
5 | public static bool debug_mode { get; set; } = false; //enables/disables logging
6 | public static bool ssl { get; set; } = false;
7 | public static string package_guid { get; set; } = String.Empty;
8 | public static string communication_servers { get; set; } = String.Empty;
9 | public static string remote_servers { get; set; } = String.Empty;
10 | public static string update_servers { get; set; } = String.Empty;
11 | public static string trust_servers { get; set; } = String.Empty;
12 | public static string file_servers { get; set; } = String.Empty;
13 | public static string tenant_guid { get; set; } = String.Empty;
14 | public static string location_guid { get; set; } = String.Empty;
15 | public static string language { get; set; } = String.Empty;
16 | public static string http_https { get; set; } = String.Empty;
17 | public static string device_name { get; set; } = String.Empty;
18 | public static string hwid { get; set; } = String.Empty;
19 | public static string platform { get; set; } = String.Empty;
20 | }
21 |
22 | public class AgentSettings
23 | {
24 | public bool RemoteServiceEnabled { get; set; } = false;
25 | public bool RemoteShellEnabled { get; set; } = false;
26 | public bool RemoteFileBrowserEnabled { get; set; } = false;
27 | public bool RemoteTaskManagerEnabled { get; set; } = false;
28 | public bool RemoteServiceManagerEnabled { get; set; } = false;
29 | public bool RemoteScreenControlEnabled { get; set; } = false;
30 | public bool RemoteScreenControlUnattendedAccess { get; set; } = false;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/Components/Pages/Collections/Scripts/Community Scripts/Report_Dialog.razor:
--------------------------------------------------------------------------------
1 | @using System.Security.Claims
2 |
3 | @inject AuthenticationStateProvider AuthenticationStateProvider
4 | @inject NavigationManager NavigationManager
5 | @inject IDialogService DialogService
6 |
7 |
8 |
9 |
10 |
11 | @if (String.IsNullOrEmpty(FirstInput))
12 | {
13 | Please provide a reason for reporting this content. This will help us take appropriate action.
14 | }
15 |
16 |
17 | Cancel
18 | Report
19 |
20 |
21 |
22 | @code {
23 | [CascadingParameter] IMudDialogInstance MudDialog { get; set; }
24 | public string FirstInput { get; set; } = string.Empty;
25 |
26 | protected override async Task OnInitializedAsync()
27 | {
28 | // Get the current user from the authentication state
29 | var user = (await AuthenticationStateProvider.GetAuthenticationStateAsync()).User;
30 |
31 | // Check if user is authenticated
32 | if (user?.Identity is not { IsAuthenticated: true })
33 | {
34 | NavigationManager.NavigateTo("/login", true);
35 | return;
36 | }
37 | }
38 |
39 | void Submit()
40 | {
41 | MudDialog.Close(DialogResult.Ok(FirstInput));
42 | }
43 |
44 | void Cancel()
45 | {
46 | MudDialog.Cancel();
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/Classes/Authentication/TokenService.cs:
--------------------------------------------------------------------------------
1 | using System.IdentityModel.Tokens.Jwt;
2 | using System.Security.Claims;
3 | using Microsoft.IdentityModel.Tokens;
4 | using System.Text;
5 | using NetLock_RMM_Web_Console.Classes.Authentication;
6 | using System.Configuration;
7 |
8 | public class TokenService
9 | {
10 | private readonly SymmetricSecurityKey _signingKey = new(Encoding.UTF8.GetBytes(NetLock_RMM_Web_Console.Configuration.Web_Console.token_service_secret_key));
11 |
12 | public string GenerateToken(UserSession userSession)
13 | {
14 | try
15 | {
16 | var claims = new List
17 | {
18 | new(ClaimTypes.Email, userSession.UserName),
19 | new(ClaimTypes.Role, userSession.Role),
20 | };
21 |
22 | var tokenDescriptor = new SecurityTokenDescriptor
23 | {
24 | Subject = new ClaimsIdentity(claims),
25 | Expires = DateTime.UtcNow.AddHours(16), // 16 hours are a usual work day (with pause included and for dashboard monitoring)
26 | SigningCredentials = new SigningCredentials(_signingKey, SecurityAlgorithms.HmacSha256Signature),
27 | Issuer = CustomAuthenticationStateProvider.Issuer, // New entry
28 | Audience = CustomAuthenticationStateProvider.Audience // New entry
29 | };
30 |
31 | var tokenHandler = new JwtSecurityTokenHandler();
32 | var token = tokenHandler.CreateToken(tokenDescriptor);
33 |
34 | return tokenHandler.WriteToken(token);
35 | }
36 | catch (Exception ex)
37 | {
38 | Logging.Handler.Error("Classes.Authentification.TokenService", "GenerateToken", ex.ToString());
39 |
40 | // Log the exception if needed
41 | return string.Empty;
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/NetLock-RMM-Server/Helper/System_Information/Server_Information_Service.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Extensions.Hosting;
2 | using System;
3 | using System.Configuration;
4 | using System.Threading;
5 | using System.Threading.Tasks;
6 |
7 | public class Server_Information_Service : BackgroundService
8 | {
9 | private readonly TimeSpan _interval = TimeSpan.FromMinutes(1);
10 |
11 | protected override async Task ExecuteAsync(CancellationToken stoppingToken)
12 | {
13 | while (!stoppingToken.IsCancellationRequested)
14 | {
15 | try
16 | {
17 | await Update_Server_Information();
18 | await Task.Delay(_interval, stoppingToken);
19 | }
20 | catch (TaskCanceledException ex)
21 | {
22 | Logging.Handler.Debug("Server_Information_Service.ExecuteAsync", "Task canceled: ", ex.ToString());
23 | // Task was terminated, terminate cleanly
24 | break;
25 | }
26 | catch (Exception ex)
27 | {
28 | Logging.Handler.Error("ServerInformationService", "ExecuteAsync", ex.ToString());
29 | }
30 | }
31 | }
32 |
33 | private async Task Update_Server_Information()
34 | {
35 | try
36 | {
37 | Logging.Handler.Debug("Server_Information_Service.UpdateServerInformation", "Server Information Update Task started at:", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
38 | await NetLock_RMM_Server.MySQL.Handler.Update_Server_Information();
39 | Logging.Handler.Debug("Server_Information_Service.UpdateServerInformation", "Server Information Update Task finished at:", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
40 | }
41 | catch (Exception ex)
42 | {
43 | Logging.Handler.Error("ServerInformationService", "UpdateServerInformation", ex.ToString());
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/NetLock RMM Agent Comm/Global/Helper/Network.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Net.NetworkInformation;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Global.Helper
9 | {
10 | internal class Network
11 | {
12 | public static string Get_Local_IP_Address()
13 | {
14 | try
15 | {
16 | // Retrieve all network interfaces of the system
17 | NetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
18 |
19 | // Select the first network interface that has a valid IPv4 address
20 | NetworkInterface ipv4Interface = networkInterfaces.FirstOrDefault(
21 | nic => nic.NetworkInterfaceType != NetworkInterfaceType.Loopback &&
22 | nic.NetworkInterfaceType != NetworkInterfaceType.Tunnel &&
23 | nic.GetIPProperties().GatewayAddresses.Any() &&
24 | nic.GetIPProperties().UnicastAddresses.Any(a => a.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork));
25 |
26 | if (ipv4Interface != null)
27 | {
28 | // Return the first valid IPv4 address of the selected network adapter
29 | return ipv4Interface.GetIPProperties().UnicastAddresses
30 | .FirstOrDefault(a => a.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
31 | .Address.ToString();
32 | }
33 | else
34 | {
35 | return "-";
36 | }
37 | }
38 | catch (Exception ex)
39 | {
40 | Logging.Error("Global.Helper.Network", "Get_Local_IP_Address", ex.ToString());
41 | return "-";
42 | }
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/NetLock RMM Agent Health/Linux/Helper/Linux.cs:
--------------------------------------------------------------------------------
1 | using Global.Helper;
2 | using Helper;
3 | using NetLock_RMM_Agent_Health;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace Linux.Helper
11 | {
12 | internal class Linux
13 | {
14 | // Helper method to create the installer service
15 | public static void CreateInstallerService()
16 | {
17 | // Set permissions
18 | Logging.Debug("Main", "Argument", $"sudo chmod +x \"{Application_Paths.c_temp_netlock_installer_path}\"");
19 | Bash.Execute_Script("Installer Permissions", false, $"sudo chmod +x \"{Application_Paths.c_temp_netlock_installer_path}\"");
20 |
21 | // Compose systemd service file content
22 | string serviceContent = @$"[Unit]
23 | Description=netlock-rmm-agent-installer
24 | After=network.target
25 |
26 | [Service]
27 | ExecStart=""/tmp/netlock rmm/installer/NetLock_RMM_Agent_Installer"" ""fix"" ""/var/0x101 Cyber Security/NetLock RMM/Comm Agent/server_config.json""
28 | Restart=no
29 | RestartSec=5s
30 | User=root
31 | WorkingDirectory=/tmp/netlock rmm/installer
32 | KillSignal=SIGINT
33 | StandardOutput=append:/var/log/netlock-rmm-agent-installer.log
34 | StandardError=append:/var/log/netlock-rmm-agent-installer.log
35 | LimitNOFILE=65536
36 |
37 | [Install]
38 | WantedBy=multi-user.target
39 | ";
40 |
41 | // Write the service file
42 | System.IO.File.WriteAllText("/etc/systemd/system/netlock-rmm-agent-installer.service", serviceContent);
43 |
44 | // Set correct permissions on the service file
45 | Bash.Execute_Script("Set service file permissions", false, $"chmod 644 \"/etc/systemd/system/netlock-rmm-agent-installer.service\"");
46 |
47 | // Reload daemon
48 | Bash.Execute_Script("Reload services", false, "systemctl daemon-reload");
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/NetLock RMM Agent Comm/Global/Helper/Random.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Security.Cryptography;
7 |
8 | namespace Global.Helper
9 | {
10 | public class Randomizer
11 | {
12 | public static async Task Generate_Access_Key(int length)
13 | {
14 | string ValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
15 |
16 | try
17 | {
18 | using (var rng = new RNGCryptoServiceProvider())
19 | {
20 | byte[] randomBytes = new byte[length];
21 | rng.GetBytes(randomBytes);
22 |
23 | StringBuilder stringBuilder = new StringBuilder(length);
24 | foreach (byte b in randomBytes)
25 | {
26 | stringBuilder.Append(ValidChars[b % ValidChars.Length]);
27 | }
28 |
29 | return stringBuilder.ToString();
30 | }
31 | }
32 | catch (Exception ex)
33 | {
34 | Logging.Error("Randomizer.Handler.Generate_Access_Key", "", ex.Message);
35 | return String.Empty;
36 | }
37 | }
38 |
39 | public static string Standard(int length)
40 | {
41 | try
42 | {
43 | Random random = new Random();
44 | const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
45 | string random_id = new string(Enumerable.Repeat(chars, length).Select(s => s[random.Next(s.Length)]).ToArray());
46 |
47 | return random_id;
48 | }
49 | catch (Exception ex)
50 | {
51 | Logging.Error("Randomizer.Handler.Standard", "", ex.ToString());
52 | return "1234567890";
53 | }
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/NetLock RMM Agent Remote/Global/Helper/Randomizer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Security.Cryptography;
7 |
8 | namespace Global.Helper
9 | {
10 | public class Randomizer
11 | {
12 | public static async Task Generate_Access_Key(int length)
13 | {
14 | string ValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
15 |
16 | try
17 | {
18 | using (var rng = new RNGCryptoServiceProvider())
19 | {
20 | byte[] randomBytes = new byte[length];
21 | rng.GetBytes(randomBytes);
22 |
23 | StringBuilder stringBuilder = new StringBuilder(length);
24 | foreach (byte b in randomBytes)
25 | {
26 | stringBuilder.Append(ValidChars[b % ValidChars.Length]);
27 | }
28 |
29 | return stringBuilder.ToString();
30 | }
31 | }
32 | catch (Exception ex)
33 | {
34 | Logging.Error("Randomizer.Handler.Generate_Access_Key", "", ex.Message);
35 | return string.Empty;
36 | }
37 | }
38 |
39 | public static string Standard(int length)
40 | {
41 | try
42 | {
43 | Random random = new Random();
44 | const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
45 | string random_id = new string(Enumerable.Repeat(chars, length).Select(s => s[random.Next(s.Length)]).ToArray());
46 |
47 | return random_id;
48 | }
49 | catch (Exception ex)
50 | {
51 | Logging.Error("Randomizer.Handler.Standard", "", ex.ToString());
52 | return "1234567890";
53 | }
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/NetLock-RMM-Server/HWID_System/winid.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Management;
4 | using System.Security.Cryptography;
5 | using System.Text;
6 |
7 | namespace _x101.HWID_System
8 | {
9 | internal class WindowsId
10 | {
11 | [System.Reflection.ObfuscationAttribute(Feature = "Virtualization", Exclude = false)]
12 |
13 | public static string GetWindowsId()
14 | {
15 | try
16 | {
17 | string cpuId = GetHardwareId("Win32_Processor", "ProcessorId");
18 | string biosSerial = GetHardwareId("Win32_BIOS", "SerialNumber");
19 | string motherboardSerial = GetHardwareId("Win32_BaseBoard", "SerialNumber");
20 | string diskSerial = GetHardwareId("Win32_DiskDrive", "SerialNumber");
21 |
22 | // Combine identifiers
23 | string combinedId = $"{cpuId}{biosSerial}{motherboardSerial}{diskSerial}";
24 |
25 | // Generate MD5 hash
26 | using (var md5 = MD5.Create())
27 | {
28 | byte[] hashBytes = md5.ComputeHash(Encoding.UTF8.GetBytes(combinedId));
29 | return BitConverter.ToString(hashBytes).Replace("-", "");
30 | }
31 | }
32 | catch
33 | {
34 | return "Unknown";
35 | }
36 | }
37 |
38 | private static string GetHardwareId(string wmiClass, string wmiProperty)
39 | {
40 | try
41 | {
42 | using (var searcher = new ManagementObjectSearcher($"SELECT {wmiProperty} FROM {wmiClass}"))
43 | {
44 | return searcher.Get()
45 | .Cast()
46 | .Select(mo => mo[wmiProperty]?.ToString())
47 | .FirstOrDefault() ?? "";
48 | }
49 | }
50 | catch
51 | {
52 | return "";
53 | }
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/NetLock RMM Agent Comm/HWID_System/winid.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Management;
4 | using System.Security.Cryptography;
5 | using System.Text;
6 |
7 | namespace _x101.HWID_System
8 | {
9 | internal class WindowsId
10 | {
11 | [System.Reflection.ObfuscationAttribute(Feature = "Virtualization", Exclude = false)]
12 |
13 | public static string GetWindowsId()
14 | {
15 | try
16 | {
17 | string cpuId = GetHardwareId("Win32_Processor", "ProcessorId");
18 | string biosSerial = GetHardwareId("Win32_BIOS", "SerialNumber");
19 | string motherboardSerial = GetHardwareId("Win32_BaseBoard", "SerialNumber");
20 | string diskSerial = GetHardwareId("Win32_DiskDrive", "SerialNumber");
21 |
22 | // Combine identifiers
23 | string combinedId = $"{cpuId}{biosSerial}{motherboardSerial}{diskSerial}";
24 |
25 | // Generate MD5 hash
26 | using (var md5 = MD5.Create())
27 | {
28 | byte[] hashBytes = md5.ComputeHash(Encoding.UTF8.GetBytes(combinedId));
29 | return BitConverter.ToString(hashBytes).Replace("-", "");
30 | }
31 | }
32 | catch
33 | {
34 | return "Unknown";
35 | }
36 | }
37 |
38 | private static string GetHardwareId(string wmiClass, string wmiProperty)
39 | {
40 | try
41 | {
42 | using (var searcher = new ManagementObjectSearcher($"SELECT {wmiProperty} FROM {wmiClass}"))
43 | {
44 | return searcher.Get()
45 | .Cast()
46 | .Select(mo => mo[wmiProperty]?.ToString())
47 | .FirstOrDefault() ?? "";
48 | }
49 | }
50 | catch
51 | {
52 | return "";
53 | }
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/NetLock RMM Agent Remote/HWID_System/winid.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Management;
4 | using System.Security.Cryptography;
5 | using System.Text;
6 |
7 | namespace _x101.HWID_System
8 | {
9 | internal class WindowsId
10 | {
11 | [System.Reflection.ObfuscationAttribute(Feature = "Virtualization", Exclude = false)]
12 |
13 | public static string GetWindowsId()
14 | {
15 | try
16 | {
17 | string cpuId = GetHardwareId("Win32_Processor", "ProcessorId");
18 | string biosSerial = GetHardwareId("Win32_BIOS", "SerialNumber");
19 | string motherboardSerial = GetHardwareId("Win32_BaseBoard", "SerialNumber");
20 | string diskSerial = GetHardwareId("Win32_DiskDrive", "SerialNumber");
21 |
22 | // Combine identifiers
23 | string combinedId = $"{cpuId}{biosSerial}{motherboardSerial}{diskSerial}";
24 |
25 | // Generate MD5 hash
26 | using (var md5 = MD5.Create())
27 | {
28 | byte[] hashBytes = md5.ComputeHash(Encoding.UTF8.GetBytes(combinedId));
29 | return BitConverter.ToString(hashBytes).Replace("-", "");
30 | }
31 | }
32 | catch
33 | {
34 | return "Unknown";
35 | }
36 | }
37 |
38 | private static string GetHardwareId(string wmiClass, string wmiProperty)
39 | {
40 | try
41 | {
42 | using (var searcher = new ManagementObjectSearcher($"SELECT {wmiProperty} FROM {wmiClass}"))
43 | {
44 | return searcher.Get()
45 | .Cast()
46 | .Select(mo => mo[wmiProperty]?.ToString())
47 | .FirstOrDefault() ?? "";
48 | }
49 | }
50 | catch
51 | {
52 | return "";
53 | }
54 | }
55 | }
56 | }
--------------------------------------------------------------------------------
/NetLock-RMM-User-Process/Windows/Helper/Sas_Diagnostics.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Security.Principal;
4 | using System.Runtime.InteropServices;
5 |
6 | namespace NetLock_RMM_User_Process.Windows.Helper
7 | {
8 | internal class Sas_Diagnostics
9 | {
10 | [DllImport("kernel32.dll")]
11 | static extern uint WTSGetActiveConsoleSessionId();
12 |
13 | [DllImport("wtsapi32.dll", SetLastError = true)]
14 | static extern bool WTSQueryUserToken(uint SessionId, out nint phToken);
15 |
16 | public static void LogContext()
17 | {
18 | uint sessionId = WTSGetActiveConsoleSessionId();
19 | Handler.Debug("Windows.Helper.ScreenControl.Sas_Diagnostics.LogContext", "LogContext", $"ActiveConsoleSessionId: {sessionId}");
20 | Console.WriteLine($"[SAS] ActiveConsoleSessionId = {sessionId}");
21 |
22 | bool isElevated = new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);
23 | Handler.Debug("Windows.Helper.ScreenControl.Sas_Diagnostics.LogContext", "LogContext", $"IsElevated/Administrator: {isElevated}");
24 | Console.WriteLine($"[SAS] IsElevated/Administrator = {isElevated}");
25 |
26 | bool isLocalSystem = WindowsIdentity.GetCurrent().Name.Equals("NT AUTHORITY\\SYSTEM", StringComparison.OrdinalIgnoreCase);
27 | Handler.Debug("Windows.Helper.ScreenControl.Sas_Diagnostics.LogContext", "LogContext", $"IsLocalSystem: {isLocalSystem}");
28 | Console.WriteLine($"[SAS] Running as LocalSystem = {isLocalSystem}");
29 |
30 | bool gotToken = WTSQueryUserToken(sessionId, out var userToken);
31 | Handler.Debug("Windows.Helper.ScreenControl.Sas_Diagnostics.LogContext", "LogContext", $"WTSQueryUserToken({sessionId}) -> {gotToken}");
32 | Console.WriteLine($"[SAS] WTSQueryUserToken({sessionId}) -> {gotToken}");
33 | if (gotToken) CloseHandle(userToken);
34 | }
35 |
36 | [DllImport("kernel32.dll", SetLastError = true)]
37 | static extern bool CloseHandle(nint hObject);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/NetLock RMM Agent Remote/Global/Helper/Base64.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.IO;
7 |
8 | namespace Global.Helper
9 | {
10 | internal class Base64
11 | {
12 | public static async Task Encode(string content)
13 | {
14 | byte[] data = Encoding.UTF8.GetBytes(content);
15 | return await Task.Run(() => Convert.ToBase64String(data));
16 | }
17 |
18 | public static async Task Decode(string encodedContent)
19 | {
20 | try
21 | {
22 | byte[] data = Convert.FromBase64String(encodedContent);
23 | return await Task.Run(() => Encoding.UTF8.GetString(data));
24 | }
25 | catch (Exception ex)
26 | {
27 | //Logging.Handler.Error("Base64.Handler.Decode", "", ex.Message);
28 | return "";
29 | }
30 | }
31 |
32 | public static string Decode_Syncron(string encodedContent)
33 | {
34 | try
35 | {
36 | byte[] data = Convert.FromBase64String(encodedContent);
37 | return Encoding.UTF8.GetString(data);
38 | }
39 | catch (Exception ex)
40 | {
41 | //Logging.Handler.Error("Base64.Handler.Decode", "", ex.Message);
42 | return "";
43 | }
44 | }
45 |
46 |
47 | /*public static void Write_File(string path, string base64)
48 | {
49 | try
50 | {
51 | File.WriteAllText(path, DecodeAsync(base64));
52 | }
53 | catch (Exception ex)
54 | {
55 | Logging.Handler.Error("Helper.Base64.Write_File", "failed", "Details: " + Environment.NewLine +
56 | "Path: " + path + Environment.NewLine +
57 | "Base64: " + base64 + Environment.NewLine +
58 | "Error: " + ex.Message);
59 | }
60 | }*/
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/Components/Pages/Devices/Dialogs/Remote_File_Browser/Create_Directory_Dialog.razor:
--------------------------------------------------------------------------------
1 | @using MySqlConnector;
2 | @using System.Data.Common;
3 | @using System.Text.Json;
4 | @using System.Security.Claims
5 |
6 | @inject NavigationManager NavigationManager
7 | @inject ILocalStorageService localStorage
8 | @inject IDialogService DialogService
9 | @inject ISnackbar Snackbar
10 | @inject IJSRuntime JSRuntime
11 | @inject IStringLocalizer Localizer
12 | @inject AuthenticationStateProvider AuthenticationStateProvider
13 |
14 |
15 |
16 | @Localizer["title"]
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | @Localizer["confirm"]
26 |
27 |
28 |
29 | @code {
30 |
31 | [CascadingParameter] IMudDialogInstance MudDialog { get; set; }
32 |
33 | private string directory = String.Empty;
34 |
35 | protected override async Task OnInitializedAsync()
36 | {
37 | // Get the current user from the authentication state
38 | var user = (await AuthenticationStateProvider.GetAuthenticationStateAsync()).User;
39 |
40 | // Check if user is authenticated
41 | if (user?.Identity is not { IsAuthenticated: true })
42 | {
43 | NavigationManager.NavigateTo("/login", true);
44 | return;
45 | }
46 | }
47 |
48 | private async Task OK()
49 | {
50 | this.Snackbar.Configuration.ShowCloseIcon = true;
51 | this.Snackbar.Configuration.PositionClass = Defaults.Classes.Position.BottomRight;
52 |
53 | this.MudDialog.Close(DialogResult.Ok(directory));
54 | }
55 |
56 | private void Cancel() => MudDialog.Cancel();
57 | }
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/Components/Pages/Devices/Dialogs/Remote_File_Browser/Rename_File_Dialog.razor:
--------------------------------------------------------------------------------
1 | @using MySqlConnector;
2 | @using System.Data.Common;
3 | @using System.Text.Json;
4 | @using System.Security.Claims
5 |
6 | @inject NavigationManager NavigationManager
7 | @inject ILocalStorageService localStorage
8 | @inject IDialogService DialogService
9 | @inject ISnackbar Snackbar
10 | @inject IJSRuntime JSRuntime
11 | @inject IStringLocalizer Localizer
12 | @inject AuthenticationStateProvider AuthenticationStateProvider
13 |
14 |
15 |
16 | @Localizer["title"]
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | @Localizer["confirm"]
26 |
27 |
28 |
29 | @code {
30 |
31 | [CascadingParameter] IMudDialogInstance MudDialog { get; set; }
32 | [Parameter] public string _remote_file_path { get; set; }
33 |
34 | protected override async Task OnInitializedAsync()
35 | {
36 | // Get the current user from the authentication state
37 | var user = (await AuthenticationStateProvider.GetAuthenticationStateAsync()).User;
38 |
39 | // Check if user is authenticated
40 | if (user?.Identity is not { IsAuthenticated: true })
41 | {
42 | NavigationManager.NavigateTo("/login", true);
43 | return;
44 | }
45 | }
46 |
47 | private async Task OK()
48 | {
49 | this.Snackbar.Configuration.ShowCloseIcon = true;
50 | this.Snackbar.Configuration.PositionClass = Defaults.Classes.Position.BottomRight;
51 |
52 | this.MudDialog.Close(DialogResult.Ok(_remote_file_path));
53 | }
54 |
55 | private void Cancel() => MudDialog.Cancel();
56 | }
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/Components/Pages/Devices/Dialogs/Remote_File_Browser/Move_Directory_Dialog.razor:
--------------------------------------------------------------------------------
1 | @using MySqlConnector;
2 | @using System.Data.Common;
3 | @using System.Text.Json;
4 | @using System.Security.Claims
5 |
6 | @inject NavigationManager NavigationManager
7 | @inject ILocalStorageService localStorage
8 | @inject IDialogService DialogService
9 | @inject ISnackbar Snackbar
10 | @inject IJSRuntime JSRuntime
11 | @inject IStringLocalizer Localizer
12 | @inject AuthenticationStateProvider AuthenticationStateProvider
13 |
14 |
15 |
16 | @Localizer["title"]
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | @Localizer["confirm"]
26 |
27 |
28 |
29 | @code {
30 |
31 | [CascadingParameter] IMudDialogInstance MudDialog { get; set; }
32 | [Parameter] public string _remote_file_path { get; set; }
33 |
34 | protected override async Task OnInitializedAsync()
35 | {
36 | // Get the current user from the authentication state
37 | var user = (await AuthenticationStateProvider.GetAuthenticationStateAsync()).User;
38 |
39 | // Check if user is authenticated
40 | if (user?.Identity is not { IsAuthenticated: true })
41 | {
42 | NavigationManager.NavigateTo("/login", true);
43 | return;
44 | }
45 | }
46 |
47 | private async Task OK()
48 | {
49 | this.Snackbar.Configuration.ShowCloseIcon = true;
50 | this.Snackbar.Configuration.PositionClass = Defaults.Classes.Position.BottomRight;
51 |
52 | this.MudDialog.Close(DialogResult.Ok(_remote_file_path));
53 | }
54 |
55 | private void Cancel() => MudDialog.Cancel();
56 | }
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/Components/Pages/Devices/Dialogs/Remote_File_Browser/Rename_Directory_Dialog.razor:
--------------------------------------------------------------------------------
1 | @using MySqlConnector;
2 | @using System.Data.Common;
3 | @using System.Text.Json;
4 | @using System.Security.Claims
5 |
6 | @inject NavigationManager NavigationManager
7 | @inject ILocalStorageService localStorage
8 | @inject IDialogService DialogService
9 | @inject ISnackbar Snackbar
10 | @inject IJSRuntime JSRuntime
11 | @inject IStringLocalizer Localizer
12 | @inject AuthenticationStateProvider AuthenticationStateProvider
13 |
14 |
15 |
16 | @Localizer["title"]
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | @Localizer["confirm"]
26 |
27 |
28 |
29 | @code {
30 |
31 | [CascadingParameter] IMudDialogInstance MudDialog { get; set; }
32 | [Parameter] public string _remote_file_path { get; set; }
33 |
34 | protected override async Task OnInitializedAsync()
35 | {
36 | // Get the current user from the authentication state
37 | var user = (await AuthenticationStateProvider.GetAuthenticationStateAsync()).User;
38 |
39 | // Check if user is authenticated
40 | if (user?.Identity is not { IsAuthenticated: true })
41 | {
42 | NavigationManager.NavigateTo("/login", true);
43 | return;
44 | }
45 | }
46 |
47 | private async Task OK()
48 | {
49 | this.Snackbar.Configuration.ShowCloseIcon = true;
50 | this.Snackbar.Configuration.PositionClass = Defaults.Classes.Position.BottomRight;
51 |
52 | this.MudDialog.Close(DialogResult.Ok(_remote_file_path));
53 | }
54 |
55 | private void Cancel() => MudDialog.Cancel();
56 | }
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/Components/Pages/Devices/Dialogs/Remote_File_Browser/Result_Dialog.razor:
--------------------------------------------------------------------------------
1 | @using MySqlConnector;
2 | @using System.Data.Common;
3 | @using System.Text.Json;
4 | @using System.Security.Claims
5 |
6 | @inject NavigationManager NavigationManager
7 | @inject ILocalStorageService localStorage
8 | @inject IDialogService DialogService
9 | @inject ISnackbar Snackbar
10 | @inject IJSRuntime JSRuntime
11 | @inject IStringLocalizer Localizer
12 | @inject AuthenticationStateProvider AuthenticationStateProvider
13 |
14 |
15 |
16 | @Localizer["title"]
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | @Localizer["close"]
26 |
27 |
28 |
29 | @code {
30 |
31 | [CascadingParameter] IMudDialogInstance MudDialog { get; set; }
32 |
33 | [Parameter] public string result { get; set; }
34 |
35 | protected override async Task OnInitializedAsync()
36 | {
37 | // Get the current user from the authentication state
38 | var user = (await AuthenticationStateProvider.GetAuthenticationStateAsync()).User;
39 |
40 | // Check if user is authenticated
41 | if (user?.Identity is not { IsAuthenticated: true })
42 | {
43 | NavigationManager.NavigateTo("/login", true);
44 | return;
45 | }
46 | }
47 |
48 | private async Task OK()
49 | {
50 | this.Snackbar.Configuration.ShowCloseIcon = true;
51 | this.Snackbar.Configuration.PositionClass = Defaults.Classes.Position.BottomRight;
52 |
53 | this.MudDialog.Close(DialogResult.Ok("success"));
54 | }
55 |
56 | private void Cancel() => MudDialog.Cancel();
57 | }
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/Components/Pages/Devices/Dialogs/Remote_File_Browser/Move_File_Dialog.razor:
--------------------------------------------------------------------------------
1 | @using MySqlConnector;
2 | @using System.Data.Common;
3 | @using System.Text.Json;
4 | @using System.Security.Claims
5 |
6 | @inject NavigationManager NavigationManager
7 | @inject ILocalStorageService localStorage
8 | @inject IDialogService DialogService
9 | @inject ISnackbar Snackbar
10 | @inject IJSRuntime JSRuntime
11 | @inject IStringLocalizer Localizer
12 | @inject AuthenticationStateProvider AuthenticationStateProvider
13 |
14 |
15 |
16 | @Localizer["title"]
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | @Localizer["confirm"]
26 |
27 |
28 |
29 | @code {
30 |
31 | [CascadingParameter] IMudDialogInstance MudDialog { get; set; }
32 | [Parameter] public string _remote_file_path { get; set; }
33 |
34 | protected override async Task OnInitializedAsync()
35 | {
36 | // Get the current user from the authentication state
37 | var user = (await AuthenticationStateProvider.GetAuthenticationStateAsync()).User;
38 |
39 | // Check if user is authenticated
40 | if (user?.Identity is not { IsAuthenticated: true })
41 | {
42 | NavigationManager.NavigateTo("/login", true);
43 | return;
44 | }
45 | }
46 |
47 | private async Task OK()
48 | {
49 | this.Snackbar.Configuration.ShowCloseIcon = true;
50 | this.Snackbar.Configuration.PositionClass = Defaults.Classes.Position.BottomRight;
51 |
52 | this.MudDialog.Close(DialogResult.Ok(_remote_file_path));
53 | }
54 |
55 | private void Cancel() => MudDialog.Cancel();
56 | }
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/Components/Pages/Devices/Dialogs/Bulk_Remote_Shell/Bulk_Remote_Shell_Result_Dialog.razor:
--------------------------------------------------------------------------------
1 | @inject ISnackbar Snackbar
2 | @inject IJSRuntime JSRuntime
3 |
4 |
5 |
6 |
7 |
8 | @DeviceName - Output
9 |
10 |
11 |
12 | @if (HasError)
13 | {
14 |
15 | Execution failed or returned an error
16 |
17 | }
18 |
19 |
20 | @Output
21 |
22 |
23 |
28 | Copy to Clipboard
29 |
30 |
31 |
32 | Close
33 |
34 |
35 |
36 | @code {
37 | [CascadingParameter] IMudDialogInstance MudDialog { get; set; }
38 |
39 | [Parameter] public string DeviceName { get; set; }
40 | [Parameter] public string Output { get; set; }
41 | [Parameter] public bool HasError { get; set; }
42 |
43 | private async Task CopyToClipboard()
44 | {
45 | try
46 | {
47 | await JSRuntime.InvokeVoidAsync("navigator.clipboard.writeText", Output);
48 | Snackbar.Add("Output copied to clipboard", Severity.Success);
49 | }
50 | catch (Exception)
51 | {
52 | Snackbar.Add("Failed to copy to clipboard", Severity.Error);
53 | }
54 | }
55 |
56 | private void Close()
57 | {
58 | MudDialog.Close();
59 | }
60 | }
61 |
62 |
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/Application_Paths.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | namespace NetLock_RMM_Web_Console
4 | {
5 | public class Application_Paths
6 | {
7 | //public static string logs_dir = @"C:\ProgramData\0x101 Cyber Security\NetLock RMM\Web Console\Logs";
8 | public static string logs_dir = Path.Combine(GetBasePath(), "0x101 Cyber Security", "NetLock RMM", "Web Console", "Logs");
9 |
10 | public static string _private_files_devices = "devices";
11 |
12 | public static string internal_dir = Path.Combine(GetCurrentDirectory(), "internal");
13 | public static string internal_temp_dir = Path.Combine(GetCurrentDirectory(), "internal", "temp");
14 |
15 | public static string internal_recordings_dir = Path.Combine(GetCurrentDirectory(), "internal", "recordings");
16 |
17 | //OSSCH_START fb852d6a-6bb3-477c-bea9-e0a25606a2e5 //OSSCH_END
18 |
19 | public static string certificates_path = Path.Combine(GetCurrentDirectory(), "certificates");
20 |
21 | private static string GetBasePath()
22 | {
23 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
24 | {
25 | return Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
26 | }
27 | else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && Application_Settings.IsLiveEnvironment)
28 | {
29 | return "/var";
30 | }
31 | else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && !Application_Settings.IsLiveEnvironment)
32 | {
33 | return "/home/nico-mak/.local/share";
34 | }
35 | else
36 | {
37 | throw new NotSupportedException("Unsupported OS");
38 | }
39 | }
40 |
41 | private static string GetCurrentDirectory()
42 | {
43 | return AppContext.BaseDirectory;
44 | }
45 |
46 | //public static string debug_txt_path = @"C:\ProgramData\0x101 Cyber Security\NetLock RMM\Web Console\debug.txt";
47 |
48 | //URLs
49 | public static string redirect_path = "/redirect";
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/NetLock-RMM-Server/MySQL/Config.cs:
--------------------------------------------------------------------------------
1 | using System.Text.Json;
2 |
3 | namespace NetLock_RMM_Server.MySQL
4 | {
5 | public class Config
6 | {
7 | public string Server { get; set; }
8 | public int Port { get; set; }
9 | public string Database { get; set; }
10 | public string User { get; set; }
11 | public string Password { get; set; }
12 | public string SslMode { get; set; }
13 | public string AdditionalConnectionParameters { get; set; }
14 |
15 | public class MySQL
16 | {
17 | public string Server { get; set; }
18 | public int Port { get; set; }
19 | public string Database { get; set; }
20 | public string User { get; set; }
21 | public string Password { get; set; }
22 | public string SslMode { get; set; }
23 | public string AdditionalConnectionParameters { get; set; }
24 |
25 | }
26 |
27 | public class RootData
28 | {
29 | public MySQL MySQL { get; set; }
30 | }
31 |
32 | // Read appsettings.json file and get mysql database name
33 | public static async Task Get_Database_Name()
34 | {
35 | try
36 | {
37 | // Read appssettings.json file
38 | string json = await File.ReadAllTextAsync("appsettings.json");
39 |
40 | //Logging.Handler.Debug("Classes.MySQL.MySQLConfig.Get_Database_Name", "json", json);
41 |
42 | // Deserialize JSON string
43 | RootData rootData = JsonSerializer.Deserialize(json);
44 |
45 | // Get MySQL configuration
46 | string database = rootData.MySQL.Database;
47 |
48 | // Return MySQL configuration
49 | //Logging.Handler.Debug("Classes.MySQL.MySQLConfig.Get_Database_Name", "database", database);
50 | return database;
51 | }
52 | catch (Exception ex)
53 | {
54 | Logging.Handler.Error("Classes.MySQL.MySQLConfig.Get_Database_Name", "General error", ex.ToString());
55 | return String.Empty;
56 | }
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/Classes/Helper/Base64.cs:
--------------------------------------------------------------------------------
1 | using System.Text;
2 |
3 | namespace Base64
4 | {
5 | internal class Handler
6 | {
7 | public static async Task Encode(string content)
8 | {
9 | byte[] data = Encoding.UTF8.GetBytes(content);
10 | return await Task.Run(() => Convert.ToBase64String(data));
11 | }
12 |
13 | /*public static async Task EncodeUtf16LE(string content)
14 | {
15 | byte[] data = Encoding.Unicode.GetBytes(content); // UTF-16 LE statt UTF-8
16 | return await Task.Run(() => Convert.ToBase64String(data));
17 | }*/
18 |
19 | public static async Task Decode(string encodedContent)
20 | {
21 | try
22 | {
23 | byte[] data = Convert.FromBase64String(encodedContent);
24 | return await Task.Run(() => Encoding.UTF8.GetString(data));
25 | }
26 | catch (Exception ex)
27 | {
28 | //Logging.Handler.Error("Base64.Handler.Decode", "", ex.Message);
29 | return "";
30 | }
31 | }
32 |
33 | public static string Decode_Syncron(string encodedContent)
34 | {
35 | try
36 | {
37 | byte[] data = Convert.FromBase64String(encodedContent);
38 | return Encoding.UTF8.GetString(data);
39 | }
40 | catch (Exception ex)
41 | {
42 | //Logging.Handler.Error("Base64.Handler.Decode", "", ex.Message);
43 | return "";
44 | }
45 | }
46 |
47 |
48 | /*public static void Write_File(string path, string base64)
49 | {
50 | try
51 | {
52 | File.WriteAllText(path, DecodeAsync(base64));
53 | }
54 | catch (Exception ex)
55 | {
56 | Logging.Handler.Error("Helper.Base64.Write_File", "failed", "Details: " + Environment.NewLine +
57 | "Path: " + path + Environment.NewLine +
58 | "Base64: " + base64 + Environment.NewLine +
59 | "Error: " + ex.Message);
60 | }
61 | }*/
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/NetLock-RMM-Server/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Warning",
5 | "Microsoft": "Error",
6 | "Microsoft.Hosting.Lifetime": "Warning",
7 | "Microsoft.AspNetCore.SignalR": "Error",
8 | "Microsoft.AspNetCore.Http.Connections": "Error"
9 | },
10 | "Custom": {
11 | "Enabled": true,
12 | "VerbosityLevel": 0
13 | }
14 | },
15 | "AllowedHosts": "*",
16 | "Kestrel": {
17 | "Endpoint": {
18 | "Http": {
19 | "Enabled": true,
20 | "Port": 7080
21 | },
22 | "Https": {
23 | "Enabled": false,
24 | "Port": 7443,
25 | "Force": true,
26 | "Hsts": {
27 | "Enabled": true
28 | },
29 | "Certificate": {
30 | "Path": "/path/to/certificates/certificate.pfx",
31 | "Password": "your-cert-password"
32 | }
33 | }
34 | },
35 | "Limits": {
36 | "MaxConcurrentConnections": 2000,
37 | "MaxConcurrentUpgradedConnections": 2000,
38 | "MaxRequestBodySize": 10737418240,
39 | "KeepAliveTimeout": 120
40 | },
41 | "Roles": {
42 | "Comm": true,
43 | "Update": true,
44 | "Trust": true,
45 | "Remote": true,
46 | "Notification": true,
47 | "File": true,
48 | "LLM": true
49 | }
50 | },
51 | "SignalR": {
52 | "MaximumReceiveMessageSize": 102400000,
53 | "ClientTimeoutInterval": 120,
54 | "KeepAliveInterval": 15,
55 | "HandshakeTimeout": 30,
56 | "EnableDetailedErrors": true,
57 | "StreamBufferCapacity": 20,
58 | "MaximumParallelInvocationsPerClient": 5,
59 | "MaxConnectionAttempts": 5,
60 | "ConnectionAttemptDelayMs": 5000
61 | },
62 | "MySQL": {
63 | "Server": "127.0.0.1",
64 | "Port": 3306,
65 | "Database": "netlock",
66 | "User": "root",
67 | "Password": "Bochum234",
68 | "SslMode": "None",
69 | "AdditionalConnectionParameters": ""
70 | },
71 | "Members_Portal_Api": {
72 | "Enabled": true,
73 | "Cloud": true,
74 | "ApiKeyOverride": "2b77005b-61a3-4fa8-83c9-5b9f3621f758-ba910728-1b53-4cb5-9159-3eb4140a2eed",
75 | "ServerGuid": "Test-Guid"
76 | },
77 | "Environment": {
78 | "Docker": false
79 | }
80 | }
81 |
82 |
--------------------------------------------------------------------------------
/NetLock-RMM-User-Process/Application_Paths.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace NetLock_RMM_User_Process
9 | {
10 | internal class Application_Paths
11 | {
12 | public static string application_data_debug_txt = Path.Combine(GetBasePath_CommonApplicationData(), "NetLock RMM User Process", "debug.txt");
13 | public static string application_data_logs = Path.Combine(GetBasePath_CommonApplicationData(), "NetLock RMM User Process", "Logs");
14 |
15 | private static string GetBasePath_CommonApplicationData()
16 | {
17 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
18 | {
19 | return Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
20 | }
21 | else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
22 | {
23 | return "/var";
24 | }
25 | else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
26 | {
27 | return "/Library/Application Support";
28 | }
29 | else if (OperatingSystem.IsMacOS())
30 | {
31 | return "/Library/Application Support";
32 | }
33 | else
34 | {
35 | throw new NotSupportedException("Unsupported OS");
36 | }
37 | }
38 |
39 | private static string GetBasePath_ProgramFiles()
40 | {
41 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
42 | {
43 | return Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
44 | }
45 | else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
46 | {
47 | return "/usr";
48 | }
49 | else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
50 | {
51 | return "/Applications";
52 | }
53 | else if (OperatingSystem.IsMacOS())
54 | {
55 | return "/Applications";
56 | }
57 | else
58 | {
59 | throw new NotSupportedException("Unsupported OS");
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/NetLock-RMM-Server/Helper/Notifications/Telegram.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Http;
2 | using MySqlConnector;
3 | using System.Data.Common;
4 | using System.Net;
5 | using Telegram.Bot;
6 | using NetLock_RMM_Server.Configuration;
7 |
8 | namespace Helper.Notifications
9 | {
10 | public class Telegram
11 | {
12 | public static async Task Send_Message(string id, string message)
13 | {
14 | string bot_token = String.Empty;
15 | string chat_id = String.Empty;
16 |
17 | MySqlConnection conn = new MySqlConnection(MySQL.Connection_String);
18 |
19 | try
20 | {
21 | await conn.OpenAsync();
22 |
23 | MySqlCommand command = new MySqlCommand("SELECT * FROM telegram_notifications WHERE id = @id;", conn);
24 | command.Parameters.AddWithValue("@id", id);
25 |
26 | using (DbDataReader reader = await command.ExecuteReaderAsync())
27 | {
28 | if (reader.HasRows)
29 | {
30 | while (await reader.ReadAsync())
31 | {
32 | bot_token = reader["bot_token"].ToString() ?? String.Empty;
33 | chat_id = reader["chat_id"].ToString() ?? String.Empty;
34 | }
35 | }
36 | }
37 | }
38 | catch (Exception ex)
39 | {
40 | Logging.Handler.Error("Classes.Helper.Notifications.Telegram", "Send_Message.Query_Connector_Info", ex.ToString());
41 | }
42 | finally
43 | {
44 | await conn.CloseAsync();
45 | }
46 |
47 | //Send message
48 | try
49 | {
50 | var botClient = new TelegramBotClient(bot_token);
51 | var messageText = message;
52 |
53 | await botClient.SendMessage(chat_id, messageText);
54 |
55 | return true;
56 | }
57 | catch (Exception ex)
58 | {
59 | Logging.Handler.Error("Classes.Helper.Notifications.Telegram", "Send_Message.Send", "status_code: " + ex.ToString());
60 | return false;
61 | }
62 |
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/Classes/Helper/Notifications/Telegram.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Http;
2 | using MySqlConnector;
3 | using System.Data.Common;
4 | using System.Net;
5 | using Telegram.Bot;
6 |
7 | namespace NetLock_RMM_Web_Console.Classes.Helper.Notifications
8 | {
9 | public class Telegram
10 | {
11 | public static async Task Send_Message(string id, string message)
12 | {
13 | string bot_token = String.Empty;
14 | string chat_id = String.Empty;
15 |
16 | MySqlConnection conn = new MySqlConnection(Configuration.MySQL.Connection_String);
17 |
18 | try
19 | {
20 | await conn.OpenAsync();
21 |
22 | MySqlCommand command = new MySqlCommand("SELECT * FROM telegram_notifications WHERE id = @id;", conn);
23 | command.Parameters.AddWithValue("@id", id);
24 |
25 | using (DbDataReader reader = await command.ExecuteReaderAsync())
26 | {
27 | if (reader.HasRows)
28 | {
29 | while (await reader.ReadAsync())
30 | {
31 | bot_token = reader["bot_token"].ToString() ?? String.Empty;
32 | chat_id = reader["chat_id"].ToString() ?? String.Empty;
33 | }
34 | }
35 | }
36 | }
37 | catch (Exception ex)
38 | {
39 | Logging.Handler.Error("Classes.Helper.Notifications.Telegram", "Send_Message.Query_Connector_Info", ex.Message);
40 | }
41 | finally
42 | {
43 | conn.Close();
44 | }
45 |
46 | //Send message
47 | try
48 | {
49 | var botClient = new TelegramBotClient(bot_token);
50 | var messageText = message;
51 |
52 | await botClient.SendMessage(chat_id, messageText);
53 |
54 | return "success";
55 | }
56 | catch (Exception ex)
57 | {
58 | Logging.Handler.Error("Classes.Helper.Notifications.Telegram", "Send_Message.Send", "status_code: " + ex.Message);
59 | return ex.Message;
60 | }
61 |
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/NetLock RMM Agent Remote/Windows/Helper/ScreenControl/Sas_Diagnostics.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Security.Principal;
4 | using System.Runtime.InteropServices;
5 | using Global.Helper;
6 |
7 | namespace Windows.Helper.ScreenControl
8 | {
9 | internal class Sas_Diagnostics
10 | {
11 | [DllImport("kernel32.dll")]
12 | static extern uint WTSGetActiveConsoleSessionId();
13 |
14 | [DllImport("wtsapi32.dll", SetLastError = true)]
15 | static extern bool WTSQueryUserToken(uint SessionId, out IntPtr phToken);
16 |
17 |
18 | public static void LogContext()
19 | {
20 | try
21 | {
22 | uint sessionId = WTSGetActiveConsoleSessionId();
23 | Logging.Debug("Windows.Helper.ScreenControl.Sas_Diagnostics.LogContext", "LogContext", $"ActiveConsoleSessionId: {sessionId}");
24 | Console.WriteLine($"[SAS] ActiveConsoleSessionId = {sessionId}");
25 |
26 | bool isElevated = new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);
27 | Logging.Debug("Windows.Helper.ScreenControl.Sas_Diagnostics.LogContext", "LogContext", $"IsElevated/Administrator: {isElevated}");
28 | Console.WriteLine($"[SAS] IsElevated/Administrator = {isElevated}");
29 |
30 | bool isLocalSystem = WindowsIdentity.GetCurrent().Name.Equals("NT AUTHORITY\\SYSTEM", StringComparison.OrdinalIgnoreCase);
31 | Logging.Debug("Windows.Helper.ScreenControl.Sas_Diagnostics.LogContext", "LogContext", $"IsLocalSystem: {isLocalSystem}");
32 | Console.WriteLine($"[SAS] Running as LocalSystem = {isLocalSystem}");
33 |
34 | bool gotToken = WTSQueryUserToken(sessionId, out var userToken);
35 | Logging.Debug("Windows.Helper.ScreenControl.Sas_Diagnostics.LogContext", "LogContext", $"WTSQueryUserToken({sessionId}) -> {gotToken}");
36 | Console.WriteLine($"[SAS] WTSQueryUserToken({sessionId}) -> {gotToken}");
37 | if (gotToken) Kernel32.CloseHandle(userToken);
38 | }
39 | catch (Exception ex)
40 | {
41 | Logging.Error("Windows.Helper.ScreenControl.Sas_Diagnostics.LogContext", "General error", ex.ToString());
42 |
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/NetLock-RMM-User-Process/MacOS/ScreenCaptureMacOS.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing.Imaging;
3 | using System.Drawing;
4 | using System.IO;
5 | using NetLock_RMM_User_Process;
6 |
7 | public class ScreenCaptureMacOS
8 | {
9 | ///
10 | /// This code was just playing around. It's not used in the project. In Q3 I will revisit this and try to realize screen capturing through native MacOS APIs. Connected with the planned Support Mode.
11 | ///
12 | ///
13 | ///
14 | public static async Task CaptureScreenToBase64(int screenIndex)
15 | {
16 | try
17 | {
18 | // Screenshot-Pfad
19 | string screenshotPath = "screenshot.png";
20 |
21 | // Screenshot mit Terminal-Befehl aufnehmen
22 | string command = $"screencapture '{screenshotPath}'";
23 | string output = MacOS.Helper.Zsh.Execute_Script("test", false, command);
24 |
25 | Console.WriteLine($"Screenshot command output: {output}");
26 |
27 | // Überprüfen, ob das Screenshot erstellt wurde
28 | if (!File.Exists(screenshotPath))
29 | {
30 | Console.WriteLine("Screenshot not found.");
31 | return null;
32 | }
33 |
34 | // Screenshot als Base64 kodieren
35 | byte[] screenshotBytes = await File.ReadAllBytesAsync(screenshotPath);
36 | string base64Screenshot = Convert.ToBase64String(screenshotBytes);
37 |
38 | return base64Screenshot;
39 | }
40 | catch (Exception ex)
41 | {
42 | Console.WriteLine($"Error capturing screen: {ex.ToString()}");
43 | return null;
44 | }
45 | }
46 |
47 | private static ImageCodecInfo GetEncoder(ImageFormat format)
48 | {
49 | try
50 | {
51 | ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders();
52 | foreach (ImageCodecInfo codec in codecs)
53 | {
54 | if (codec.FormatID == format.Guid)
55 | {
56 | return codec;
57 | }
58 | }
59 | return null;
60 | }
61 | catch (Exception ex)
62 | {
63 | Console.WriteLine($"Error getting encoder: {ex.ToString()}");
64 | return null;
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/Components/Pages/Devices/Dialogs/Remote_Control/Code_Signing_Warning_Dialog.razor:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Code Signing Not Available
5 |
6 | Your Windows agents are not digitally signed. This may cause issues with unattended access, UAC dialogs,
7 | or applications running with administrator privileges. These limitations are enforced by Microsoft as a
8 | security measure when code signing is missing.
9 |
10 |
11 |
12 |
13 | If you experience such issues, consider upgrading to one of our paid plans, which include code signing.
14 |
15 |
16 |
17 |
18 |
19 |
20 | Available from Tier 1 for professional deployments
21 |
22 |
23 |
24 | Code signed Windows agents
25 | No UAC warnings
26 | Trusted by Windows
27 | Full administrator privileges
28 |
29 |
30 |
31 | Continue Anyway
32 |
33 | View Pricing
34 |
35 |
36 |
37 |
38 | @code {
39 | [CascadingParameter] IMudDialogInstance MudDialog { get; set; } = null!;
40 |
41 | private void Cancel()
42 | {
43 | MudDialog.Close(DialogResult.Ok(false));
44 | }
45 |
46 | private void ViewPricing()
47 | {
48 | MudDialog.Close(DialogResult.Ok(true));
49 | }
50 | }
51 |
52 |
--------------------------------------------------------------------------------
/NetLock RMM Agent Health/Global/Helper/IO.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Security.Cryptography;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace Global.Helper
10 | {
11 | internal class IO
12 | {
13 | public static string Get_SHA512(string FilePath)
14 | {
15 | try
16 | {
17 | using (FileStream stream = File.OpenRead(FilePath))
18 | {
19 | SHA512Managed sha512 = new SHA512Managed();
20 | byte[] checksum_sha512 = sha512.ComputeHash(stream);
21 | string hash = BitConverter.ToString(checksum_sha512).Replace("-", String.Empty);
22 |
23 | Logging.Debug("Helper.IO.Get_SHA512", "hash", hash);
24 |
25 | return hash;
26 | }
27 | }
28 | catch (Exception ex)
29 | {
30 | Logging.Error("Helper.IO.Get_SHA512", "General error", ex.ToString());
31 | return ex.Message;
32 | }
33 | }
34 |
35 | public static void Delete_File(string path)
36 | {
37 | try
38 | {
39 | if (File.Exists(path))
40 | File.Delete(path);
41 |
42 | Logging.Debug("Helper.IO.Delete_File", "Deleted file.", path);
43 | }
44 | catch (Exception ex)
45 | {
46 | Logging.Error("Helper.IO.Delete_File", "Delete file failed: " + path, ex.ToString());
47 | Console.WriteLine("[" + DateTime.Now + "] - [Helper.IO.Delete_File] -> Delete file failed: " + ex.Message);
48 | }
49 | }
50 |
51 | public static void Delete_Directory(string path)
52 | {
53 | try
54 | {
55 | if (Directory.Exists(path))
56 | Directory.Delete(path, true);
57 |
58 | Logging.Debug("Helper.IO.Delete_Directory", "Deleted directory.", path);
59 | }
60 | catch (Exception ex)
61 | {
62 | Logging.Error("Helper.IO.Delete_Directory", "Delete directory failed: " + path, ex.ToString());
63 | Console.WriteLine("[" + DateTime.Now + "] - [Helper.IO.Delete_Directory] -> Delete directory failed: " + ex.Message);
64 | }
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/NetLock RMM Agent Installer/Helper/IO.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Security.Cryptography;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace Helper
10 | {
11 | internal class IO
12 | {
13 | public static string Get_SHA512(string FilePath)
14 | {
15 | try
16 | {
17 | using (FileStream stream = File.OpenRead(FilePath))
18 | {
19 | SHA512Managed sha512 = new SHA512Managed();
20 | byte[] checksum_sha512 = sha512.ComputeHash(stream);
21 | string hash = BitConverter.ToString(checksum_sha512).Replace("-", String.Empty);
22 |
23 | Logging.Handler.Debug("Helper.IO.Get_SHA512", "hash", hash);
24 |
25 | return hash;
26 | }
27 | }
28 | catch (Exception ex)
29 | {
30 | Logging.Handler.Error("Helper.IO.Get_SHA512", "General error", ex.ToString());
31 | return ex.Message;
32 | }
33 | }
34 |
35 | public static void Delete_File(string path)
36 | {
37 | try
38 | {
39 | if (File.Exists(path))
40 | File.Delete(path);
41 |
42 | Logging.Handler.Debug("Helper.IO.Delete_File", "Deleted file.", path);
43 | }
44 | catch (Exception ex)
45 | {
46 | Logging.Handler.Error("Helper.IO.Delete_File", "Delete file failed: " + path, ex.ToString());
47 | Console.WriteLine("[" + DateTime.Now + "] - [Helper.IO.Delete_File] -> Delete file failed: " + ex.Message);
48 | }
49 | }
50 |
51 | public static void Delete_Directory(string path)
52 | {
53 | try
54 | {
55 | if (Directory.Exists(path))
56 | Directory.Delete(path, true);
57 |
58 | Logging.Handler.Debug("Helper.IO.Delete_Directory", "Deleted directory.", path);
59 | }
60 | catch (Exception ex)
61 | {
62 | Logging.Handler.Error("Helper.IO.Delete_Directory", "Delete directory failed: " + path, ex.ToString());
63 | Console.WriteLine("[" + DateTime.Now + "] - [Helper.IO.Delete_Directory] -> Delete directory failed: " + ex.Message);
64 | }
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/Components/Pages/Tenants/Export_Data_Dialog.razor:
--------------------------------------------------------------------------------
1 | @using MySqlConnector;
2 | @using System.Data.Common;
3 | @using System.Text.Json;
4 | @using System.Security.Claims
5 |
6 | @inject NavigationManager NavigationManager
7 | @inject ILocalStorageService localStorage
8 | @inject IDialogService DialogService
9 | @inject ISnackbar Snackbar
10 | @inject IJSRuntime JSRuntime
11 | @inject IStringLocalizer Localizer
12 | @inject AuthenticationStateProvider AuthenticationStateProvider
13 |
14 |
15 |
16 | @Localizer["export_data"]
17 |
18 |
19 | @Localizer["text"]
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | @Localizer["cancel"]
30 | @Localizer["export"]
31 |
32 |
33 |
34 | @code {
35 |
36 | private string type = string.Empty;
37 |
38 | [CascadingParameter]
39 | private IMudDialogInstance MudDialog { get; set; } = default!;
40 |
41 | private bool Form_Valid()
42 | {
43 | if (String.IsNullOrEmpty(type))
44 | return true;
45 | else
46 | return false;
47 | }
48 |
49 | protected override async Task OnInitializedAsync()
50 | {
51 | // Get the current user from the authentication state
52 | var user = (await AuthenticationStateProvider.GetAuthenticationStateAsync()).User;
53 |
54 | // Check if user is authenticated
55 | if (user?.Identity is not { IsAuthenticated: true })
56 | {
57 | NavigationManager.NavigateTo("/login", true);
58 | return;
59 | }
60 | }
61 |
62 | private void OK()
63 | {
64 | this.MudDialog.Close(DialogResult.Ok(type));
65 | }
66 |
67 | private void Cancel() => MudDialog.Cancel();
68 | }
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## Latest Release
4 |
5 | ### ⚠️ Important Notice
6 |
7 | **Breaking Changes:**
8 | - All agents must be updated to the latest version for remote access to function properly
9 | - Review and update your policies to enable remote capabilities in agent settings
10 | - The new tray icon must be enabled in policy settings for attended remote access
11 |
12 | ### ✨ New Features
13 |
14 | #### User Tray Icon
15 | - Introduced fully customizable tray icon for enhanced user engagement
16 | - Added new remote access experience with user-controlled accept/decline functionality
17 | - Administrator-controlled remote access behavior through policy settings
18 | - Ideal for situations requiring confidentiality and user consent
19 |
20 | #### Device Labels
21 | - New device labels provide clearer device overview
22 | - Automation policy preview shows which policies are applied to each device
23 |
24 | #### Shutdown & Reboot Actions
25 | - Quick shutdown and reboot actions added
26 | - Direct device control without navigating through remote shell → script selection → execution
27 |
28 | #### Agent Policy Controls
29 | - Configure device synchronization frequency with server
30 | - Override global auto-update settings per assigned policy
31 | - Enable or disable specific remote features per policy
32 | - Enable or disable entire remote service per policy
33 | - Policy settings are managed directly by remote devices (requires policy sync)
34 | - Define unattended access permissions or require user confirmation before connection
35 |
36 | ### 🔧 Improvements
37 |
38 | - **Remote Agent Service:** Complete overhaul of connection behavior
39 | - Automatic connection re-establishment after system reboot when network connectivity is restored
40 | - Fixed edge cases where security programs could silently block connections
41 |
42 | - **User Session Tracking:** Last active user now correctly reflects RDP sessions
43 |
44 | - **Linux Software Inventory:** Added support for additional package managers:
45 | - Yum
46 | - Zypper
47 | - Pacman
48 | - DNF
49 |
50 | - **Remote Screen Control:** Performance optimizations
51 | - Reduced CPU resource usage
52 | - ~33% reduction in bandwidth consumption
53 | - Noticeable performance improvements
54 |
55 | - **Agent Installer:** Added support for hidden and no-log parameters
56 |
57 | - Various small tweaks and improvements
58 |
59 | ### 💬 Feedback
60 |
61 | We value your feedback! Please share your experience to help us continue improving NetLock RMM.
62 |
63 | ---
64 |
65 | *Release Date: December 7, 2025*
66 |
--------------------------------------------------------------------------------
/NetLock RMM Agent Comm/Windows/Helper/Service.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.ServiceProcess;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using Global.Helper;
8 |
9 | namespace Windows.Helper
10 | {
11 | internal class Service
12 | {
13 | public static bool Start(string name)
14 | {
15 | try
16 | {
17 | Logging.Debug("Windows.Helper.Start", "Starting service.", name);
18 | Console.WriteLine("[" + DateTime.Now + "] - [Windows.Helper.Start] -> Starting service: " + name);
19 |
20 | ServiceController sc = new ServiceController(name);
21 | sc.Start();
22 | sc.WaitForStatus(ServiceControllerStatus.Running);
23 |
24 | Logging.Debug("Windows.Helper.Start", "Starting service.", "Done.");
25 | Console.WriteLine("[" + DateTime.Now + "] - [Windows.Helper.Start] -> Starting service: Done.");
26 |
27 | return true;
28 | }
29 | catch (Exception ex)
30 | {
31 | Logging.Error("Windows.Helper.Start", "Starting service failed: " + name, ex.ToString());
32 | Console.WriteLine("[" + DateTime.Now + "] - [Windows.Helper.Start] -> Starting service failed: " + ex.Message);
33 | return false;
34 | }
35 | }
36 |
37 | public static bool Stop(string name)
38 | {
39 | try
40 | {
41 | Logging.Debug("Windows.Helper.Stop", "Stop service.", name);
42 | Console.WriteLine("[" + DateTime.Now + "] - [Mode: Fix] -> Stopping service: " + name);
43 |
44 | ServiceController sc = new ServiceController(name);
45 | sc.Stop();
46 | sc.WaitForStatus(ServiceControllerStatus.Stopped);
47 |
48 | Logging.Debug("Windows.Helper.Stop", "Stop service.", "Done.");
49 | Console.WriteLine("[" + DateTime.Now + "] - [Mode: Fix] -> Stop service: Done.");
50 |
51 | return true;
52 | }
53 | catch (Exception ex)
54 | {
55 | Logging.Error("Windows.Helper.Stop", "Stopping service failed: " + name, ex.ToString());
56 | Console.WriteLine("[" + DateTime.Now + "] - [Windows.Helper.Stop] -> Stopping service failed: " + ex.Message);
57 | return false;
58 | }
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/NetLock RMM Agent Installer/Helper/Service.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.ServiceProcess;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace Helper
9 | {
10 | internal class Service
11 | {
12 | public static bool Start(string name)
13 | {
14 | try
15 | {
16 | Logging.Handler.Debug("Helper.Service.Start", "Starting service.", name);
17 | Console.WriteLine("[" + DateTime.Now + "] - [Helper.Service.Start] -> Starting service: " + name);
18 |
19 | ServiceController sc = new ServiceController(name);
20 | sc.Start();
21 | sc.WaitForStatus(ServiceControllerStatus.Running);
22 |
23 | Logging.Handler.Debug("Helper.Service.Start", "Starting service.", "Done.");
24 | Console.WriteLine("[" + DateTime.Now + "] - [Helper.Service.Start] -> Starting service: Done.");
25 |
26 | return true;
27 | }
28 | catch (Exception ex)
29 | {
30 | Logging.Handler.Error("Helper.Service.Start", "Starting service failed: " + name, ex.ToString());
31 | Console.WriteLine("[" + DateTime.Now + "] - [Helper.Service.Start] -> Starting service failed: " + ex.Message);
32 | return false;
33 | }
34 | }
35 |
36 | public static bool Stop(string name)
37 | {
38 | try
39 | {
40 | Logging.Handler.Debug("Helper.Service.Stop", "Stop service.", name);
41 | Console.WriteLine("[" + DateTime.Now + "] - [Mode: Fix] -> Stopping service: " + name);
42 |
43 | ServiceController sc = new ServiceController(name);
44 | sc.Stop();
45 | sc.WaitForStatus(ServiceControllerStatus.Stopped);
46 |
47 | Logging.Handler.Debug("Helper.Service.Stop", "Stop service.", "Done.");
48 | Console.WriteLine("[" + DateTime.Now + "] - [Mode: Fix] -> Stop service: Done.");
49 |
50 | return true;
51 | }
52 | catch (Exception ex)
53 | {
54 | Logging.Handler.Error("Helper.Service.Stop", "Stopping service failed: " + name, ex.ToString());
55 | Console.WriteLine("[" + DateTime.Now + "] - [Helper.Service.Stop] -> Stopping service failed: " + ex.Message);
56 | return false;
57 | }
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/Components/Pages/Policies/Dialogs/Export_Data_Dialog.razor:
--------------------------------------------------------------------------------
1 | @using MySqlConnector;
2 | @using System.Data.Common;
3 | @using System.Text.Json;
4 | @using System.Security.Claims
5 |
6 | @inject NavigationManager NavigationManager
7 | @inject ILocalStorageService localStorage
8 | @inject IDialogService DialogService
9 | @inject ISnackbar Snackbar
10 | @inject IJSRuntime JSRuntime
11 | @inject IStringLocalizer Localizer
12 | @inject AuthenticationStateProvider AuthenticationStateProvider
13 |
14 |
15 |
16 | @Localizer["export_data"]
17 |
18 |
19 | @Localizer["text"]
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | @Localizer["cancel"]
30 | @Localizer["export"]
31 |
32 |
33 |
34 | @code {
35 |
36 | private string type = string.Empty;
37 |
38 | [CascadingParameter]
39 | private IMudDialogInstance MudDialog { get; set; } = default!;
40 |
41 | private bool Form_Valid()
42 | {
43 | if (String.IsNullOrEmpty(type))
44 | return true;
45 | else
46 | return false;
47 | }
48 |
49 | protected override async Task OnInitializedAsync()
50 | {
51 | // Get the current user from the authentication state
52 | var user = (await AuthenticationStateProvider.GetAuthenticationStateAsync()).User;
53 |
54 | // Check if user is authenticated
55 | if (user?.Identity is not { IsAuthenticated: true })
56 | {
57 | NavigationManager.NavigateTo("/login", true);
58 | return;
59 | }
60 | }
61 |
62 | private void OK()
63 | {
64 | this.MudDialog.Close(DialogResult.Ok(type));
65 | }
66 |
67 | private void Cancel() => MudDialog.Cancel();
68 | }
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/Components/App.razor:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | NetLock RMM - Web Console
18 |
19 |
20 |
21 |
22 |
23 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/NetLock-RMM-Web-Console/NetLock RMM Web Console.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net9.0
5 | enable
6 | enable
7 | $(MSBuildProjectName.Replace(" ", "_"))
8 | $(AssemblyName.Replace(' ', '_'))
9 | $(AssemblyName)
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 |
--------------------------------------------------------------------------------