Exemplo n.º 1
0
        public void Execute()
        {
            StartTime = DateTime.Now;
            // This is the main execution thread.
            Timer statusUpdateTimer =
                new Timer(TimeSpan.FromMinutes(1)
                          .TotalMilliseconds)
            {
                AutoReset = true
            };                        // Set the time (1 min in this case)

            statusUpdateTimer.Elapsed += TimedStatusUpdate;
            statusUpdateTimer.Start();

            // if we haven't been told what dir or computer to target, we're going to need to do share discovery. that means finding computers from the domain.
            if (MyOptions.PathTargets == null && MyOptions.ComputerTargets == null)
            {
                DomainDiscovery();
            }
            // if we've been told what computers to hit...
            else if (MyOptions.ComputerTargets != null)
            {
                ShareDiscovery(MyOptions.ComputerTargets);
            }
            // otherwise we should have a set of path targets...
            else if (MyOptions.PathTargets != null)
            {
                FileDiscovery(MyOptions.PathTargets);
            }
            // but if that hasn't been done, something has gone wrong.
            else
            {
                Mq.Error("OctoParrot says: AWK! I SHOULDN'T BE!");
            }

            waitHandle.WaitOne();

            StatusUpdate();
            DateTime finished = DateTime.Now;
            TimeSpan runSpan  = finished.Subtract(StartTime);

            Mq.Info("Finished at " + finished.ToLocalTime());
            Mq.Info("Snafflin' took " + runSpan);
            Mq.Finish();
        }
Exemplo n.º 2
0
        public void Execute()
        {
            StartTime = DateTime.Now;
            // This is the main execution thread.
            Timer statusUpdateTimer =
                new Timer(TimeSpan.FromMinutes(1)
                          .TotalMilliseconds)
            {
                AutoReset = true
            };                        // Set the time (1 min in this case)

            statusUpdateTimer.Elapsed += TimedStatusUpdate;
            statusUpdateTimer.Start();


            // If we want to hunt for user IDs, we need data from the running user's domain.
            // Future - walk trusts
            if (MyOptions.DomainUserRules)
            {
                DomainUserDiscovery();
            }

            // Explicit folder setting overrides DFS
            if (MyOptions.PathTargets.Count != 0 && (MyOptions.DfsShareDiscovery || MyOptions.DfsOnly))
            {
                DomainDfsDiscovery();
            }

            if (MyOptions.PathTargets.Count == 0 && MyOptions.ComputerTargets == null)
            {
                if (MyOptions.DfsSharesDict.Count == 0)
                {
                    Mq.Info("Invoking DFS Discovery because no ComputerTargets or PathTargets were specified");
                    DomainDfsDiscovery();
                }

                if (!MyOptions.DfsOnly)
                {
                    Mq.Info("Invoking full domain computer discovery.");
                    DomainTargetDiscovery();
                }
                else
                {
                    Mq.Info("Skipping domain computer discovery.");
                    foreach (string share in MyOptions.DfsSharesDict.Keys)
                    {
                        if (!MyOptions.PathTargets.Contains(share))
                        {
                            MyOptions.PathTargets.Add(share);
                        }
                    }
                    Mq.Info("Starting TreeWalker tasks on DFS shares.");
                    FileDiscovery(MyOptions.PathTargets.ToArray());
                }
            }
            // otherwise we should have a set of path targets...
            else if (MyOptions.PathTargets.Count != 0)
            {
                FileDiscovery(MyOptions.PathTargets.ToArray());
            }
            // or we've been told what computers to hit...
            else if (MyOptions.ComputerTargets != null)
            {
                ShareDiscovery(MyOptions.ComputerTargets);
            }

            // but if that hasn't been done, something has gone wrong.
            else
            {
                Mq.Error("OctoParrot says: AWK! I SHOULDN'T BE!");
            }

            waitHandle.WaitOne();

            StatusUpdate();
            DateTime finished = DateTime.Now;
            TimeSpan runSpan  = finished.Subtract(StartTime);

            Mq.Info("Finished at " + finished.ToLocalTime());
            Mq.Info("Snafflin' took " + runSpan);
            Mq.Finish();
        }