예제 #1
0
 public bool LsbDistinct()
 {
     try
     {
         var networkActivitities = new List <BsonDocument>();
         if (SelectedUsers.Count < 11 || SelectedMachines.Count < 1)
         {
             return(false);
         }
         DbClient.ClearTestCollections();
         SvcCtrl.StopService("ATACenter");
         DbClient.SetCenterProfileForReplay();
         Logger.Debug("Center profile set for replay");
         networkActivitities.AddRange(
             SelectedUsers.Select(
                 user =>
                 DocumentCreator.SimpleBindCreator(user, SelectedMachines[0],
                                                   SelectedDomainControllers.FirstOrDefault(), DomainList.Single(_ => _.Id == user.Domain).Name
                                                   , DomainList.Single(_ => _.Id == SelectedMachines[0].Domain).Name, SourceGateway)));
         DbClient.InsertBatch(networkActivitities);
         Logger.Debug("Done inserting Ldap activities");
         SvcCtrl.StartService("ATACenter");
         return(true);
     }
     catch (Exception distinctException)
     {
         Logger.Error(distinctException);
         return(false);
     }
 }
예제 #2
0
 public bool GoldenTicketActivity()
 {
     try
     {
         var tgsList       = new List <BsonDocument>();
         var userEntity    = Users.First(_ => _.Name == "user1");
         var machineEntity = Machines.First(_ => _.Name == "CLIENT1");
         for (var loopIndex = 0; loopIndex <= _saAmount; loopIndex++)
         {
             tgsList.Add(DocumentCreator.KerberosCreator(userEntity, machineEntity,
                                                         DomainControllers.FirstOrDefault(), DomainList.Single(_ => _.Id == userEntity.Domain).Name
                                                         , DomainList.Single(_ => _.Id == machineEntity.Domain).Name, SourceGateway, $"{(Spn)(_random.Next(0, 5))}/{Machines[loopIndex].Name}", null, "Tgs"));
         }
         DbClient.SetCenterProfileForReplay();
         SvcCtrl.StopService("ATACenter");
         DbClient.InsertBatch(tgsList);
         SvcCtrl.StartService("ATACenter");
         return(true);
     }
     catch (Exception e)
     {
         Logger.Error(e);
         return(false);
     }
 }
예제 #3
0
        /// <summary>
        /// Stops the specified service
        /// </summary>
        /// <param name="ServiceName">The service name </param>
        /// <param name="TimeOutSec">Optionl Timout in seconds</param>
        /// <returns></returns>
        public static bool StopService(string ServiceName, int TimeOutSec = 180)
        {
            bool Exists = false;

            foreach (ServiceController SvcCtrl in ServiceController.GetServices())
            {
                if (SvcCtrl.ServiceName == ServiceName)
                {
                    Exists = true;
                    WriteToApplicationLog("Stop Service: " + ServiceName, EventLogEntryType.Information);
                    try
                    {
                        if (SvcCtrl.Status == ServiceControllerStatus.Stopped)
                        {
                            return(true);
                        }
                        switch (SvcCtrl.Status)
                        {
                        case ServiceControllerStatus.PausePending:
                            SvcCtrl.WaitForStatus(ServiceControllerStatus.Paused, new TimeSpan(TimeSpan.TicksPerSecond * TimeOutSec));
                            SvcCtrl.Stop();
                            SvcCtrl.WaitForStatus(ServiceControllerStatus.Stopped, new TimeSpan(TimeSpan.TicksPerSecond * TimeOutSec));
                            break;

                        case ServiceControllerStatus.ContinuePending:
                            SvcCtrl.WaitForStatus(ServiceControllerStatus.Running, new TimeSpan(TimeSpan.TicksPerSecond * TimeOutSec));
                            SvcCtrl.Stop();
                            SvcCtrl.WaitForStatus(ServiceControllerStatus.Stopped, new TimeSpan(TimeSpan.TicksPerSecond * TimeOutSec));
                            break;

                        default:
                            SvcCtrl.Stop();
                            SvcCtrl.WaitForStatus(ServiceControllerStatus.Stopped, new TimeSpan(TimeSpan.TicksPerSecond * TimeOutSec));
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        WriteToApplicationLog(ex.Message + Environment.NewLine + ex.StackTrace, EventLogEntryType.Error);
                        return(false);
                    }
                    WriteToApplicationLog("Service Stopped successfully: " + ServiceName, EventLogEntryType.SuccessAudit);
                    break;
                }
            }
            if (!Exists)
            {
                WriteToApplicationLog("Service Not Found: " + ServiceName, EventLogEntryType.SuccessAudit);
                throw new Exception("Service Not Found: " + ServiceName);
            }
            return(true);
        }
예제 #4
0
 private void InsertActivities(bool isLearning = false)
 {
     DbClient.ClearTestCollections();
     SvcCtrl.StopService("ATACenter");
     if (isLearning)
     {
         DbClient.SetCenterProfileForReplay();
         DbClient.SetDetectorProfileForSamr();
     }
     DbClient.InsertBatch(ActivitiesList);
     ActivitiesList.Clear();
     SvcCtrl.StartService("ATACenter");
 }