Esempio n. 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter directory: ");
            var directory = Console.ReadLine();

            var signatureAnalyzer = new SignatureAnalyzer();
            var heuristicAnalyzer = new HeuristicAnalyzer();

            var signatureAnalisysRes = signatureAnalyzer.CheckDirectory(directory);

            Console.WriteLine("Signature analysis:");
            foreach (var response in signatureAnalisysRes.FileResults)
            {
                Console.WriteLine($"{response.FileName} {string.Join(' ', response.Viruses)}");
            }

            var hueristicAnalisysRes = heuristicAnalyzer.CheckDirectory(directory);

            Console.WriteLine("\nHueristic analysis:");
            foreach (var response in hueristicAnalisysRes.FileResults)
            {
                Console.WriteLine($"{response.FileName} {Math.Round(response.Infected, 2)} {Math.Round(response.Uninfected, 2)}");
            }
        }
Esempio n. 2
0
        private void analysis_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter      = "SpreadSheets (*.xlsx) | *.xlsx";
            dialog.Multiselect = false;

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Open(dialog.FileName, false);
                    workbookPart = spreadsheetDocument.WorkbookPart;
                }
                catch
                {
                    System.Windows.MessageBox.Show("The specification file is open in a other process");
                }

                SheetData sheetData = null;

                try
                {
                    Sheet sheet = workbookPart.Workbook.Sheets.ChildElements.Cast <Sheet>().First(x => x.Name == "Assembly Specification");
                    int   index = workbookPart.WorksheetParts.ToList().IndexOf(workbookPart.WorksheetParts.Last()) - workbookPart.Workbook.Sheets.ToList().IndexOf(sheet);
                    sheetData = workbookPart.WorksheetParts.ElementAt(index).Worksheet.Elements <SheetData>().First();
                }
                catch
                {
                    System.Windows.MessageBox.Show("Invalid specification file :\nCouldn't find the 'Assembly Specification' worksheet");
                }

                List <Row>  rows      = sheetData.Elements <Row>().ToList();
                List <Cell> headerRow = rows.First().Elements <Cell>().ToList();
                rows.RemoveAll(x => !x.Elements <Cell>().Any(y => !string.IsNullOrEmpty(TextInCell(y))));

                string assemblyName;

                if (headerRow.Any(x => TextInCell(x) == "Signed"))
                {
                    List <SignatureSpecification> sigspecs = new List <SignatureSpecification>();
                    int sigIndex = headerRow.IndexOf(headerRow.First(x => TextInCell(x) == "Signed"));

                    foreach (Row r in rows)
                    {
                        List <Cell> row = r.Elements <Cell>().ToList();
                        assemblyName = TextInCell(row.ElementAt(0));
                        sigspecs.Add(new SignatureSpecification(assemblyName, TextInCell(row.ElementAt(sigIndex)) == "x"));
                    }

                    SignatureAnalyzer sigAnalyzer = new SignatureAnalyzer();
                    sigAnalyzer.Analyze(Model, sigspecs);
                }

                if (headerRow.Any(x => TextInCell(x) == "Obfuscated"))
                {
                    List <ObfuscationSpecification> obfuscationspecs = new List <ObfuscationSpecification>();
                    int obIndex = headerRow.IndexOf(headerRow.First(x => TextInCell(x) == "Obfuscated"));

                    foreach (Row r in rows)
                    {
                        List <Cell> row = r.Elements <Cell>().ToList();
                        assemblyName = TextInCell(row.ElementAt(0));
                        obfuscationspecs.Add(new ObfuscationSpecification(assemblyName, TextInCell(row.ElementAt(obIndex)) == "x"));
                    }

                    ObfuscationAnalyzer obfuscationAnalyzer = new ObfuscationAnalyzer();
                    obfuscationAnalyzer.Analyze(Model, obfuscationspecs);
                }

                Model.SoftwareComponents.Where(x => x.Name != "System Assemblies").ToList().ForEach(x => ModelCommonDataOrganizer.UpdateGroups(Model, x));
                UpdateTreeView();
                UpdateErrorNodes(GraphViewer.Graph);
                analysis.Visibility = Visibility.Hidden;
            }
        }