public void TryToRunNormalFlow(ParsingArgsResult options, ConsoleVisualization consoleVisualization)
 {
     try
     {
         Console.WriteLine(string.Format("Requesting information to {0}", options.Server));
         RunNormalFlow(options, consoleVisualization);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
        private void RunNormalFlow(ParsingArgsResult options, ConsoleVisualization consoleVisualization)
        {
            AuthPair authPair = null;
            var serverToConnect = Localhost;

            if (options.IsDataIncluded)
            {
                authPair = new AuthPair { UserName = options.UserName, Password = options.Password };
                serverToConnect = options.Server;
            }

            var wmiQueryProvider = new Core.Wmi.WmiQueryProvider(serverToConnect, NameSpace, authPair);
            var managementCollection = wmiQueryProvider.GetManagementObjects(Class);
            var wmiQueryFilter = new Core.Wmi.WmiCollectionFilter(managementCollection);
            var all = wmiQueryFilter.GetAll();
            var converter = new ManagementObjectToWebDomainConverter();
            var result = converter.GetWebDomains(all);

            consoleVisualization.Run(result.OrderByDescending(wd => wd.CurrentConnections).Take(options.Number));
        }
Ejemplo n.º 3
0
        private const string VersionNumberString = "v1.0"; //Using a fixed string by now

        #endregion Fields

        #region Methods

        static void Main(string[] args)
        {
            var options = new ParsingArgsResult { Number = DefaultNumberOfResults };

            var executionController = new ExecFlowController();
            ICommandLineParser parser = new CommandLineParser();
            var consoleVisualization = new ConsoleVisualization();

            if (parser.ParseArguments(args, options))
            {
                executionController.TryToRunNormalFlow(options, consoleVisualization);
            }
            else
            {
                Console.WriteLine(string.Format("FindTheBastard {0}", VersionNumberString));
                Console.WriteLine("Copyright (C) Domitienda.com, Hosting Valencia S.L.U");
                Console.WriteLine("Usage: -s\t server [optional]");
                Console.WriteLine("Usage: -u\t username [optional]");
                Console.WriteLine("Usage: -p\t password [optional]");
                Console.WriteLine(string.Format("Usage: -n\t number of results [optional, default:{0}]", DefaultNumberOfResults));
            }
        }