Esempio n. 1
0
        static int RunReporterVerb(ReporterOptions options)
        {
            if (options.ScanType.ToUpper() == "SMB")
            {
                Dictionary <string, SMBHost> hosts;
                SetCommonOptions(options);

                if (File.Exists(options.InputFile))
                {
                    hosts = SMBSharesMapperSerializer.DeserializeHosts(options.InputFile);
                    if (hosts == null)
                    {
                        return(-1);
                    }

                    if (options.OutReport.Length > 0)
                    {
                        if (File.Exists(options.SIDFile))
                        {
                            ReportGenerator.XLSXReport.LoadSIDResolutionFile(options.SIDFile);
                        }
                        ReportGenerator.XLSXReport.GenerateSMBHostsReport(hosts, options.OutReport);
                        ReportGenerator.XLSXReport.SIDCahe.Clear();
                    }
                }
            }
            return(0);
        }
Esempio n. 2
0
        static int RunRescanSMBVerb(RescanSMBOptions options)
        {
            Dictionary <string, SMBHost> hosts;

            SetCommonOptions(options);
            SetScanCommonOptions(options);
            SetMTOptions(options);
            SetDirScanMTOptions(options);

            Config.ScanForNewShares = options.ScanForNewShares;
            Config.ScanForNewSharesRecusiveLevel      = options.RecursiveLevel;
            Config.ScanForNewSharesTryResolveHostName = options.ResolveHostname;

            if (File.Exists(options.InputFile))
            {
                hosts = SMBSharesMapperSerializer.DeserializeHosts(options.InputFile);
                if (hosts == null)
                {
                    return(-1);
                }

                if (options.AppendHosts != null)
                {
                    SharesScanner.AppendHosts(hosts, options.AppendHosts.Split(','), Config.ScanForNewSharesTryResolveHostName);
                }

                if (options.AppendHostsFile != null)
                {
                    SharesScanner.AppendHosts(hosts, options.AppendHostsFile, Config.ScanForNewSharesTryResolveHostName);
                }

                if (options.MaxThreads > 1)
                {
                    SharesScanner.MTReScanHosts(hosts);
                }
                else
                {
                    SharesScanner.ReScanHosts(hosts);
                }

                SMBSharesMapperSerializer.SerializeHosts(hosts, options.OutData);

                if (options.OutReport.Length > 0)
                {
                    if (File.Exists(options.SIDFileIn))
                    {
                        ReportGenerator.XLSXReport.LoadSIDResolutionFile(options.SIDFileIn);
                    }
                    ReportGenerator.XLSXReport.GenerateSMBHostsReport(hosts, options.OutReport);
                    ReportGenerator.XLSXReport.SIDCahe.Clear();
                }
            }

            return(0);
        }