Пример #1
0
 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";
Пример #2
0
        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");
            }
        }
Пример #3
0
 public static void AssemblyInit(TestContext context)
 {
     filePath = folder + "\\Test.txt";
     NonAdmin.ClearAutoClosePrograms();
     NonAdmin.UnlockFolder(filePath);
     NonAdmin.HideAndProtectFolder(filePath, false);
 }
Пример #4
0
 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;
     }
 }
Пример #6
0
        public void CloseFileExplorerTest()
        {
            Process explorer = new Process();

            explorer.StartInfo.FileName = "explorer.exe";
            explorer.Start();
            Thread.Sleep(2000);
            NonAdmin.CloseFileExplorer();
            Assert.IsTrue(explorer.HasExited);
        }
Пример #7
0
        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();
        }
Пример #8
0
        public void CloseProgramTest()
        {
            Process newNotepad = new Process();

            newNotepad.StartInfo.FileName = "notepad.exe";
            newNotepad.Start();
            Thread.Sleep(2000);
            NonAdmin.CloseProgram("notepad");
            Assert.IsTrue(newNotepad.HasExited);
        }
Пример #9
0
        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);
        }
Пример #13
0
        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);
        }
Пример #14
0
        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();
        }
Пример #15
0
 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
Пример #17
0
 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();
 }
Пример #18
0
        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
Пример #20
0
 public void DoesServiceExistTest()
 {
     Assert.IsTrue(NonAdmin.DoesServiceExist("SysMain", Environment.MachineName));
 }
Пример #21
0
 public void IsWindowsInSafeModeTest()
 {
     NonAdmin.IsWindowsInSafeMode();
 }
Пример #22
0
 public void IsInAdministratorModeTest()
 {
     // No way to be sure at the moment
     NonAdmin.IsInAdministratorMode();
 }
Пример #23
0
 static void virtualDesktopTestAsync()
 {
     NonAdmin.CreateNewVirtualDesktop();
     NonAdmin.SwitchToVirtualDesktop(true);
 }