コード例 #1
0
        public static FidoReturnValues SQLFidoReturnValues(FidoReturnValues lFidoReturnValues, string sSrcIP, string sHostname)
        {
            //go to our sysmgmt data sources in the XML to get SQL queries and strings
            var sSQLSource    = SQL_Queries.GetSqlSources();
            var sLandeskSrcIP = String.Empty;

            foreach (var source in sSQLSource)
            {
                // ReSharper disable once RedundantAssignment
                var    lQuery       = new List <string>();
                var    lHostInfo    = new List <string>();
                string sNewSource   = null;
                var    sSplitSource = source.Split('-');
                sNewSource = sSplitSource.Length > 1 ? sSplitSource[0] : source;

                switch (sNewSource)
                {
                case "landesk":

                    sLandeskSrcIP = SourceLandesk(ref lFidoReturnValues, sSrcIP, sHostname, sNewSource, sLandeskSrcIP, source, lHostInfo);

                    continue;

                case "jamf":

                    //if nmap or ssh is null use IP
                    SetHostInfo(sHostname, sSrcIP, source, lHostInfo);

                    //if return has values assign to lFidoReturnValues
                    if (lHostInfo[0] != "unknown")
                    {
                        if ((lFidoReturnValues.Landesk != null) && !String.IsNullOrEmpty(lFidoReturnValues.Landesk.Hostname))
                        {
                            var LandeskDateTime = Convert.ToDateTime(lFidoReturnValues.Landesk.LastUpdate);
                            var JamfDateTime    = FromEpochTime(lHostInfo[3]);

                            if (LandeskDateTime.ToUniversalTime() > JamfDateTime)
                            {
                                continue;
                            }
                        }
                        lFidoReturnValues.Hostname = lHostInfo[1];
                        lFidoReturnValues.Username = lHostInfo[11];
                        if (lFidoReturnValues.Jamf == null)
                        {
                            lFidoReturnValues.Jamf = new JamfReturnValues();
                        }

                        lFidoReturnValues.Jamf = Jamf2FidoValues.Convert(lFidoReturnValues, lHostInfo);
                    }

                    continue;

                default:
                    continue;
                }
            }
            return(lFidoReturnValues);
        }
コード例 #2
0
        public static FidoReturnValues SQLFidoReturnValues(FidoReturnValues lFidoReturnValues, string sSrcIP, string sHostname)
        {
            //go to our sysmgmt data sources in the XML to get SQL queries and strings
            var sSQLSource    = SQL_Queries.GetSqlSources();
            var sLandeskSrcIP = String.Empty;

            foreach (var source in sSQLSource)
            {
                // ReSharper disable once RedundantAssignment
                var    lQuery       = new List <string>();
                var    lHostInfo    = new List <string>();
                string sNewSource   = null;
                var    sSplitSource = source.Split('-');
                sNewSource = sSplitSource.Length > 1 ? sSplitSource[0] : source;

                switch (sNewSource)
                {
                case "landesk":

                    //this is a hack needed to reformat the srcip if Landesk is used
                    //because landesk stores IPs in 000.000.000.000 format Where each
                    //octet needs 3 numbers.
                    if ((sNewSource.ToLower() == "landesk") && (!String.IsNullOrEmpty(sSrcIP)))
                    {
                        sLandeskSrcIP = SysmgmtLandesk.FormatIP(sSrcIP);
                    }


                    //if nmap or ssh is null
                    if (String.IsNullOrEmpty(sHostname))
                    {
                        lQuery = SQL_Queries.GetSqlConfigs(source);
                        lHostInfo.AddRange(SQL_Queries.RunMSsqlQuery(lQuery, sLandeskSrcIP, null));
                    }
                    else
                    {
                        lQuery = SQL_Queries.GetSqlConfigs(source);
                        lHostInfo.AddRange(SQL_Queries.RunMSsqlQuery(lQuery, null, sHostname));
                    }

                    //if return has values assign to lFidoReturnValues
                    if (lHostInfo[0] != "unknown")
                    {
                        lFidoReturnValues.Hostname = lHostInfo[0];
                        if (lFidoReturnValues.Landesk == null)
                        {
                            lFidoReturnValues.Landesk = new LandeskReturnValues();
                        }

                        //format return from Landesk to Fido object
                        lFidoReturnValues = Landesk2FidoValues.LandesklFidoValues(lFidoReturnValues, lHostInfo);

                        //query Landesk to get more system information
                        lFidoReturnValues = SysmgmtLandesk.GetHostOsInfo(lFidoReturnValues, lQuery[0]);

                        //query to get total # of vulns for the machine
                        lFidoReturnValues.Landesk.Patches = SysmgmtLandesk.GetVulns(lFidoReturnValues.Hostname, lQuery[0]);

                        //query to get if Bit9 was installed\
                        if (lFidoReturnValues.Bit9 == null)
                        {
                            lFidoReturnValues.Bit9 = new Bit9ReturnValues();
                        }
                        lFidoReturnValues.Bit9.IsBit9 = IsBit9Installed();
                        lFidoReturnValues             = SysmgmtLandesk.GetBit9Status(lFidoReturnValues, lQuery[0]);
                        if (lFidoReturnValues.Landesk.Bit9Running == null)
                        {
                            lFidoReturnValues.Landesk.Bit9Running = String.Empty;
                        }
                        if (lFidoReturnValues.Landesk.Bit9Version == null)
                        {
                            lFidoReturnValues.Landesk.Bit9Version = String.Empty;
                        }
                    }

                    continue;

                case "jamf":

                    //if nmap or ssh is null use IP
                    if (String.IsNullOrEmpty(sHostname))
                    {
                        lQuery = SQL_Queries.GetSqlConfigs(source);
                        lHostInfo.AddRange(SQL_Queries.RunMysqlQuery(lQuery, sSrcIP, null));
                    }
                    //if hostname is not null use IP instead
                    else
                    {
                        lQuery = SQL_Queries.GetSqlConfigs(source);
                        lHostInfo.AddRange(SQL_Queries.RunMysqlQuery(lQuery, null, sHostname));
                    }

                    //if return has values assign to lFidoReturnValues
                    if (lHostInfo[0] != "unknown")
                    {
                        if ((lFidoReturnValues.Landesk != null) && !String.IsNullOrEmpty(lFidoReturnValues.Landesk.Hostname))
                        {
                            var LandeskDateTime = Convert.ToDateTime(lFidoReturnValues.Landesk.LastUpdate);
                            var JamfDateTime    = FromEpochTime(lHostInfo[3]);

                            if (LandeskDateTime.ToUniversalTime() > JamfDateTime)
                            {
                                continue;
                            }
                        }
                        lFidoReturnValues.Hostname = lHostInfo[1];
                        lFidoReturnValues.Username = lHostInfo[11];
                        if (lFidoReturnValues.Jamf == null)
                        {
                            lFidoReturnValues.Jamf = new JamfReturnValues();
                        }

                        lFidoReturnValues.Jamf = Jamf2FidoValues.Convert(lFidoReturnValues, lHostInfo);
                    }

                    continue;

                default:
                    continue;
                }
            }
            return(lFidoReturnValues);
        }