public PersistentSMBClientResults(SMBClientToolResults results)
 {
     this.FullOutput = results.FullOutput;
     this.ParentPort = new PersistentPort(results.ParentPort);
     this.ShareDetails = results.ShareDetails;
     this.HostIPAddressV4 = results.HostIPAddressV4;
     this.HostPort = results.HostPort;
     this.IsTCP = results.IsTCP;
 }
Beispiel #2
0
        public IToolResults Run()
        {
            string cmd, output;

            cmd = "-g -L " + _options.Host + " -U Administrator -N";

            ProcessStartInfo si = new ProcessStartInfo();

            si.RedirectStandardOutput = true;
            si.UseShellExecute        = false;
            si.RedirectStandardError  = true;            //smbclient sends some good info to stderr

            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();
            string errout = proc.StandardError.ReadToEnd();

            //parse output for shares

            proc.WaitForExit();

            SMBClientToolResults results = new SMBClientToolResults(errout + "\n\n\n" + output);


            if (_options.RecurseShares)
            {
                results.RecurseShares(_options.Host);
            }

            return(results);
        }
Beispiel #3
0
        public IToolResults Run()
        {
            string cmd, output;

            cmd = "-g -L " + _options.Host + " -U Administrator -N";

            ProcessStartInfo si = new ProcessStartInfo();
            si.RedirectStandardOutput = true;
            si.UseShellExecute = false;
            si.RedirectStandardError = true; //smbclient sends some good info to stderr

            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();
            string errout = proc.StandardError.ReadToEnd();
            //parse output for shares

            proc.WaitForExit();

            SMBClientToolResults results = new SMBClientToolResults(errout + "\n\n\n" + output);

            if (_options.RecurseShares)
                results.RecurseShares(_options.Host);

            return results;
        }
Beispiel #4
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);
        }