Beispiel #1
0
        public override void readTablesFromWord(string wordFile)
        {
            bool flag = true;

            using (DocX document = DocX.Load(wordFile))
            {
                if (document.Tables.Count > 0)
                {
                    foreach (Novacode.Table table in document.Tables)
                    {
                        if ((foundstone.myTable.containsAffectedSoftware(table.Rows[0])))
                        {
                            extractTableContent(table);
                        }
                        else
                        {
                            if (foundstone.myTable.tableContainsCVEs(table.Rows[0]))
                            {
                                if (flag)   //only the first time, because there migth be more than two tables containing CVEs
                                {
                                    writePatchIni();
                                    flag = false;
                                }
                                foundstone.inspectVulneravilityTable(table);
                            }
                        }
                    }
                }
            }
            if (flag)// we could not find a cveTable
            {
                writePatchIni();
            }
        }
Beispiel #2
0
        public override void readTablesFromWeb(HtmlDocument page)
        {
            string cvss = "";
            string content;
            bool   firstCVETable = true;

            if (page.DocumentNode != null)
            {
                if (page.DocumentNode.SelectNodes("//table[@class='dataTable']") != null)
                {
                    foreach (HtmlNode table in page.DocumentNode.SelectNodes("//table[@class='dataTable']"))
                    {
                        if (table.SelectNodes("thead") != null)
                        {
                            HtmlNode head = table.SelectSingleNode("thead");
                            if (head.SelectNodes("tr") != null)
                            {
                                HtmlNode           headRow  = head.SelectSingleNode("tr");
                                HtmlNodeCollection headCols = headRow.SelectNodes("th");
                                if ((headCols.Count == 4) || (headCols.Count == 5) && (foundstone.myTable.isValidHeader(headCols)))//This table have 4 or 5 colums, so it is a valid table
                                {
                                    foundstone.myTable.setHeaderSupporteTrue();
                                    foundstone.myTable.setSystemOrComponent(headCols[0].InnerText);
                                    if (table.SelectNodes("tbody") != null)
                                    {
                                        foreach (HtmlNode body in table.SelectNodes("tbody"))
                                        {
                                            if (body.SelectNodes("tr") != null)
                                            {
                                                HtmlNode bodyRows = body.SelectSingleNode("tr");
                                                if ((bodyRows.SelectNodes("th") != null))
                                                {
                                                    HtmlNode bodyHead = bodyRows.SelectSingleNode("th");  // we are assuming that there is gonna be only on <th> tag
                                                    content = bodyHead.InnerText;
                                                    foundstone.myTable.setSupportedHeader(content);
                                                }
                                                else
                                                {
                                                    foreach (HtmlNode row in body.SelectNodes("tr"))
                                                    {
                                                        if (row.SelectNodes("td") != null)
                                                        {
                                                            HtmlNodeCollection cols = row.SelectNodes("td");
                                                            if (cols.Count == 4)   // This are the only rows that we are interested in
                                                            {
                                                                processRowFourCols(cols);
                                                            }

                                                            if (cols.Count == 5)
                                                            {
                                                                processRowFiveCols(cols);
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                if (table.SelectNodes("caption") != null)
                                {
                                    HtmlNode caption = table.SelectSingleNode("caption");
                                    if (foundstone.myTable.isCVEHeader(caption.InnerText))
                                    {
                                        if (firstCVETable)
                                        {
                                            writePatchOnly();
                                            firstCVETable = false;
                                        }
                                        foundstone.inspectVulneravilityTable(table);
                                        //cvss += foundstone.myTable.getCVS(headCols);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                foundstone.set_Cvss(cvss);
            }
            if (firstCVETable)//We could not found a CVE Table
            {
                writePatchOnly();
            }
        }