예제 #1
0
        // Core.Property.module =
        public ObfuscationProcess(ModuleDefMD module)
        {
            _module  = module;
            CH       = new NoisetteCore.Helper.ConsoleHelper();
            CH.begin = DateTime.Now;
            CH.Debug("Instancing Tuples and ModuleWriters");
            SetObfuscateMethod = new Dictionary <Tuple <MethodDef>, bool>();
            Core.Property.opts = new ModuleWriterOptions(_module);
            CH.Debug("Analyzing module...");
            ObfuscationAnalyzer AZ = new ObfuscationAnalyzer(_module);

            AZ.PerformAnalyze();
        }
예제 #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;
            }
        }