Skip to content

Commit 0c965c5

Browse files
additions and bug fixes
1 parent 36cc98f commit 0c965c5

File tree

13 files changed

+172
-62
lines changed

13 files changed

+172
-62
lines changed

Logging/Logging.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,22 @@ internal static class Log
2424

2525
internal sealed class Options
2626
{
27-
internal static Options Default() => new(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
28-
2927
internal const Int32 DEFAULT_PADDING_WIDTH = 52;
3028
internal const String FILENAME_FORMAT = "yyyy.MM.dd";
3129
internal const String TIME_FORMAT = "dd.MM.yyyy HH:mm:ss";
3230

31+
public Options()
32+
{
33+
LogDirectoryPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
34+
Padding = DEFAULT_PADDING_WIDTH;
35+
TimeFormat = TIME_FORMAT;
36+
FilenameFormat = FILENAME_FORMAT;
37+
DefaultTextColor = Console.ForegroundColor;
38+
AllocateConsoleInReleaseMode = false;
39+
40+
Initialized = true;
41+
}
42+
3343
internal Options(String logDirectoryPath, Int32 padding = DEFAULT_PADDING_WIDTH, String timeFormat = TIME_FORMAT, String filenameFormat = FILENAME_FORMAT, Boolean allocateConsoleInReleaseMode = false)
3444
{
3545
LogDirectoryPath = logDirectoryPath;

OS Stimulator.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@
184184
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
185185
</EmbeddedResource>
186186
<None Include="App\app.manifest" />
187-
<None Include="ClassDiagram1.cd" />
188187
<None Include="packages.config" />
189188
<None Include="Properties\Settings.settings">
190189
<Generator>SettingsSingleFileGenerator</Generator>

Program/Applications/Codecs.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,17 @@ private static async Task Codecs() => await Task.Run(() =>
4242

4343
for (Int32 i = 0; i < files.Length; ++i)
4444
{
45-
Log.FastLog("Installing: " + files[i], LogSeverity.Info, CODECS_SOURCE);
46-
PowerShell.Create().AddCommand("Add-AppPackage")
47-
.AddParameter("-Path", files[i])
48-
.Invoke();
45+
try
46+
{
47+
Log.FastLog("Installing: " + files[i], LogSeverity.Info, CODECS_SOURCE);
48+
PowerShell.Create().AddCommand("Add-AppPackage")
49+
.AddParameter("-Path", files[i])
50+
.Invoke();
51+
}
52+
catch (Exception exception)
53+
{
54+
Log.FastLog($"Failed to install {files[i]}: " + exception.Message, LogSeverity.Warning, CODECS_SOURCE);
55+
}
4956
}
5057

5158
Log.FastLog("Done", LogSeverity.Info, CODECS_SOURCE);

Program/Applications/ImageGlass.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using BSS.Logging;
22
using System;
3+
using System.Diagnostics;
34
using System.IO;
45
using System.Threading.Tasks;
56

@@ -13,6 +14,23 @@ private static async Task ImageGlass() => await Task.Run(() =>
1314
{
1415
try
1516
{
17+
Process[] processes = Process.GetProcessesByName("ImageGlass");
18+
if (processes != null && processes.Length != 0)
19+
{
20+
System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show(
21+
$"{processes.Length} instances open, end all tasks?",
22+
IMAGEGLASS_SOURCE,
23+
System.Windows.Forms.MessageBoxButtons.YesNo,
24+
System.Windows.Forms.MessageBoxIcon.Question);
25+
26+
if (result != System.Windows.Forms.DialogResult.Yes) return;
27+
28+
for (Int32 i = 0; i < processes.Length; ++i)
29+
{
30+
processes[i].Kill();
31+
}
32+
}
33+
1634
Log.FastLog("Installing " + IMAGEGLASS_SOURCE, LogSeverity.Info, IMAGEGLASS_SOURCE);
1735

1836
if (!File.Exists(RunContextInfo.ExecutablePath + "\\assets\\ImageGlass\\ImageGlass_x64.msi")

Program/Applications/Notepad++.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using BSS.Logging;
22
using Microsoft.Win32;
33
using System;
4+
using System.Diagnostics;
45
using System.IO;
56
using System.IO.Compression;
67
using System.Threading.Tasks;
@@ -15,6 +16,23 @@ private static async Task InstallNotepadPlusPlus() => await Task.Run(() =>
1516
{
1617
try
1718
{
19+
Process[] processes = Process.GetProcessesByName("notepad++");
20+
if (processes != null && processes.Length != 0)
21+
{
22+
System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show(
23+
$"{processes.Length} instances open, end all tasks?",
24+
"Notepad++",
25+
System.Windows.Forms.MessageBoxButtons.YesNo,
26+
System.Windows.Forms.MessageBoxIcon.Question);
27+
28+
if (result != System.Windows.Forms.DialogResult.Yes) return;
29+
30+
for (Int32 i = 0; i < processes.Length; ++i)
31+
{
32+
processes[i].Kill();
33+
}
34+
}
35+
1836
Log.FastLog("Installing Notepad++", LogSeverity.Info, NOTEPADPLUSPLUS_SOURCE);
1937

2038
Util.KillExplorer(true);

Program/Miscellaneous/NGEN.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ private static async Task NGEN() => await Task.Run(() =>
2121
{
2222
if (File.Exists(runtimes[i] + "\\ngen.exe"))
2323
{
24-
Log.FastLog($"Starting{runtimes[i]}\\ngen.exe executeQueuedItems", LogSeverity.Info, NGEN_SOURCE);
24+
Log.FastLog($"Starting {runtimes[i]}\\ngen.exe executeQueuedItems", LogSeverity.Info, NGEN_SOURCE);
2525
Util.Execute.Process(new(runtimes[i] + "\\ngen.exe", "executeQueuedItems", true, true, true));
2626
}
2727
}
@@ -34,7 +34,7 @@ private static async Task NGEN() => await Task.Run(() =>
3434
{
3535
if (File.Exists(runtimes[i] + "\\ngen.exe"))
3636
{
37-
Log.FastLog($"Starting{runtimes[i]}\\ngen.exe executeQueuedItems", LogSeverity.Info, NGEN_SOURCE);
37+
Log.FastLog($"Starting {runtimes[i]}\\ngen.exe executeQueuedItems", LogSeverity.Info, NGEN_SOURCE);
3838
Util.Execute.Process(new(runtimes[i] + "\\ngen.exe", "executeQueuedItems", true, true, true));
3939
}
4040
}

Program/Privacy_and_Security/Privacy.cs

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ private async static Task Privacy()
3737
new(true, false, "Deactivate cross device message and clipboard sync", null!),
3838
new(true, false, "Deactivate Cortana", null!),
3939
new(true, false, "Deactivate reports to SpyNet", null!),
40-
new(true, false, "Don't remember recently opened files", null!),
40+
new(true, false, "*Don't remember and show recently opened files", "WIN + R will not keep track of entered commands"),
41+
new(true, false, "Deactivate Lock scree tips and tricks", null!),
4142
];
4243

4344
OptionSelector optionSelector = new("Privacy", options, new(true, 0, "privacy.cfg"));
@@ -440,16 +441,16 @@ await Task.Run(() =>
440441
{
441442
Log.FastLog("[MACHINE][USER] Deactivating Cortana", LogSeverity.Info, PRIVACY_SOURCE);
442443

443-
Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCortana ", 0, RegistryValueKind.DWord);
444-
Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCortanaAboveLock ", 0, RegistryValueKind.DWord);
445-
Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\InputPersonalization", "AllowInputPersonalization ", 0, RegistryValueKind.DWord);
444+
Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCortana", 0, RegistryValueKind.DWord);
445+
Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search", "AllowCortanaAboveLock", 0, RegistryValueKind.DWord);
446+
Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\InputPersonalization", "AllowInputPersonalization", 0, RegistryValueKind.DWord);
446447

447-
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Windows Search", "CortanaConsent ", 0, RegistryValueKind.DWord);
448-
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Personalization\Settings", "AcceptedPrivacyPolicy ", 0, RegistryValueKind.DWord);
448+
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Windows Search", "CortanaConsent", 0, RegistryValueKind.DWord);
449+
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Personalization\Settings", "AcceptedPrivacyPolicy", 0, RegistryValueKind.DWord);
449450

450-
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\InputPersonalization", "RestrictImplicitTextCollection ", 0, RegistryValueKind.DWord);
451-
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\InputPersonalization", "RestrictImplicitInkCollection ", 0, RegistryValueKind.DWord);
452-
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\InputPersonalization\TrainedDataStore", "HarvestContacts ", 0, RegistryValueKind.DWord);
451+
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\InputPersonalization", "RestrictImplicitTextCollection", 0, RegistryValueKind.DWord);
452+
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\InputPersonalization", "RestrictImplicitInkCollection", 0, RegistryValueKind.DWord);
453+
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\InputPersonalization\TrainedDataStore", "HarvestContacts", 0, RegistryValueKind.DWord);
453454

454455

455456
}
@@ -465,9 +466,9 @@ await Task.Run(() =>
465466
{
466467
Log.FastLog("[MACHINE] Deactivating reports to SpyNet", LogSeverity.Info, PRIVACY_SOURCE);
467468

468-
Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows Defender\Spynet", "SubmitSamplesConsent ", 2, RegistryValueKind.DWord);
469-
Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows Defender\Spynet", "SpyNetReporting ", 0, RegistryValueKind.DWord);
470-
Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\MRT", "DontReportInfectionInformation ", 1, RegistryValueKind.DWord);
469+
Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows Defender\Spynet", "SubmitSamplesConsent", 2, RegistryValueKind.DWord);
470+
Registry.SetValue(@"HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows Defender\Spynet", "SpyNetReporting", 0, RegistryValueKind.DWord);
471+
Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\MRT", "DontReportInfectionInformation", 1, RegistryValueKind.DWord);
471472
}
472473
}
473474
catch (Exception exception)
@@ -479,16 +480,40 @@ await Task.Run(() =>
479480
{
480481
if (optionSelector.Result.UserSelection[24])
481482
{
482-
Log.FastLog("[USER] Don't remember recently opened files", LogSeverity.Info, PRIVACY_SOURCE);
483+
Log.FastLog("[USER] Don't remember and show recently opened files", LogSeverity.Info, PRIVACY_SOURCE);
483484

484-
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Start_TrackDocs ", 0, RegistryValueKind.DWord);
485+
RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RecentDocs", true);
486+
key?.DeleteValue("MRUListEx", false);
487+
488+
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer", "ShowFrequent", 0, RegistryValueKind.DWord);
489+
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer", "ShowRecent", 0, RegistryValueKind.DWord);
490+
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer", "ShowRecommendations", 0, RegistryValueKind.DWord);
491+
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer", "ShowCloudFilesInQuickAccess", 0, RegistryValueKind.DWord);
492+
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Start", "ShowRecentList", 0, RegistryValueKind.DWord);
493+
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Start_TrackDoc", 0, RegistryValueKind.DWord);
485494
}
486495
}
487496
catch (Exception exception)
488497
{
489498
Log.FastLog("[USER] Don't remember recently opened files failed with: " + exception.Message, LogSeverity.Error, PRIVACY_SOURCE);
490499
}
491500

501+
try
502+
{
503+
if (optionSelector.Result.UserSelection[25])
504+
{
505+
Log.FastLog("[USER] Disabling lock screen tips and tricks", LogSeverity.Info, PRIVACY_SOURCE);
506+
507+
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "SubscribedContent-338387Enabled", 0, RegistryValueKind.DWord);
508+
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager", "RotatingLockScreenOverlayEnabled", 0, RegistryValueKind.DWord);
509+
510+
}
511+
}
512+
catch (Exception exception)
513+
{
514+
Log.FastLog("[USER] Disabling lock screen tips and tricks failed with: " + exception.Message, LogSeverity.Error, PRIVACY_SOURCE);
515+
}
516+
492517
Util.RestartExplorerForUser();
493518
});
494519

Program/Privacy_and_Security/SystemSecurity/Harden.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ private async static Task Harden()
3131
new(false, false, "Set default app for .cmd to notepad", null!),
3232
new(true, false, "Set default app for .vbs to notepad", null!),
3333
new(true, false, "Set default app for .vbe to notepad", null!),
34-
new(true, false, "*Block system apps in firewall (see tooltip) , ", "notepad.exe, regsvr32.exe, mshta.exe, wscript.exe, cscript.exe, runscripthelper.exe, hh.exe"),
34+
new(true, false, "*Block system apps in firewall (see tooltip)", "notepad.exe, regsvr32.exe, mshta.exe, wscript.exe, cscript.exe, runscripthelper.exe, hh.exe"),
3535
new(true, false, "Deactivate anonymous Sam-Account enumeration", null!),
3636
new(true, false, "Activate Anti-spoof for facial recognition", null!),
3737
new(true, false, "Deactivate camera on locked screen", null!),

Program/Privacy_and_Security/SystemSecurity/VBS.cs

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -88,29 +88,20 @@ private static void EnableVBS()
8888
private static void DisableVBS()
8989
{
9090
RegistryKey controlLsa = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Control\\Lsa", true);
91-
controlLsa.DeleteValue("LsaCfgFlags", false);
91+
controlLsa?.DeleteValue("LsaCfgFlags", false);
9292

9393
RegistryKey windowsDeviceGuard = Registry.LocalMachine.OpenSubKey("Software\\Policies\\Microsoft\\Windows\\DeviceGuard", true);
94-
windowsDeviceGuard.DeleteValue("RequirePlatformSecurityFeatures", false);
95-
windowsDeviceGuard.DeleteValue("ConfigureKernelShadowStacksLaunch", false);
96-
windowsDeviceGuard.DeleteValue("ConfigureSystemGuardLaunch", false);
97-
windowsDeviceGuard.DeleteValue("MachineIdentityIsolation", false);
98-
windowsDeviceGuard.DeleteValue("LsaCfgFlags", false);
99-
windowsDeviceGuard.DeleteValue("HVCIMATRequired", false);
100-
windowsDeviceGuard.DeleteValue("HypervisorEnforcedCodeIntegrity", false);
101-
windowsDeviceGuard.DeleteValue("EnableVirtualizationBasedSecurity", false);
102-
103-
RegistryKey controlDeviceGuard = Registry.LocalMachine.OpenSubKey("System\\ControlSet001\\Control\\DeviceGuard", true);
104-
controlDeviceGuard.DeleteValue("Locked", false);
105-
controlDeviceGuard.DeleteValue("EnableVirtualizationBasedSecurity", false);
106-
107-
RegistryKey hypervisorEnforcedCodeIntegrity = Registry.LocalMachine.OpenSubKey("System\\ControlSet001\\Control\\DeviceGuard\\Scenarios\\HypervisorEnforcedCodeIntegrity", true);
108-
hypervisorEnforcedCodeIntegrity.DeleteValue("Locked", false);
109-
hypervisorEnforcedCodeIntegrity.DeleteValue("HVCIMATRequired", false);
110-
hypervisorEnforcedCodeIntegrity.DeleteValue("Enabled", false);
111-
112-
RegistryKey kernelShadowStacks = Registry.LocalMachine.OpenSubKey("System\\ControlSet001\\Control\\DeviceGuard\\Scenarios\\KernelShadowStacks", true);
113-
kernelShadowStacks.DeleteValue("Enabled", false);
94+
windowsDeviceGuard?.DeleteValue("RequirePlatformSecurityFeatures", false);
95+
windowsDeviceGuard?.DeleteValue("ConfigureKernelShadowStacksLaunch", false);
96+
windowsDeviceGuard?.DeleteValue("ConfigureSystemGuardLaunch", false);
97+
windowsDeviceGuard?.DeleteValue("MachineIdentityIsolation", false);
98+
windowsDeviceGuard?.DeleteValue("LsaCfgFlags", false);
99+
windowsDeviceGuard?.DeleteValue("HVCIMATRequired", false);
100+
windowsDeviceGuard?.DeleteValue("HypervisorEnforcedCodeIntegrity", false);
101+
windowsDeviceGuard?.DeleteValue("EnableVirtualizationBasedSecurity", false);
102+
103+
RegistryKey controlDeviceGuard = Registry.LocalMachine.OpenSubKey("System\\ControlSet001\\Control", true);
104+
controlDeviceGuard?.DeleteSubKeyTree("DeviceGuard", false);
114105

115106
Log.FastLog($"Removed VBS config values from the registry, a restart is needed to apply the changes. You may want check the status with msinfo32 | consider using 'bcdedit /set hypervisorlaunchtype off'", LogSeverity.Info, VBS_SOURCE);
116107

0 commit comments

Comments
 (0)