Beispiel #1
0
        public void TestGetService()
        {
            var service = SCM.GetService("localhost", "Netlogon");

            Assert.IsNotNull(service);
            Assert.AreEqual("Netlogon", service.DisplayName);
        }
Beispiel #2
0
        public void TestCreateGetStartStopDeleteService()
        {
            bool result = SCM.CreateService("localhost", "SharpSploit Service", "SharpSploitSvc", @"C:\Temp\SharpSploitService.exe");

            Assert.IsTrue(result);

            var service = SCM.GetService("localhost", "SharpSploitSvc");

            Assert.AreEqual("SharpSploitSvc", service.DisplayName);
            Assert.AreEqual("SharpSploit Service", service.ServiceName);
            Assert.AreEqual(ServiceControllerStatus.Stopped, service.Status);
            Assert.AreEqual(false, service.CanStop);

            result = SCM.StartService("localhost", "SharpSploitSvc");
            Assert.IsTrue(result);

            service = SCM.GetService("localhost", "SharpSploitSvc");
            Assert.AreEqual("SharpSploitSvc", service.DisplayName);
            Assert.AreEqual("SharpSploit Service", service.ServiceName);
            Assert.AreEqual(ServiceControllerStatus.Running, service.Status);
            Assert.AreEqual(true, service.CanStop);

            result = SCM.StopService("localhost", "SharpSploitSvc");
            Assert.IsTrue(result);

            service = SCM.GetService("localhost", "SharpSploitSvc");
            Assert.AreEqual("SharpSploitSvc", service.DisplayName);
            Assert.AreEqual("SharpSploit Service", service.ServiceName);
            Assert.AreEqual(ServiceControllerStatus.Stopped, service.Status);
            Assert.AreEqual(false, service.CanStop);

            result = SCM.DeleteService("localhost", "SharpSploit Service");
            Assert.IsTrue(result);

            service = SCM.GetService("localhost", "SharpSploitSvc");
            Assert.IsNull(service);
        }
Beispiel #3
0
        public void TestGetServiceBadServiceName()
        {
            var service = SCM.GetService("localhost", "blah");

            Assert.IsNull(service);
        }