public static void StartService(string serviceName = "Bolter Admin Service", string adminAppName = "BolterAdminApp", bool enableUACprompt = true) { if (enableUACprompt && !NonAdmin.IsInAdministratorMode()) { // Technique : Use the admin app (UAC prompt) string projectDirPath = Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.Parent.Parent.Parent.FullName; // The path to all visual studio projects var adminAppPath = projectDirPath + @$ "\Bolter\BolterAdminApp\bin\Debug\netcoreapp3.1\{adminAppName}.exe";
public void RequestSetStartupSafeModeTest() { if (NonAdmin.DoesServiceExist("Bolter Admin Service", Environment.MachineName)) { var keyPath = @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"; var shellKey = "Shell"; var key = Registry.LocalMachine.OpenSubKey(keyPath, false); ReceiverClient client = new ReceiverClient(); client.ConnectToBolterService(IP_SERVER_ADDRESS, PORT); Thread.Sleep(1000); string initial = (string)key.GetValue(shellKey); Console.WriteLine("Initial value :" + initial); client.RequestSetStartupSafeMode(true, System.Reflection.Assembly.GetEntryAssembly().Location); Thread.Sleep(1000); string edited = (string)key.GetValue(shellKey); Console.WriteLine("Edited value :" + edited); client.RequestSetStartupSafeMode(false, System.Reflection.Assembly.GetEntryAssembly().Location); Thread.Sleep(1000); string revert = (string)key.GetValue(shellKey); Console.WriteLine("Revert value :" + revert); Assert.AreEqual(initial, revert); } else { Assert.Fail("The Bolter Service must be installed to run this test"); } }
public static void AssemblyInit(TestContext context) { filePath = folder + "\\Test.txt"; NonAdmin.ClearAutoClosePrograms(); NonAdmin.UnlockFolder(filePath); NonAdmin.HideAndProtectFolder(filePath, false); }
private static void InstallService() { Admin.InstallService(); if (NonAdmin.IsInAdministratorMode()) { } ; }
public void Put(string email, [FromBody] NonAdmin nonadmin_update) { //update NonAdmins with specific email from database if (!ModelState.IsValid || nonadmin_update == null) { return; } }
public void CloseFileExplorerTest() { Process explorer = new Process(); explorer.StartInfo.FileName = "explorer.exe"; explorer.Start(); Thread.Sleep(2000); NonAdmin.CloseFileExplorer(); Assert.IsTrue(explorer.HasExited); }
static void folderLockTest() { string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\BUNKER"; Directory.CreateDirectory(path); NonAdmin.LockFolder(path, false); Thread.Sleep(20000); NonAdmin.UnlockFolder(path); Console.ReadLine(); }
public void CloseProgramTest() { Process newNotepad = new Process(); newNotepad.StartInfo.FileName = "notepad.exe"; newNotepad.Start(); Thread.Sleep(2000); NonAdmin.CloseProgram("notepad"); Assert.IsTrue(newNotepad.HasExited); }
public void GetTaskManagerActivationTest() { string taskmgr = "taskmgr"; bool enabled = NonAdmin.GetTaskManagerActivation(); if (enabled) { Process.Start("CMD.exe", $"/C {taskmgr}"); Assert.IsTrue(Process.GetProcessesByName(taskmgr).Length > 0); } }
public NonAdmin Post([FromBody] NonAdmin NonAdmin) { if (!ModelState.IsValid || NonAdmin == null) { return(null); } //add Administrator to Database return(NonAdmin); }
public NonAdmin Post([FromBody] NonAdmin NonAdmin) { if (!ModelState.IsValid || NonAdmin == null) { return(null); } //add Administrator to Database var add = new NonAdminLogic().CreateUser(NonAdmin.Email, NonAdmin.Psswrd, NonAdmin.FirstName, NonAdmin.LastName); return(NonAdmin); }
public NonAdmin Put(string email, [FromBody] NonAdmin nonadmin_update) { //update NonAdmins with specific email from database if (!ModelState.IsValid || nonadmin_update == null) { return(null); } var update = new NonAdminLogic().UpdateUser(nonadmin_update.Email, nonadmin_update.Psswrd, nonadmin_update.FirstName, nonadmin_update.LastName); return(nonadmin_update); }
public void RunRespawnableProgramTest() { string programName = "notepad"; string programExeName = "notepad.exe"; NonAdmin.RunRespawnableProgram(programExeName, DateTime.Now, DateTime.Now.AddMinutes(1)); Thread.Sleep(2000); NonAdmin.CloseProgram(programName); Thread.Sleep(3000); // We check if the program has resurrected Assert.IsTrue(Process.GetProcessesByName(programName).Length > 0); NonAdmin.CloseProgram(programName); }
public void AddAutoCloseProgramsTest() { int i = 0; NonAdmin.AutoCloseProgramListChanged += (s, e) => { if (e.ProgramAction == NonAdmin.ProgramListAction.Added) { i++; } }; NonAdmin.AddAutoCloseProgram("test", TimeSpan.Zero, new TimeSpan(23, 59, 59), false); NonAdmin.AddAutoCloseProgram("test2", TimeSpan.Zero, new TimeSpan(23, 59, 59), false); Assert.AreEqual(i, 2); NonAdmin.ClearAutoClosePrograms(); }
public void HideAndProtectFolderTest() { try { File.WriteAllText(filePath, "Test"); NonAdmin.HideAndProtectFolder(filePath, true); File.Delete(filePath); } catch (Exception) { Assert.IsTrue(File.Exists(filePath)); } finally { Assert.IsTrue(File.Exists(filePath)); } }
} // End UpdateUser // DELETE a User public override bool DeleteUser(string Email) { try { NonAdmin AdminTemp = context.NonAdmin.FirstOrDefault(i => i.Email == Email); context.NonAdmin.Remove(AdminTemp); UserCreds Temp = context.UserCreds.FirstOrDefault(i => i.Email == Email); context.UserCreds.Remove(Temp); context.SaveChanges(); return(true); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(false); } } // End DeleteUser
static void Main(string[] args) { Console.WriteLine("This is the demo client (console version), user : "******"[MATRIX] Requesting remote service admin commands"); // Use the service or bridge admin app cl.ConnectToBolterService(IP_SERVER_ADDRESS, PORT); // cl.RequestSetBatchAndCMDBlock(false); // cl.RequestPreventDateEditingW10(true); // cl.RequestSetBatchAndCMDBlock(false); // AdminSandbox.RequestRemoteCommands(cl); Console.WriteLine("[MATRIX] All commands requested"); // Thread.Sleep(20000); Console.WriteLine("Now unblocking"); cl.RequestDisableAllAdminRestrictions(AppDomain.CurrentDomain.BaseDirectory); Console.WriteLine("Sleeping 20s"); } else { Admin.SetBatchAndCMDBlock(false, "franc"); Admin.PreventDateEditingW10(true); Admin.SetBatchAndCMDBlock(false, "franc"); } Console.WriteLine("Unblocked Admin"); NonAdmin.DisableAllNonAdminRestrictions(); //cl.RequestDisableAllAdminRestrictions(AppDomain.CurrentDomain.BaseDirectory); // RealServiceTestTCP(true); new ManualResetEvent(false).WaitOne(); }
public void SetStartupSafeModeTest() { if (!NonAdmin.IsInAdministratorMode()) { throw new UnauthorizedAccessException("We need to run these tests with UAC enabled"); } var keyPath = @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"; var shellKey = "Shell"; var key = Registry.LocalMachine.OpenSubKey(keyPath, true); string initial = (string)key.GetValue(shellKey); Admin.SetStartupSafeMode(true); Admin.SetStartupSafeMode(true); // Try to put 2 times the same path string edited = (string)key.GetValue(shellKey); Console.WriteLine("Edited to " + edited); Admin.SetStartupSafeMode(false); string revert = (string)key.GetValue(shellKey); Console.WriteLine("Reverted to " + revert); Assert.AreEqual(initial, revert); }
// CREATE a NonAdmin User public override bool CreateUser(string Email, string Password, string FirstName, string LastName) { try { UserCreds temp = new UserCreds(); temp.Email = Email; temp.Psswrd = Password; temp.FirstName = FirstName; temp.LastName = LastName; context.UserCreds.Add(temp); NonAdmin userTemp = new NonAdmin(); userTemp.Email = Email; context.NonAdmin.Add(userTemp); context.SaveChanges(); return(true); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(false); } } // End CreateUser
public void DoesServiceExistTest() { Assert.IsTrue(NonAdmin.DoesServiceExist("SysMain", Environment.MachineName)); }
public void IsWindowsInSafeModeTest() { NonAdmin.IsWindowsInSafeMode(); }
public void IsInAdministratorModeTest() { // No way to be sure at the moment NonAdmin.IsInAdministratorMode(); }
static void virtualDesktopTestAsync() { NonAdmin.CreateNewVirtualDesktop(); NonAdmin.SwitchToVirtualDesktop(true); }