-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShieldBreakPatcher.cs
More file actions
82 lines (71 loc) · 3.12 KB
/
Copy pathShieldBreakPatcher.cs
File metadata and controls
82 lines (71 loc) · 3.12 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
using System;
using System.IO;
using System.Security.AccessControl;
using System.Security.Principal;
namespace Ubitquity.ShieldBreakMitigation
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("==================================================");
Console.WriteLine(" UBITQUITY / NETTWERKED ShieldBreak Interim Patch ");
Console.WriteLine("==================================================");
if (!IsAdministrator())
{
Console.WriteLine("[!] ERROR: This patch requires Administrative privileges.");
Console.WriteLine(" Please right-click and 'Run as Administrator'.");
Console.ReadLine();
return;
}
string[] targetDirectories = { @"C:\Temp", @"C:\Windows\Temp" };
// Get the SID for the local "Users" group (BUILTIN\Users)
SecurityIdentifier usersGroup = new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null);
foreach (string dir in targetDirectories)
{
if (Directory.Exists(dir))
{
try
{
DirectoryInfo dInfo = new DirectoryInfo(dir);
DirectorySecurity dSecurity = dInfo.GetAccessControl();
// Create the Deny rule for creating junctions (CreateDirectories)
FileSystemAccessRule denyRule = new FileSystemAccessRule(
usersGroup,
FileSystemRights.CreateDirectories,
InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
PropagationFlags.None,
AccessControlType.Deny);
dSecurity.AddAccessRule(denyRule);
dInfo.SetAccessControl(dSecurity);
Console.WriteLine($"[+] SUCCESS: Secured ACLs on {dir}");
}
catch (Exception ex)
{
Console.WriteLine($"[-] ERROR securing {dir}: {ex.Message}");
}
}
else
{
Console.WriteLine($"[*] SKIPPED: Directory {dir} does not exist.");
}
}
Console.WriteLine("\nMitigation applied successfully. Await official Microsoft update.");
// Check for silent flag (used by automated installers)
if (args.Length == 0 || args[0] != "/silent")
{
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
// Helper to check for Administrator privilege
public static bool IsAdministrator()
{
using (WindowsIdentity identity = WindowsIdentity.GetCurrent())
{
WindowsPrincipal principal = new WindowsPrincipal(identity);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}
}
}
}