Editing the remote registry is easy with C#'s WMI/Registry provider. I've recently implemented these features into my MobileExec Program to disable CAC access. See below:
ConnectionOptions co = new ConnectionOptions();
co.Username = txtUsername.Text;
co.Password = txtPassword.Text;
co.Impersonation = ImpersonationLevel.Impersonate;
co.EnablePrivileges = true;
co.Authentication = AuthenticationLevel.PacketPrivacy;
System.Net.IPHostEntry h =
System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName());
string IPAddress = h.AddressList.GetValue(0).ToString();
string lm = System.Net.Dns.GetHostName().ToString();
if (txtUsername.Text == "" || txtPassword.Text == ""
|| txtServer.Text == "127.0.0.1"
|| txtServer.Text.ToLower() == "localhost"
|| txtServer.Text.ToLower() == lm.ToLower()
|| txtServer.Text.ToLower() == IPAddress.ToLower())
{
co.Username = null;
co.Password = null;
}
string temp1 = txtServer.Text;
Label1.ForeColor = Color.Black;
this.Label1.Style["text-align"] = "left";
try
{
ManagementScope myScope =
new ManagementScope("\\\\" + temp1 + "\\root\\default", co);
ManagementPath mypath = new ManagementPath("StdRegProv");
ManagementClass wmiRegistry =
new ManagementClass(myScope, mypath, null);
const uint HKEY_LOCAL_MACHINE = unchecked((uint)0x80000002);
string keyPath = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System";
ManagementBaseObject inParams6 = wmiRegistry.GetMethodParameters("SetDWORDValue");
inParams6["hDefKey"] = HKEY_LOCAL_MACHINE;
inParams6["sSubKeyName"] = keyPath;
inParams6["sValueName"] = "SCForceOption";
inParams6["uValue"] = (UInt32)0;
ManagementBaseObject outParams6 = wmiRegistry.InvokeMethod("SetDWORDValue", inParams6, null);
Label1.Text = "Done! CAC Disabled";
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
Various Scripts and Application Code Segments for .NET, VB, C#, C++, C, Java, JavaScript, HTML, Python, Perl, AutoIT, Batch, ASP Classic, Objective-C, Swift, Unreal Engine 4, Unity3D & others. Also contains numerous IT tidbits, procedures, and tricks including Technology Hacks on various platforms.
Subscribe to:
Post Comments (Atom)
Generating "Always On Top" NSWindow in macOS across all detected displays
Also: Using UIKit & Cocoa Frameworks using Objective-C In m acOS or OS X , written in either Objective-C or Swift Langues, you m...
-
In Unreal Engine 4 you will eventually need Linear Interpolation between two values to do something like ping pong between two float val...
-
Recently Possess () has been deprecated from UE4 , and when writing classes based on AAIController you have to use the function OnPossess ...
-
Often we intermingle C++ and Blueprints, and need for the two to communicate. With Behavior Trees, using ENUMs is an everyday occurrence an...
No comments:
Post a Comment