From e920bfc69ce283de0e8a360554fa9dd62a75ede1 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 15 Mar 2023 15:53:24 -0400 Subject: [PATCH] Executable is not inherently extractable --- BinaryObjectScanner.FileType/Executable.cs | 21 +-------------------- BurnOutSharp/Factory.cs | 1 - BurnOutSharp/Scanner.cs | 17 +++-------------- 3 files changed, 4 insertions(+), 35 deletions(-) diff --git a/BinaryObjectScanner.FileType/Executable.cs b/BinaryObjectScanner.FileType/Executable.cs index b4b52b50..133ea9c0 100644 --- a/BinaryObjectScanner.FileType/Executable.cs +++ b/BinaryObjectScanner.FileType/Executable.cs @@ -19,7 +19,7 @@ namespace BinaryObjectScanner.FileType /// Due to the complexity of executables, all extraction handling /// another class that is used by the scanner /// - public class Executable : IDetectable, IExtractable + public class Executable : IDetectable { #region Properties @@ -167,25 +167,6 @@ namespace BinaryObjectScanner.FileType return string.Join(";", protections); } - /// - public string Extract(string file, bool includeDebug) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Extract(fs, file, includeDebug); - } - } - - /// - /// This implementation should never be invoked - public string Extract(Stream stream, string file, bool includeDebug) - { - throw new InvalidOperationException(); - } - #region Check Runners /// diff --git a/BurnOutSharp/Factory.cs b/BurnOutSharp/Factory.cs index 964d1704..ca42142c 100644 --- a/BurnOutSharp/Factory.cs +++ b/BurnOutSharp/Factory.cs @@ -38,7 +38,6 @@ namespace BurnOutSharp case SupportedFileType.BZip2: return new BinaryObjectScanner.FileType.BZip2(); case SupportedFileType.CFB: return new BinaryObjectScanner.FileType.CFB(); //case SupportedFileType.CIA: return new BinaryObjectScanner.FileType.CIA(); - case SupportedFileType.Executable: return new BinaryObjectScanner.FileType.Executable(); case SupportedFileType.GCF: return new BinaryObjectScanner.FileType.GCF(); case SupportedFileType.GZIP: return new BinaryObjectScanner.FileType.GZIP(); case SupportedFileType.InstallShieldArchiveV3: return new BinaryObjectScanner.FileType.InstallShieldArchiveV3(); diff --git a/BurnOutSharp/Scanner.cs b/BurnOutSharp/Scanner.cs index 08c2e137..3649cf21 100644 --- a/BurnOutSharp/Scanner.cs +++ b/BurnOutSharp/Scanner.cs @@ -298,16 +298,9 @@ namespace BurnOutSharp if (detectable != null && ScanContents) { // If we have an executable, it needs to bypass normal handling - // TODO: Write custom executable handling if (detectable is Executable executable) { executable.IncludePackers = ScanPackers; - - // TODO: Enable this after IExtractable is properly implemented for Executable - //var subProtections = Handler.HandleDetectable(executable, fileName, stream, IncludeDebug); - //if (subProtections != null) - // AppendToDictionary(protections, fileName, subProtections); - var subProtections = ProcessExecutable(executable, fileName, stream); if (subProtections != null) AppendToDictionary(protections, subProtections); @@ -347,13 +340,9 @@ namespace BurnOutSharp // If we're scanning archives if (extractable != null && ScanArchives) { - // We only want to process non-executables - if (!(extractable is Executable)) - { - var subProtections = Handler.HandleExtractable(extractable, fileName, stream, this); - if (subProtections != null) - AppendToDictionary(protections, subProtections); - } + var subProtections = Handler.HandleExtractable(extractable, fileName, stream, this); + if (subProtections != null) + AppendToDictionary(protections, subProtections); } #endregion