forked from 0x101-Cyber-Security/NetLock-RMM
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApplication_Paths.cs
More file actions
176 lines (154 loc) · 13.8 KB
/
Copy pathApplication_Paths.cs
File metadata and controls
176 lines (154 loc) · 13.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.InteropServices;
namespace NetLock_RMM_Agent_Installer
{
internal class Application_Paths
{
// Custom temp path that can be set via --temp parameter
private static string _customTempPath = null;
public static void SetCustomTempPath(string path)
{
_customTempPath = path;
// Re-initialize temp-dependent paths
c_temp_netlock_dir = Path.Combine(GetTempPath(), "netlock rmm");
c_temp_logs_dir = Path.Combine(GetTempPath(), "netlock rmm", "installer", "logs");
}
public static string c_temp_netlock_dir = Path.Combine(GetTempPath(), "netlock rmm");
public static string c_temp_logs_dir = Path.Combine(GetTempPath(), "netlock rmm", "installer", "logs");
// Agent Bundle URLs (contain all agent per platform)
public static string agent_package_url_winx64 = "/private/downloads/netlock/agent.package.win-x64.zip";
public static string agent_package_url_winarm64 = "/private/downloads/netlock/agent.package.win-arm64.zip";
public static string agent_package_url_linuxx64 = "/private/downloads/netlock/agent.package.linux-x64.zip";
public static string agent_package_url_linuxarm64 = "/private/downloads/netlock/agent.package.linux-arm64.zip";
public static string agent_package_url_osx64 = "/private/downloads/netlock/agent.package.osx-x64.zip";
public static string agent_package_url_osxarm64 = "/private/downloads/netlock/agent.package.osx-arm64.zip";
public static string program_files_comm_agent_dir = Path.Combine(GetBasePath_ProgramFiles(), OperatingSystem.IsWindows() ? "0x101 Cyber Security" : "0x101_Cyber_Security", OperatingSystem.IsWindows() ? "NetLock RMM" : "NetLock_RMM", OperatingSystem.IsWindows() ? "Comm Agent" : "Comm_Agent");
public static string program_data_comm_agent_dir = Path.Combine(GetBasePath_CommonApplicationData(), "0x101 Cyber Security", "NetLock RMM", "Comm Agent");
public static string program_files_comm_agent_path = Path.Combine(GetBasePath_ProgramFiles(), "0x101 Cyber Security", "NetLock RMM", "Comm Agent", "NetLock_RMM_Agent_Comm.exe");
public static string program_files_comm_agent_service_name_linux = "netlock-rmm-agent-comm";
public static string program_files_comm_agent_service_name_osx = "com.netlock.rmm.agentcomm";
public static string program_files_comm_agent_service_path_unix = Path.Combine(program_files_comm_agent_dir, "NetLock_RMM_Agent_Comm");
public static string program_files_comm_agent_service_config_path_linux = "/etc/systemd/system/netlock-rmm-agent-comm.service";
public static string program_files_comm_agent_service_config_path_osx = $"/Library/LaunchDaemons/{program_files_comm_agent_service_name_osx}.plist";
public static string program_files_comm_agent_service_log_path_unix = "/var/log/netlock-rmm-agent-comm.log";
public static string program_data_comm_agent_logs_dir = Path.Combine(GetBasePath_CommonApplicationData(), "0x101 Cyber Security", "NetLock RMM", "Comm Agent", "Logs");
public static string program_data_comm_agent_jobs_dir = Path.Combine(GetBasePath_CommonApplicationData(), "0x101 Cyber Security", "NetLock RMM", "Comm Agent", "Jobs");
public static string program_data_comm_agent_msdav_dir = Path.Combine(GetBasePath_CommonApplicationData(), "0x101 Cyber Security", "NetLock RMM", "Comm Agent", "Microsoft Defender Antivirus");
public static string program_data_comm_agent_scripts_dir = Path.Combine(GetBasePath_CommonApplicationData(), "0x101 Cyber Security", "NetLock RMM", "Comm Agent", "Scripts");
public static string program_data_comm_agent_backups_dir = Path.Combine(GetBasePath_CommonApplicationData(), "0x101 Cyber Security", "NetLock RMM", "Comm Agent", "Backups");
public static string program_data_comm_agent_sensors_dir = Path.Combine(GetBasePath_CommonApplicationData(), "0x101 Cyber Security", "NetLock RMM", "Comm Agent", "Sensors");
public static string program_data_comm_agent_dumps_dir = Path.Combine(GetBasePath_CommonApplicationData(), "0x101 Cyber Security", "NetLock RMM", "Comm Agent", "Dumps");
public static string program_data_comm_agent_temp_dir = Path.Combine(GetBasePath_CommonApplicationData(), "0x101 Cyber Security", "NetLock RMM", "Comm Agent", "Temp");
public static string program_data_comm_agent_server_config = Path.Combine(GetBasePath_CommonApplicationData(), "0x101 Cyber Security", "NetLock RMM", "Comm Agent", "server_config.json");
public static string program_data_health_agent_server_config = Path.Combine(GetBasePath_CommonApplicationData(), "0x101 Cyber Security", "NetLock RMM", "Health Agent", "server_config.json");
public static string program_data_comm_agent_just_installed = Path.Combine(GetBasePath_CommonApplicationData(), "0x101 Cyber Security", "NetLock RMM", "Comm Agent", "just_installed.txt");
public static string program_data_comm_agent_events_path = Path.Combine(GetBasePath_CommonApplicationData(), "0x101 Cyber Security", "NetLock RMM", "Comm Agent", "events.nlock");
public static string program_data_comm_agent_policies_path = Path.Combine(GetBasePath_CommonApplicationData(), "0x101 Cyber Security", "NetLock RMM", "Comm Agent", "policy.nlock");
public static string program_data_comm_agent_version_path = Path.Combine(GetBasePath_CommonApplicationData(), "0x101 Cyber Security", "NetLock RMM", "Comm Agent", "version.txt");
public static string program_files_remote_agent_dir = Path.Combine(GetBasePath_ProgramFiles(), OperatingSystem.IsWindows() ? "0x101 Cyber Security" : "0x101_Cyber_Security", OperatingSystem.IsWindows() ? "NetLock RMM" : "NetLock_RMM", OperatingSystem.IsWindows() ? "Remote Agent" : "Remote_Agent");
public static string program_data_remote_agent_dir = Path.Combine(GetBasePath_CommonApplicationData(), "0x101 Cyber Security", "NetLock RMM", "Remote Agent");
public static string program_files_remote_agent_path = Path.Combine(GetBasePath_ProgramFiles(), "0x101 Cyber Security", "NetLock RMM", "Remote Agent", "NetLock_RMM_Agent_Remote.exe");
public static string program_files_remote_agent_service_name_linux = "netlock-rmm-agent-remote";
public static string program_files_remote_agent_service_name_osx = "com.netlock.rmm.agentremote";
public static string program_files_remote_agent_service_path_unix = Path.Combine(program_files_remote_agent_dir, "NetLock_RMM_Agent_Remote");
public static string program_files_remote_agent_service_config_path_linux = "/etc/systemd/system/netlock-rmm-agent-remote.service";
public static string program_files_remote_agent_service_config_path_osx = $"/Library/LaunchDaemons/{program_files_remote_agent_service_name_osx}.plist";
public static string program_files_remote_agent_service_log_path_unix= "/var/log/netlock-rmm-agent-remote.log";
public static string program_files_health_agent_dir = Path.Combine(GetBasePath_ProgramFiles(), OperatingSystem.IsWindows() ? "0x101 Cyber Security" : "0x101_Cyber_Security", OperatingSystem.IsWindows() ? "NetLock RMM" : "NetLock_RMM", OperatingSystem.IsWindows() ? "Health Agent" : "Health_Agent");
public static string program_data_health_agent_dir = Path.Combine(GetBasePath_CommonApplicationData(), "0x101 Cyber Security", "NetLock RMM", "Health Agent");
public static string program_files_health_agent_path = Path.Combine(GetBasePath_ProgramFiles(), "0x101 Cyber Security", "NetLock RMM", "Health Agent", "NetLock_RMM_Agent_Health.exe");
public static string program_files_health_agent_service_name_linux = "netlock-rmm-agent-health";
public static string program_files_health_agent_service_name_osx = "com.netlock.rmm.agenthealth";
public static string program_files_health_agent_service_path_unix = Path.Combine(program_files_health_agent_dir, "NetLock_RMM_Agent_Health");
public static string program_files_health_agent_service_config_path_linux = "/etc/systemd/system/netlock-rmm-agent-health.service";
public static string program_files_health_agent_service_config_path_osx = $"/Library/LaunchDaemons/{program_files_health_agent_service_name_osx}.plist";
public static string program_files_health_agent_service_log_path_unix = "/var/log/netlock-rmm-agent-health.log";
public static string program_files_user_process_dir = Path.Combine(GetBasePath_ProgramFiles(), OperatingSystem.IsWindows() ? "0x101 Cyber Security" : "0x101_Cyber_Security", OperatingSystem.IsWindows() ? "NetLock RMM" : "NetLock_RMM", OperatingSystem.IsWindows() ? "User Process" : "User_Process");
public static string program_data_user_process_dir = Path.Combine(GetBasePath_CommonApplicationData(), "0x101 Cyber Security", "NetLock RMM", "User Process");
public static string program_files_user_process_path = Path.Combine(GetBasePath_ProgramFiles(), OperatingSystem.IsWindows() ? "0x101 Cyber Security" : "0x101_Cyber_Security", OperatingSystem.IsWindows() ? "NetLock RMM" : "NetLock_RMM", OperatingSystem.IsWindows() ? "User Process" : "User_Process", OperatingSystem.IsWindows() ? "NetLock_RMM_User_Process.exe" : "NetLock_RMM_User_Process");
//public static string program_files_user_agent_dir = Path.Combine(GetBasePath_ProgramFiles(), OperatingSystem.IsWindows() ? "0x101 Cyber Security" : "0x101_Cyber_Security", OperatingSystem.IsWindows() ? "NetLock RMM" : "NetLock_RMM", OperatingSystem.IsWindows() ? "User Agent" : "User_Agent");
//public static string program_data_user_agent_dir = Path.Combine(GetBasePath_CommonApplicationData(), "0x101 Cyber Security", "NetLock RMM", "User Agent");
//public static string program_files_user_agent_path = Path.Combine(GetBasePath_ProgramFiles(), OperatingSystem.IsWindows() ? "0x101 Cyber Security" : "0x101_Cyber_Security", OperatingSystem.IsWindows() ? "NetLock RMM" : "NetLock_RMM", OperatingSystem.IsWindows() ? "User Agent" : "User_Agent", OperatingSystem.IsWindows() ? "NetLock_RMM_User_Process.exe" : "NetLock_RMM_User_Process");
public static string program_files_tray_icon_dir = Path.Combine(GetBasePath_ProgramFiles(), OperatingSystem.IsWindows() ? "0x101 Cyber Security" : "0x101_Cyber_Security", OperatingSystem.IsWindows() ? "NetLock RMM" : "NetLock_RMM", OperatingSystem.IsWindows() ? "Tray Icon" : "Tray_Icon");
public static string program_files_tray_icon_path = Path.Combine(GetBasePath_ProgramFiles(), OperatingSystem.IsWindows() ? "0x101 Cyber Security" : "0x101_Cyber_Security", OperatingSystem.IsWindows() ? "NetLock RMM" : "NetLock_RMM", OperatingSystem.IsWindows() ? "Tray Icon" : "Tray_Icon", OperatingSystem.IsWindows() ? "NetLock_RMM_Tray_Icon.exe" : "NetLock_RMM_Tray_Icon");
// Agent Bundle package paths
public static string agent_package_path = @"agent.package";
public static string program_files_0x101_cyber_security_dir = Path.Combine(GetBasePath_ProgramFiles(), OperatingSystem.IsWindows() ? "0x101 Cyber Security" : "0x101_Cyber_Security");
public static string program_data_0x101_cyber_security_dir = Path.Combine(GetBasePath_CommonApplicationData(), "0x101 Cyber Security");
// Windows registry
public static string hklm_run_directory_reg_path = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run";
private static string GetBasePath_CommonApplicationData()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return "/var";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
return "/Library/Application Support";
}
else if (OperatingSystem.IsMacOS())
{
return "/Library/Application Support";
}
else
{
throw new NotSupportedException("Unsupported OS");
}
}
private static string GetBasePath_ProgramFiles()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return "/usr";
}
else if (OperatingSystem.IsMacOS())
{
return "/usr/local/bin";
}
else
{
throw new NotSupportedException("Unsupported OS");
}
}
public static string GetTempPath()
{
// Return custom temp path if set
if (!string.IsNullOrEmpty(_customTempPath))
{
return _customTempPath;
}
string basePath;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
basePath = @"C:\temp";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
basePath = "/tmp";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
basePath = "/tmp";
}
else
{
throw new NotSupportedException("Unsupported OS");
}
return basePath;
}
}
}