Exemplo n.º 1
0
        public IToolResults Run()
        {
            string cmd, output;

            cmd = "-w 10 -dd " + _options.Host;

            ProcessStartInfo si = new ProcessStartInfo();

            si.RedirectStandardOutput = true;
            si.UseShellExecute        = false;

            Process proc = new Process();

            proc.StartInfo           = si;
            proc.EnableRaisingEvents = false;
            proc.StartInfo.FileName  = _options.Path;
            proc.StartInfo.Arguments = cmd;
            proc.Start();

            output = proc.StandardOutput.ReadToEnd();

            proc.WaitForExit();

            OneSixtyOneToolResults results = new OneSixtyOneToolResults(output);

            return(results);
        }
Exemplo n.º 2
0
        private void ScanHost(NMapHost host, out List <IToolResults> toolResults)
        {
            IToolOptions _options;
            string       eventDescription;

            toolResults = new List <IToolResults> ();

            bool routed = false;
            int  tries  = 0;

            foreach (Port port in host.Ports)
            {
                if (port.Service == "http")
                {
                    _options = new NiktoToolOptions();

                    (_options as NiktoToolOptions).Host = host.IPAddressv4;
                    (_options as NiktoToolOptions).Port = port.PortNumber;
                    (_options as NiktoToolOptions).Path = this.Configuration ["niktoPath"];

                    Nikto nikto = new Nikto(_options);

                    eventDescription = "Running nikto (http) on host: " + (string.IsNullOrEmpty(host.Hostname) ? host.IPAddressv4 : host.Hostname);
                    CreateEvent(DateTime.Now, eventDescription, 1);
                    Console.WriteLine(eventDescription);

                    NiktoToolResults niktoResults = (nikto.Run() as NiktoToolResults);
                    niktoResults.HostIPAddressV4 = host.IPAddressv4;
                    niktoResults.HostPort        = port.PortNumber;
                    niktoResults.IsTCP           = true;
                    toolResults.Add(niktoResults);
                }
                else if (port.Service == "https")
                {
                    _options = new SSLScanToolOptions();

                    (_options as SSLScanToolOptions).Host = host.IPAddressv4;
                    (_options as SSLScanToolOptions).Port = port.PortNumber;
                    (_options as SSLScanToolOptions).Path = this.Configuration ["sslscanPath"];

                    SSLScan sslscan = new SSLScan(_options);


                    eventDescription = "Running sslscan (https) on host: " + (string.IsNullOrEmpty(host.Hostname) ? host.IPAddressv4 : host.Hostname);
                    CreateEvent(DateTime.Now, eventDescription, 1);
                    Console.WriteLine(eventDescription);

                    SSLScanToolResults sslResults = (sslscan.Run() as SSLScanToolResults);

                    sslResults.HostIPAddressV4 = host.IPAddressv4;
                    sslResults.HostPort        = port.PortNumber;
                    sslResults.IsTCP           = true;
                    toolResults.Add(sslResults);

                    _options = new NiktoToolOptions();

                    (_options as NiktoToolOptions).Host  = host.IPAddressv4;
                    (_options as NiktoToolOptions).Port  = port.PortNumber;
                    (_options as NiktoToolOptions).IsSSL = true;
                    (_options as NiktoToolOptions).Path  = this.Configuration ["niktoPath"];

                    Nikto nikto = new Nikto(_options);


                    eventDescription = "Running nikto (https) on host: " + (string.IsNullOrEmpty(host.Hostname) ? host.IPAddressv4 : host.Hostname);
                    CreateEvent(DateTime.Now, eventDescription, 1);
                    Console.WriteLine(eventDescription);

                    NiktoToolResults niktoResults = (nikto.Run() as NiktoToolResults);


                    niktoResults.HostIPAddressV4 = host.IPAddressv4;
                    niktoResults.HostPort        = port.PortNumber;
                    niktoResults.IsTCP           = true;
                    toolResults.Add(niktoResults);
                }
                else if (port.Service == "ssh")
                {
                    _options = new SSLScanToolOptions();

                    (_options as SSLScanToolOptions).Host = host.IPAddressv4;
                    (_options as SSLScanToolOptions).Port = port.PortNumber;
                    (_options as SSLScanToolOptions).Path = this.Configuration ["sslscanPath"];

                    SSLScan sslscan = new SSLScan(_options);

                    eventDescription = "Running sslscan (ssh) on host: " + (string.IsNullOrEmpty(host.Hostname) ? host.IPAddressv4 : host.Hostname);
                    CreateEvent(DateTime.Now, eventDescription, 1);
                    Console.WriteLine(eventDescription);

                    SSLScanToolResults sslResults = (sslscan.Run() as SSLScanToolResults);

                    sslResults.HostIPAddressV4 = host.IPAddressv4;
                    sslResults.HostPort        = port.PortNumber;
                    sslResults.IsTCP           = true;
                    toolResults.Add(sslResults);
                }
                else if (port.PortNumber == 445)                     //smb
                {
                    _options = new SMBClientToolOptions();

                    (_options as SMBClientToolOptions).Host          = host.IPAddressv4;
                    (_options as SMBClientToolOptions).RecurseShares = true;
                    (_options as SMBClientToolOptions).Path          = this.Configuration ["smbclientPath"];

                    SMBClient smb = new SMBClient(_options);

                    eventDescription = "Running smbclient (cifs) on host: " + (string.IsNullOrEmpty(host.Hostname) ? host.IPAddressv4 : host.Hostname);
                    CreateEvent(DateTime.Now, eventDescription, 1);
                    Console.WriteLine(eventDescription);

                    SMBClientToolResults smbResults = smb.Run() as SMBClientToolResults;

                    smbResults.ParentPort = port;

                    smbResults.HostIPAddressV4 = host.IPAddressv4;
                    smbResults.HostPort        = port.PortNumber;
                    smbResults.IsTCP           = true;
                    toolResults.Add(smbResults);

                    eventDescription = string.Format("Found {0} shares on host {1}", smbResults.ShareDetails.Count, host.Hostname);
                    CreateEvent(DateTime.Now, eventDescription, 1);
                    Console.WriteLine(eventDescription);
                }
                else if (port.Service == "snmp")
                {
                    _options = new OneSixtyOneToolOptions();

                    (_options as OneSixtyOneToolOptions).Host = host.IPAddressv4;
                    (_options as OneSixtyOneToolOptions).Path = this.Configuration ["onesixtyonePath"];

                    OneSixtyOne onesixone = new OneSixtyOne(_options);

                    eventDescription = "Running onesixtyone (snmp) on host: " + (string.IsNullOrEmpty(host.Hostname) ? host.IPAddressv4 : host.Hostname);
                    CreateEvent(DateTime.Now, eventDescription, 1);
                    Console.WriteLine(eventDescription);

                    OneSixtyOneToolResults osoResults = onesixone.Run() as OneSixtyOneToolResults;

                    osoResults.HostIPAddressV4 = host.IPAddressv4;
                    osoResults.HostPort        = port.PortNumber;
                    osoResults.IsTCP           = true;
                    toolResults.Add(osoResults);
                }
            }

            eventDescription = "Finished host " + (string.IsNullOrEmpty(host.Hostname) ? host.IPAddressv4 : host.Hostname);
            CreateEvent(DateTime.Now, eventDescription, 1);
            Console.WriteLine(eventDescription);
        }