Skip to content

Commit 65dff00

Browse files
authored
Store RemoteDesktop username and password in profile file (encrypted) (BornToBeRoot#569)
* Store password in profile file * Resize dialog * Update 04_Changelog.md * Support legacy profiles :) * Check if empty, remove creds on disable * Note added if profile file is not encrypted * Profile validation added * Use profile credentials on connect * Update GlobalAssemblyInfo.cs * Update changelog and version Co-authored-by: BornToBeRoot <BornToBeRoot@users.noreply.github.com>
1 parent f62495a commit 65dff00

17 files changed

Lines changed: 503 additions & 88 deletions

File tree

InnoSetup.iss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
33

44
#define MyAppName "NETworkManager"
5-
#define MyAppVersion "2021.2.17.0"
5+
#define MyAppVersion "2021.3.21.0"
66
#define MyAppPublisher "BornToBeRoot"
77
#define MyAppURL "https://github.com/BornToBeRoot/NETworkManager/"
88
#define MyAppExeName "NETworkManager.exe"

Source/GlobalAssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
[assembly: AssemblyTrademark("")]
77
[assembly: AssemblyCulture("")]
88

9-
[assembly: AssemblyVersion("2021.2.17.0")]
10-
[assembly: AssemblyFileVersion("2021.2.17.0")]
9+
[assembly: AssemblyVersion("2021.3.21.0")]
10+
[assembly: AssemblyFileVersion("2021.3.21.0")]

Source/NETworkManager.Localization/Resources/Strings.Designer.cs

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/NETworkManager.Localization/Resources/Strings.resx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3060,4 +3060,9 @@ The application will be restarted afterwards!</value>
30603060
<data name="License_MicrosoftWebView2License" xml:space="preserve">
30613061
<value>Microsoft WebView2 License</value>
30623062
</data>
3063+
<data name="WarningMessage_ProfileFileNotEncryptedStoringPasswords" xml:space="preserve">
3064+
<value>The current profile file is not encrypted and passwords will stored unencrypted on disk!
3065+
3066+
Enable profile file encryption in Settings&gt;Profile to store credentials securely.</value>
3067+
</data>
30633068
</root>

Source/NETworkManager.Profiles/Application/RemoteDesktop.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ public static RemoteDesktopSessionInfo CreateSessionInfo(ProfileInfo profileInfo
5555
VisualStyles = profileInfo != null && profileInfo.RemoteDesktop_OverrideVisualStyles ? profileInfo.RemoteDesktop_VisualStyles : SettingsManager.Current.RemoteDesktop_VisualStyles,
5656
};
5757

58+
// Set credentials
59+
if(profileInfo.RemoteDesktop_UseCredentials)
60+
{
61+
info.CustomCredentials = true;
62+
63+
info.Username = profileInfo.RemoteDesktop_Username;
64+
info.Password = profileInfo.RemoteDesktop_Password;
65+
}
66+
5867
return info;
5968
}
6069

Source/NETworkManager.Profiles/ProfileInfo.cs

Lines changed: 163 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
using NETworkManager.Models.PuTTY;
33
using NETworkManager.Models.RemoteDesktop;
44
using NETworkManager.Settings;
5+
using System.Security;
6+
using System.Xml.Serialization;
57

68
namespace NETworkManager.Profiles
79
{
810
/// <summary>
911
/// Class represents a profile.
1012
/// </summary>
13+
[XmlType("ProfileInfoLegacy")] // XML --> Deprecated because of #378
1114
public class ProfileInfo
1215
{
1316
/// <summary>
@@ -63,6 +66,13 @@ public class ProfileInfo
6366
public bool RemoteDesktop_Enabled { get; set; }
6467
public bool RemoteDesktop_InheritHost { get; set; } = true;
6568
public string RemoteDesktop_Host { get; set; }
69+
70+
public bool RemoteDesktop_UseCredentials { get; set; }
71+
72+
public string RemoteDesktop_Username { get; set; }
73+
74+
[XmlIgnore]
75+
public SecureString RemoteDesktop_Password { get; set; }
6676
public bool RemoteDesktop_OverrideDisplay { get; set; }
6777
public bool RemoteDesktop_AdjustScreenAutomatically { get; set; }
6878
public bool RemoteDesktop_UseCurrentViewSize { get; set; }
@@ -148,7 +158,7 @@ public class ProfileInfo
148158
public string PuTTY_LogFileName { get; set; } = GlobalStaticConfiguration.PuTTY_LogFileName;
149159
public bool PuTTY_OverrideAdditionalCommandLine { get; set; }
150160
public string PuTTY_AdditionalCommandLine { get; set; }
151-
161+
152162
public bool TigerVNC_Enabled { get; set; }
153163
public bool TigerVNC_InheritHost { get; set; } = true;
154164
public string TigerVNC_Host { get; set; }
@@ -175,5 +185,157 @@ public ProfileInfo()
175185
{
176186

177187
}
188+
189+
/// <summary>
190+
/// Initializes a new instance of the<see cref="ProfileInfo"/> class with properties.
191+
/// </summary>
192+
public ProfileInfo(ProfileInfo profile)
193+
{
194+
Name = profile.Name;
195+
Host = profile.Host;
196+
Group = profile.Group;
197+
Tags = profile.Tags;
198+
199+
NetworkInterface_Enabled = profile.NetworkInterface_Enabled;
200+
NetworkInterface_EnableStaticIPAddress = profile.NetworkInterface_EnableStaticIPAddress;
201+
NetworkInterface_IPAddress = profile.NetworkInterface_IPAddress;
202+
NetworkInterface_SubnetmaskOrCidr = profile.NetworkInterface_SubnetmaskOrCidr;
203+
NetworkInterface_Gateway = profile.NetworkInterface_Gateway;
204+
NetworkInterface_EnableStaticDNS = profile.NetworkInterface_EnableStaticDNS;
205+
NetworkInterface_PrimaryDNSServer = profile.NetworkInterface_PrimaryDNSServer;
206+
NetworkInterface_SecondaryDNSServer = profile.NetworkInterface_SecondaryDNSServer;
207+
208+
IPScanner_Enabled = profile.IPScanner_Enabled;
209+
IPScanner_InheritHost = profile.IPScanner_InheritHost;
210+
IPScanner_HostOrIPRange = profile.IPScanner_HostOrIPRange;
211+
212+
PortScanner_Enabled = profile.PortScanner_Enabled;
213+
PortScanner_InheritHost = profile.PortScanner_InheritHost;
214+
PortScanner_Host = profile.PortScanner_Host;
215+
PortScanner_Ports = profile.PortScanner_Ports;
216+
217+
PingMonitor_Enabled = profile.PingMonitor_Enabled;
218+
PingMonitor_InheritHost = profile.PingMonitor_InheritHost;
219+
PingMonitor_Host = profile.PingMonitor_Host;
220+
221+
Traceroute_Enabled = profile.Traceroute_Enabled;
222+
Traceroute_InheritHost = profile.Traceroute_InheritHost;
223+
Traceroute_Host = profile.Traceroute_Host;
224+
225+
DNSLookup_Enabled = profile.DNSLookup_Enabled;
226+
DNSLookup_InheritHost = profile.DNSLookup_InheritHost;
227+
DNSLookup_Host = profile.DNSLookup_Host;
228+
229+
RemoteDesktop_Enabled = profile.RemoteDesktop_Enabled;
230+
RemoteDesktop_InheritHost = profile.RemoteDesktop_InheritHost;
231+
RemoteDesktop_Host = profile.RemoteDesktop_Host;
232+
RemoteDesktop_UseCredentials = profile.RemoteDesktop_UseCredentials;
233+
RemoteDesktop_Username = profile.RemoteDesktop_Username;
234+
RemoteDesktop_Password = profile.RemoteDesktop_Password;
235+
RemoteDesktop_OverrideDisplay = profile.RemoteDesktop_OverrideDisplay;
236+
RemoteDesktop_AdjustScreenAutomatically = profile.RemoteDesktop_AdjustScreenAutomatically;
237+
RemoteDesktop_UseCurrentViewSize = profile.RemoteDesktop_UseCurrentViewSize;
238+
RemoteDesktop_UseFixedScreenSize = profile.RemoteDesktop_UseFixedScreenSize;
239+
RemoteDesktop_ScreenWidth = profile.RemoteDesktop_ScreenWidth;
240+
RemoteDesktop_ScreenHeight = profile.RemoteDesktop_ScreenHeight;
241+
RemoteDesktop_UseCustomScreenSize = profile.RemoteDesktop_UseCustomScreenSize;
242+
RemoteDesktop_CustomScreenWidth = profile.RemoteDesktop_CustomScreenWidth;
243+
RemoteDesktop_CustomScreenHeight = profile.RemoteDesktop_CustomScreenHeight;
244+
RemoteDesktop_OverrideColorDepth = profile.RemoteDesktop_OverrideColorDepth;
245+
RemoteDesktop_ColorDepth = profile.RemoteDesktop_ColorDepth;
246+
RemoteDesktop_OverridePort = profile.RemoteDesktop_OverridePort;
247+
RemoteDesktop_Port = profile.RemoteDesktop_Port;
248+
RemoteDesktop_OverrideCredSspSupport = profile.RemoteDesktop_OverrideCredSspSupport;
249+
RemoteDesktop_EnableCredSspSupport = profile.RemoteDesktop_EnableCredSspSupport;
250+
RemoteDesktop_OverrideAuthenticationLevel = profile.RemoteDesktop_OverrideAuthenticationLevel;
251+
RemoteDesktop_AuthenticationLevel = profile.RemoteDesktop_AuthenticationLevel;
252+
RemoteDesktop_OverrideAudioRedirectionMode = profile.RemoteDesktop_OverrideAudioRedirectionMode;
253+
RemoteDesktop_AudioRedirectionMode = profile.RemoteDesktop_AudioRedirectionMode;
254+
RemoteDesktop_OverrideAudioCaptureRedirectionMode = profile.RemoteDesktop_OverrideAudioCaptureRedirectionMode;
255+
RemoteDesktop_AudioCaptureRedirectionMode = profile.RemoteDesktop_AudioCaptureRedirectionMode;
256+
RemoteDesktop_OverrideApplyWindowsKeyCombinations = profile.RemoteDesktop_OverrideApplyWindowsKeyCombinations;
257+
RemoteDesktop_KeyboardHookMode = profile.RemoteDesktop_KeyboardHookMode;
258+
RemoteDesktop_OverrideRedirectClipboard = profile.RemoteDesktop_OverrideRedirectClipboard;
259+
RemoteDesktop_RedirectClipboard = profile.RemoteDesktop_RedirectClipboard;
260+
RemoteDesktop_OverrideRedirectDevices = profile.RemoteDesktop_OverrideRedirectDevices;
261+
RemoteDesktop_RedirectDevices = profile.RemoteDesktop_RedirectDevices;
262+
RemoteDesktop_OverrideRedirectDrives = profile.RemoteDesktop_OverrideRedirectDrives;
263+
RemoteDesktop_RedirectDrives = profile.RemoteDesktop_RedirectDrives;
264+
RemoteDesktop_OverrideRedirectPorts = profile.RemoteDesktop_OverrideRedirectPorts;
265+
RemoteDesktop_RedirectPorts = profile.RemoteDesktop_RedirectPorts;
266+
RemoteDesktop_OverrideRedirectSmartcards = profile.RemoteDesktop_OverrideRedirectSmartcards;
267+
RemoteDesktop_RedirectSmartCards = profile.RemoteDesktop_RedirectSmartCards;
268+
RemoteDesktop_OverrideRedirectPrinters = profile.RemoteDesktop_OverrideRedirectPrinters;
269+
RemoteDesktop_RedirectPrinters = profile.RemoteDesktop_RedirectPrinters;
270+
RemoteDesktop_OverridePersistentBitmapCaching = profile.RemoteDesktop_OverridePersistentBitmapCaching;
271+
RemoteDesktop_PersistentBitmapCaching = profile.RemoteDesktop_PersistentBitmapCaching;
272+
RemoteDesktop_OverrideReconnectIfTheConnectionIsDropped = profile.RemoteDesktop_OverrideReconnectIfTheConnectionIsDropped;
273+
RemoteDesktop_ReconnectIfTheConnectionIsDropped = profile.RemoteDesktop_ReconnectIfTheConnectionIsDropped;
274+
RemoteDesktop_OverrideNetworkConnectionType = profile.RemoteDesktop_OverrideNetworkConnectionType;
275+
RemoteDesktop_NetworkConnectionType = profile.RemoteDesktop_NetworkConnectionType;
276+
RemoteDesktop_OverrideDesktopBackground = profile.RemoteDesktop_OverrideDesktopBackground;
277+
RemoteDesktop_DesktopBackground = profile.RemoteDesktop_DesktopBackground;
278+
RemoteDesktop_OverrideFontSmoothing = profile.RemoteDesktop_OverrideFontSmoothing;
279+
RemoteDesktop_FontSmoothing = profile.RemoteDesktop_FontSmoothing;
280+
RemoteDesktop_OverrideDesktopComposition = profile.RemoteDesktop_OverrideDesktopComposition;
281+
RemoteDesktop_DesktopComposition = profile.RemoteDesktop_DesktopComposition;
282+
RemoteDesktop_OverrideShowWindowContentsWhileDragging = profile.RemoteDesktop_OverrideShowWindowContentsWhileDragging;
283+
RemoteDesktop_ShowWindowContentsWhileDragging = profile.RemoteDesktop_ShowWindowContentsWhileDragging;
284+
RemoteDesktop_OverrideMenuAndWindowAnimation = profile.RemoteDesktop_OverrideMenuAndWindowAnimation;
285+
RemoteDesktop_MenuAndWindowAnimation = profile.RemoteDesktop_MenuAndWindowAnimation;
286+
RemoteDesktop_OverrideVisualStyles = profile.RemoteDesktop_OverrideVisualStyles;
287+
RemoteDesktop_VisualStyles = profile.RemoteDesktop_VisualStyles;
288+
289+
PowerShell_Enabled = profile.PowerShell_Enabled;
290+
PowerShell_EnableRemoteConsole = profile.PowerShell_EnableRemoteConsole;
291+
PowerShell_InheritHost = profile.PowerShell_InheritHost;
292+
PowerShell_Host = profile.PowerShell_Host;
293+
PowerShell_OverrideAdditionalCommandLine = profile.PowerShell_OverrideAdditionalCommandLine;
294+
PowerShell_AdditionalCommandLine = profile.PowerShell_AdditionalCommandLine;
295+
PowerShell_OverrideExecutionPolicy = profile.PowerShell_OverrideExecutionPolicy;
296+
PowerShell_ExecutionPolicy = profile.PowerShell_ExecutionPolicy;
297+
298+
PuTTY_Enabled = profile.PuTTY_Enabled;
299+
PuTTY_ConnectionMode = profile.PuTTY_ConnectionMode;
300+
PuTTY_InheritHost = profile.PuTTY_InheritHost;
301+
PuTTY_HostOrSerialLine = profile.PuTTY_HostOrSerialLine;
302+
PuTTY_OverridePortOrBaud = profile.PuTTY_OverridePortOrBaud;
303+
PuTTY_PortOrBaud = profile.PuTTY_PortOrBaud;
304+
PuTTY_OverrideUsername = profile.PuTTY_OverrideUsername;
305+
PuTTY_Username = profile.PuTTY_Username;
306+
PuTTY_OverridePrivateKeyFile = profile.PuTTY_OverridePrivateKeyFile;
307+
PuTTY_PrivateKeyFile = profile.PuTTY_PrivateKeyFile;
308+
PuTTY_OverrideProfile = profile.PuTTY_OverrideProfile;
309+
PuTTY_Profile = profile.PuTTY_Profile;
310+
PuTTY_OverrideEnableLog = profile.PuTTY_OverrideEnableLog;
311+
PuTTY_EnableLog = profile.PuTTY_EnableLog;
312+
PuTTY_OverrideLogMode = profile.PuTTY_OverrideLogMode;
313+
PuTTY_LogMode = profile.PuTTY_LogMode;
314+
PuTTY_OverrideLogPath = profile.PuTTY_OverrideLogPath;
315+
PuTTY_LogPath = profile.PuTTY_LogPath;
316+
PuTTY_OverrideLogFileName = profile.PuTTY_OverrideLogFileName;
317+
PuTTY_LogFileName = profile.PuTTY_LogFileName;
318+
PuTTY_OverrideAdditionalCommandLine = profile.PuTTY_OverrideAdditionalCommandLine;
319+
PuTTY_AdditionalCommandLine = profile.PuTTY_AdditionalCommandLine;
320+
321+
TigerVNC_Enabled = profile.TigerVNC_Enabled;
322+
TigerVNC_InheritHost = profile.TigerVNC_InheritHost;
323+
TigerVNC_Host = profile.TigerVNC_Host;
324+
TigerVNC_OverridePort = profile.TigerVNC_OverridePort;
325+
TigerVNC_Port = profile.TigerVNC_Port;
326+
327+
WebConsole_Enabled = profile.WebConsole_Enabled;
328+
WebConsole_Url = profile.WebConsole_Url;
329+
330+
WakeOnLAN_Enabled = profile.WakeOnLAN_Enabled;
331+
WakeOnLAN_MACAddress = profile.WakeOnLAN_MACAddress;
332+
WakeOnLAN_Broadcast = profile.WakeOnLAN_Broadcast;
333+
WakeOnLAN_OverridePort = profile.WakeOnLAN_OverridePort;
334+
WakeOnLAN_Port = profile.WakeOnLAN_Port;
335+
336+
Whois_Enabled = profile.Whois_Enabled;
337+
Whois_InheritHost = profile.Whois_InheritHost;
338+
Whois_Domain = profile.Whois_Domain;
339+
}
178340
}
179341
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Xml.Serialization;
2+
3+
namespace NETworkManager.Profiles
4+
{
5+
[XmlType("ProfileInfo")] // XML --> Has to mapped because of #378
6+
public class ProfileInfoSerializable : ProfileInfo
7+
{
8+
/// <summary>
9+
/// Override the default remote desktop password to make it serializable.
10+
/// </summary>
11+
public new string RemoteDesktop_Password { get; set; }
12+
13+
public ProfileInfoSerializable()
14+
{
15+
16+
}
17+
18+
public ProfileInfoSerializable(ProfileInfo profile) : base(profile)
19+
{
20+
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)