Exemplo n.º 1
0
            bool Add(IObfuscatedFile file, bool skipUnknownObfuscator, bool isFromPossibleFiles)
            {
                var key = Utils.GetFullPath(file.Filename);

                if (allFiles.ContainsKey(key))
                {
                    Logger.Instance.Log(false, null, LoggerEvent.Warning, "Ingoring duplicate file: {0}", file.Filename);
                    return(false);
                }
                allFiles[key] = true;

                int oldIndentLevel = Logger.Instance.IndentLevel;

                try {
                    file.DeobfuscatorContext = options.DeobfuscatorContext;
                    file.Load(options.CreateDeobfuscators());
                }
                catch (NotSupportedException) {
                    return(false);                      // Eg. unsupported architecture
                }
                catch (BadImageFormatException) {
                    if (isFromPossibleFiles)
                    {
                        Logger.Instance.Log(false, null, LoggerEvent.Warning, "The file isn't a .NET PE file: {0}", file.Filename);
                    }
                    return(false);                      // Not a .NET file
                }
                catch (EndOfStreamException) {
                    return(false);
                }
                catch (IOException) {
                    if (isFromPossibleFiles)
                    {
                        Logger.Instance.Log(false, null, LoggerEvent.Warning, "The file isn't a .NET PE file: {0}", file.Filename);
                    }
                    return(false);                      // Not a .NET file
                }
                catch (Exception ex) {
                    Logger.Instance.Log(false, null, LoggerEvent.Warning, "Could not load file ({0}): {1}", ex.GetType(), file.Filename);
                    return(false);
                }
                finally {
                    Logger.Instance.IndentLevel = oldIndentLevel;
                }

                var deob = file.Deobfuscator;

                if (skipUnknownObfuscator && deob.Type == "un")
                {
                    Logger.v("Skipping unknown obfuscator: {0}", file.Filename);
                    RemoveModule(file.ModuleDefMD);
                    return(false);
                }
                else
                {
                    Logger.n("Detected {0} ({1})", deob.Name, file.Filename);
                    if (options.CreateDestinationDir)
                    {
                        CreateDirectories(Path.GetDirectoryName(file.NewFilename));
                    }
                    return(true);
                }
            }
			bool Add(IObfuscatedFile file, bool skipUnknownObfuscator, bool isFromPossibleFiles) {
				var key = Utils.GetFullPath(file.Filename);
				if (allFiles.ContainsKey(key)) {
					Logger.Instance.Log(false, null, LoggerEvent.Warning, "Ingoring duplicate file: {0}", file.Filename);
					return false;
				}
				allFiles[key] = true;

				int oldIndentLevel = Logger.Instance.IndentLevel;
				try {
					file.DeobfuscatorContext = options.DeobfuscatorContext;
					file.Load(options.CreateDeobfuscators());
				}
				catch (NotSupportedException) {
					return false;	// Eg. unsupported architecture
				}
				catch (BadImageFormatException) {
					if (isFromPossibleFiles)
						Logger.Instance.Log(false, null, LoggerEvent.Warning, "The file isn't a .NET PE file: {0}", file.Filename);
					return false;	// Not a .NET file
				}
				catch (EndOfStreamException) {
					return false;
				}
				catch (IOException) {
					if (isFromPossibleFiles)
						Logger.Instance.Log(false, null, LoggerEvent.Warning, "The file isn't a .NET PE file: {0}", file.Filename);
					return false;	// Not a .NET file
				}
				catch (Exception ex) {
					Logger.Instance.Log(false, null, LoggerEvent.Warning, "Could not load file ({0}): {1}", ex.GetType(), file.Filename);
					return false;
				}
				finally {
					Logger.Instance.IndentLevel = oldIndentLevel;
				}

				var deob = file.Deobfuscator;
				if (skipUnknownObfuscator && deob.Type == "un") {
					Logger.v("Skipping unknown obfuscator: {0}", file.Filename);
					RemoveModule(file.ModuleDefMD);
					return false;
				}
				else {
					Logger.n("Detected {0} ({1})", deob.Name, file.Filename);
					if (options.CreateDestinationDir)
						CreateDirectories(Path.GetDirectoryName(file.NewFilename));
					return true;
				}
			}