From c43353d126608d38b1acc6e559148e52cfc7a712 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Mon, 13 Mar 2023 16:06:45 -0400 Subject: [PATCH] Move most detectables to new interface --- .../AACSMediaKeyBlock.cs | 51 +++++++++++++ BinaryObjectScanner.FileType/BDPlusSVM.cs | 49 ++++++++++++ .../BinaryObjectScanner.FileType.csproj | 1 + BinaryObjectScanner.FileType/LDSCRYPT.cs | 44 +++++++++++ BinaryObjectScanner.FileType/PLJ.cs | 44 +++++++++++ .../SFFS.cs | 74 +++++++++---------- BurnOutSharp/FileType/AACSMediaKeyBlock.cs | 57 -------------- BurnOutSharp/FileType/BDPlusSVM.cs | 55 -------------- BurnOutSharp/FileType/LDSCRYPT.cs | 49 ------------ BurnOutSharp/FileType/PLJ.cs | 49 ------------ BurnOutSharp/Scanner.cs | 42 ++++++++--- BurnOutSharp/Tools/FileTypeTools.cs | 25 +++---- Coding Guide.md | 4 +- Developer Guide.md | 3 +- 14 files changed, 271 insertions(+), 276 deletions(-) create mode 100644 BinaryObjectScanner.FileType/AACSMediaKeyBlock.cs create mode 100644 BinaryObjectScanner.FileType/BDPlusSVM.cs create mode 100644 BinaryObjectScanner.FileType/LDSCRYPT.cs create mode 100644 BinaryObjectScanner.FileType/PLJ.cs rename {BurnOutSharp/FileType => BinaryObjectScanner.FileType}/SFFS.cs (58%) delete mode 100644 BurnOutSharp/FileType/AACSMediaKeyBlock.cs delete mode 100644 BurnOutSharp/FileType/BDPlusSVM.cs delete mode 100644 BurnOutSharp/FileType/LDSCRYPT.cs delete mode 100644 BurnOutSharp/FileType/PLJ.cs diff --git a/BinaryObjectScanner.FileType/AACSMediaKeyBlock.cs b/BinaryObjectScanner.FileType/AACSMediaKeyBlock.cs new file mode 100644 index 00000000..6f780207 --- /dev/null +++ b/BinaryObjectScanner.FileType/AACSMediaKeyBlock.cs @@ -0,0 +1,51 @@ +using System; +using System.IO; +using System.Linq; +using BinaryObjectScanner.Interfaces; + +namespace BinaryObjectScanner.FileType +{ + /// + /// AACS media key block + /// + public class AACSMediaKeyBlock : IDetectable + { + /// + public string Detect(string file, bool includeDebug) + { + if (!File.Exists(file)) + return null; + + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) + { + return Detect(fs, file, includeDebug); + } + } + + /// + public string Detect(Stream stream, string file, bool includeDebug) + { + // If the MKB file itself fails + try + { + // Create the wrapper + Wrappers.AACSMediaKeyBlock mkb = Wrappers.AACSMediaKeyBlock.Create(stream); + if (mkb == null) + return null; + + // Derive the version, if possible + var typeAndVersion = mkb.Records.FirstOrDefault(r => r.RecordType == Models.AACS.RecordType.TypeAndVersion); + if (typeAndVersion == null) + return "AACS (Unknown Version)"; + else + return $"AACS {(typeAndVersion as Models.AACS.TypeAndVersionRecord).VersionNumber}"; + } + catch (Exception ex) + { + if (includeDebug) Console.WriteLine(ex); + } + + return null; + } + } +} diff --git a/BinaryObjectScanner.FileType/BDPlusSVM.cs b/BinaryObjectScanner.FileType/BDPlusSVM.cs new file mode 100644 index 00000000..71db4540 --- /dev/null +++ b/BinaryObjectScanner.FileType/BDPlusSVM.cs @@ -0,0 +1,49 @@ +using System; +using System.IO; +using BinaryObjectScanner.Interfaces; + +namespace BinaryObjectScanner.FileType +{ + /// + /// BD+ SVM + /// + public class BDPlusSVM : IDetectable + { + /// + public string Detect(string file, bool includeDebug) + { + if (!File.Exists(file)) + return null; + + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) + { + return Detect(fs, file, includeDebug); + } + } + + /// + public string Detect(Stream stream, string file, bool includeDebug) + { + // If the BD+ file itself fails + try + { + // Create the wrapper + Wrappers.BDPlusSVM svm = Wrappers.BDPlusSVM.Create(stream); + if (svm == null) + return null; + + // Format the date + string date = $"{svm.Year:0000}/{svm.Month:00}/{svm.Day:00}"; + + // Return the formatted value + return $"BD+ {date}"; + } + catch (Exception ex) + { + if (includeDebug) Console.WriteLine(ex); + } + + return null; + } + } +} diff --git a/BinaryObjectScanner.FileType/BinaryObjectScanner.FileType.csproj b/BinaryObjectScanner.FileType/BinaryObjectScanner.FileType.csproj index e8fa6f94..a326126c 100644 --- a/BinaryObjectScanner.FileType/BinaryObjectScanner.FileType.csproj +++ b/BinaryObjectScanner.FileType/BinaryObjectScanner.FileType.csproj @@ -22,6 +22,7 @@ + diff --git a/BinaryObjectScanner.FileType/LDSCRYPT.cs b/BinaryObjectScanner.FileType/LDSCRYPT.cs new file mode 100644 index 00000000..937f936a --- /dev/null +++ b/BinaryObjectScanner.FileType/LDSCRYPT.cs @@ -0,0 +1,44 @@ +using System; +using System.IO; +using BinaryObjectScanner.Interfaces; +using BinaryObjectScanner.Matching; + +namespace BinaryObjectScanner.FileType +{ + /// + /// Link Data Security encrypted file + /// + public class LDSCRYPT : IDetectable + { + /// + public string Detect(string file, bool includeDebug) + { + if (!File.Exists(file)) + return null; + + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) + { + return Detect(fs, file, includeDebug); + } + } + + /// + public string Detect(Stream stream, string file, bool includeDebug) + { + try + { + byte[] magic = new byte[16]; + stream.Read(magic, 0, 16); + + if (magic.StartsWith(new byte?[] { 0x4C, 0x44, 0x53, 0x43, 0x52, 0x59, 0x50, 0x54 })) + return "Link Data Security encrypted file"; + } + catch (Exception ex) + { + if (includeDebug) Console.WriteLine(ex); + } + + return null; + } + } +} diff --git a/BinaryObjectScanner.FileType/PLJ.cs b/BinaryObjectScanner.FileType/PLJ.cs new file mode 100644 index 00000000..c373683d --- /dev/null +++ b/BinaryObjectScanner.FileType/PLJ.cs @@ -0,0 +1,44 @@ +using System; +using System.IO; +using BinaryObjectScanner.Interfaces; +using BinaryObjectScanner.Matching; + +namespace BinaryObjectScanner.FileType +{ + /// + /// PlayJ audio file + /// + public class PLJ : IDetectable + { + /// + public string Detect(string file, bool includeDebug) + { + if (!File.Exists(file)) + return null; + + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) + { + return Detect(fs, file, includeDebug); + } + } + + /// + public string Detect(Stream stream, string file, bool includeDebug) + { + try + { + byte[] magic = new byte[16]; + stream.Read(magic, 0, 16); + + if (magic.StartsWith(new byte?[] { 0xFF, 0x9D, 0x53, 0x4B })) + return "PlayJ Audio File"; + } + catch (Exception ex) + { + if (includeDebug) Console.WriteLine(ex); + } + + return null; + } + } +} diff --git a/BurnOutSharp/FileType/SFFS.cs b/BinaryObjectScanner.FileType/SFFS.cs similarity index 58% rename from BurnOutSharp/FileType/SFFS.cs rename to BinaryObjectScanner.FileType/SFFS.cs index 66e60148..de3f06fa 100644 --- a/BurnOutSharp/FileType/SFFS.cs +++ b/BinaryObjectScanner.FileType/SFFS.cs @@ -1,18 +1,47 @@ using System; -using System.Collections.Concurrent; using System.IO; -using BurnOutSharp.Interfaces; using BinaryObjectScanner.Interfaces; -using static BinaryObjectScanner.Utilities.Dictionary; +using BinaryObjectScanner.Matching; -namespace BurnOutSharp.FileType +namespace BinaryObjectScanner.FileType { /// /// StarForce Filesystem file /// /// - public class SFFS : IExtractable, IScannable + public class SFFS : IExtractable, IDetectable { + /// + public string Detect(string file, bool includeDebug) + { + if (!File.Exists(file)) + return null; + + using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) + { + return Detect(fs, file, includeDebug); + } + } + + /// + public string Detect(Stream stream, string file, bool includeDebug) + { + try + { + byte[] magic = new byte[16]; + stream.Read(magic, 0, 16); + + if (magic.StartsWith(new byte?[] { 0x53, 0x46, 0x46, 0x53 })) + return "StarForce Filesystem Container"; + } + catch (Exception ex) + { + if (includeDebug) Console.WriteLine(ex); + } + + return null; + } + /// public string Extract(string file, bool includeDebug) { @@ -30,40 +59,5 @@ namespace BurnOutSharp.FileType { return null; } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - var protections = new ConcurrentDictionary>(); - try - { - byte[] magic = new byte[16]; - stream.Read(magic, 0, 16); - - if (Tools.FileTypeTools.GetFileType(magic) == SupportedFileType.SFFS) - { - AppendToDictionary(protections, file, "StarForce Filesystem Container"); - return protections; - } - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } } } diff --git a/BurnOutSharp/FileType/AACSMediaKeyBlock.cs b/BurnOutSharp/FileType/AACSMediaKeyBlock.cs deleted file mode 100644 index 644836d1..00000000 --- a/BurnOutSharp/FileType/AACSMediaKeyBlock.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.IO; -using System.Linq; -using BurnOutSharp.Interfaces; - -namespace BurnOutSharp.FileType -{ - /// - /// AACS media key block - /// - public class AACSMediaKeyBlock : IScannable - { - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the MKB file itself fails - try - { - // Create the wrapper - BinaryObjectScanner.Wrappers.AACSMediaKeyBlock mkb = BinaryObjectScanner.Wrappers.AACSMediaKeyBlock.Create(stream); - if (mkb == null) - return null; - - // Setup the output - var protections = new ConcurrentDictionary>(); - protections[file] = new ConcurrentQueue(); - - var typeAndVersion = mkb.Records.FirstOrDefault(r => r.RecordType == BinaryObjectScanner.Models.AACS.RecordType.TypeAndVersion); - if (typeAndVersion == null) - protections[file].Enqueue("AACS (Unknown Version)"); - else - protections[file].Enqueue($"AACS {(typeAndVersion as BinaryObjectScanner.Models.AACS.TypeAndVersionRecord).VersionNumber}"); - - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } - } -} diff --git a/BurnOutSharp/FileType/BDPlusSVM.cs b/BurnOutSharp/FileType/BDPlusSVM.cs deleted file mode 100644 index 7b557bb5..00000000 --- a/BurnOutSharp/FileType/BDPlusSVM.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.IO; -using BurnOutSharp.Interfaces; - -namespace BurnOutSharp.FileType -{ - /// - /// BD+ SVM - /// - public class BDPlusSVM : IScannable - { - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - // If the BD+ file itself fails - try - { - // Create the wrapper - BinaryObjectScanner.Wrappers.BDPlusSVM svm = BinaryObjectScanner.Wrappers.BDPlusSVM.Create(stream); - if (svm == null) - return null; - - // Setup the output - var protections = new ConcurrentDictionary>(); - protections[file] = new ConcurrentQueue(); - - // Format the date - string date = $"{svm.Year:0000}/{svm.Month:00}/{svm.Day:00}"; - - // Add and return the protection - protections[file].Enqueue($"BD+ {date}"); - return protections; - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } - } -} diff --git a/BurnOutSharp/FileType/LDSCRYPT.cs b/BurnOutSharp/FileType/LDSCRYPT.cs deleted file mode 100644 index 7215f846..00000000 --- a/BurnOutSharp/FileType/LDSCRYPT.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.IO; -using BurnOutSharp.Interfaces; -using static BinaryObjectScanner.Utilities.Dictionary; - -namespace BurnOutSharp.FileType -{ - /// - /// Link Data Security encrypted file - /// - public class LDSCRYPT : IScannable - { - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - var protections = new ConcurrentDictionary>(); - try - { - byte[] magic = new byte[16]; - stream.Read(magic, 0, 16); - - if (Tools.FileTypeTools.GetFileType(magic) == SupportedFileType.LDSCRYPT) - { - AppendToDictionary(protections, file, "Link Data Security encrypted file"); - return protections; - } - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } - } -} diff --git a/BurnOutSharp/FileType/PLJ.cs b/BurnOutSharp/FileType/PLJ.cs deleted file mode 100644 index fad30332..00000000 --- a/BurnOutSharp/FileType/PLJ.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.IO; -using BurnOutSharp.Interfaces; -using static BinaryObjectScanner.Utilities.Dictionary; - -namespace BurnOutSharp.FileType -{ - /// - /// PlayJ audio file - /// - public class PLJ : IScannable - { - /// - public ConcurrentDictionary> Scan(Scanner scanner, string file) - { - if (!File.Exists(file)) - return null; - - using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) - { - return Scan(scanner, fs, file); - } - } - - /// - public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) - { - var protections = new ConcurrentDictionary>(); - try - { - byte[] magic = new byte[16]; - stream.Read(magic, 0, 16); - - if (Tools.FileTypeTools.GetFileType(magic) == SupportedFileType.PLJ) - { - AppendToDictionary(protections, file, "PlayJ Audio File"); - return protections; - } - } - catch (Exception ex) - { - if (scanner.IncludeDebug) Console.WriteLine(ex); - } - - return null; - } - } -} diff --git a/BurnOutSharp/Scanner.cs b/BurnOutSharp/Scanner.cs index a0bde6eb..52d96fc7 100644 --- a/BurnOutSharp/Scanner.cs +++ b/BurnOutSharp/Scanner.cs @@ -344,6 +344,17 @@ namespace BurnOutSharp #region Non-Archive File Types + // Create a detectable for the given file type + var detectable = CreateDetectable(fileType); + + // If we're scanning file contents + if (detectable != null && ScanContents) + { + string subProtection = detectable.Detect(stream, fileName, IncludeDebug); + if (!string.IsNullOrWhiteSpace(subProtection)) + AppendToDictionary(protections, fileName, subProtection); + } + // Create a scannable for the given file type var scannable = CreateScannable(fileType); @@ -417,6 +428,25 @@ namespace BurnOutSharp #region Helpers + /// + /// Create an instance of a detectable based on file type + /// + private static IDetectable CreateDetectable(SupportedFileType fileType) + { + switch (fileType) + { + case SupportedFileType.AACSMediaKeyBlock: return new BinaryObjectScanner.FileType.AACSMediaKeyBlock(); + case SupportedFileType.BDPlusSVM: return new BinaryObjectScanner.FileType.BDPlusSVM(); + //case SupportedFileType.CIA: return new BinaryObjectScanner.FileType.CIA(); + case SupportedFileType.LDSCRYPT: return new BinaryObjectScanner.FileType.LDSCRYPT(); + //case SupportedFileType.N3DS: return new BinaryObjectScanner.FileType.N3DS(); + //case SupportedFileType.Nitro: return new BinaryObjectScanner.FileType.Nitro(); + case SupportedFileType.PLJ: return new BinaryObjectScanner.FileType.PLJ(); + case SupportedFileType.SFFS: return new BinaryObjectScanner.FileType.SFFS(); + default: return null; + } + } + /// /// Create an instance of an extractable based on file type /// @@ -447,7 +477,7 @@ namespace BurnOutSharp //case SupportedFileType.Quantum: return new BinaryObjectScanner.FileType.Quantum(); case SupportedFileType.RAR: return new BinaryObjectScanner.FileType.RAR(); case SupportedFileType.SevenZip: return new BinaryObjectScanner.FileType.SevenZip(); - case SupportedFileType.SFFS: return new FileType.SFFS(); + case SupportedFileType.SFFS: return new BinaryObjectScanner.FileType.SFFS(); case SupportedFileType.SGA: return new BinaryObjectScanner.FileType.SGA(); case SupportedFileType.TapeArchive: return new BinaryObjectScanner.FileType.TapeArchive(); case SupportedFileType.VBSP: return new BinaryObjectScanner.FileType.VBSP(); @@ -466,17 +496,7 @@ namespace BurnOutSharp { switch (fileType) { - case SupportedFileType.AACSMediaKeyBlock: return new FileType.AACSMediaKeyBlock(); - case SupportedFileType.BDPlusSVM: return new FileType.BDPlusSVM(); - //case SupportedFileType.CIA: return new FileType.CIA(); case SupportedFileType.Executable: return new FileType.Executable(); - //case FileTypes.IniFile: return new FileType.IniFile(); - case SupportedFileType.LDSCRYPT: return new FileType.LDSCRYPT(); - //case SupportedFileType.N3DS: return new FileType.N3DS(); - //case SupportedFileType.NCF: return new FileType.NCF(); - //case SupportedFileType.Nitro: return new FileType.Nitro(); - case SupportedFileType.PLJ: return new FileType.PLJ(); - case SupportedFileType.SFFS: return new FileType.SFFS(); case SupportedFileType.Textfile: return new FileType.Textfile(); default: return null; } diff --git a/BurnOutSharp/Tools/FileTypeTools.cs b/BurnOutSharp/Tools/FileTypeTools.cs index 577403f4..6559e5a0 100644 --- a/BurnOutSharp/Tools/FileTypeTools.cs +++ b/BurnOutSharp/Tools/FileTypeTools.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using BinaryObjectScanner.FileType; using BinaryObjectScanner.Matching; using BinaryObjectScanner.Utilities; using BinaryObjectScanner.Wrappers; @@ -793,40 +792,40 @@ namespace BurnOutSharp.Tools { case SupportedFileType.AACSMediaKeyBlock: return AACSMediaKeyBlock.Create(data); case SupportedFileType.BDPlusSVM: return BDPlusSVM.Create(data); - case SupportedFileType.BFPK: return BinaryObjectScanner.Wrappers.BFPK.Create(data); - case SupportedFileType.BSP: return BinaryObjectScanner.Wrappers.BSP.Create(data); + case SupportedFileType.BFPK: return BFPK.Create(data); + case SupportedFileType.BSP: return BSP.Create(data); //case SupportedFileType.BZip2: return BZip2.Create(data); - case SupportedFileType.CFB: return BinaryObjectScanner.Wrappers.CFB.Create(data); + case SupportedFileType.CFB: return CFB.Create(data); case SupportedFileType.CIA: return CIA.Create(data); case SupportedFileType.Executable: return DetermineExecutableType(data); - case SupportedFileType.GCF: return BinaryObjectScanner.Wrappers.GCF.Create(data); + case SupportedFileType.GCF: return GCF.Create(data); //case SupportedFileType.GZIP: return GZIP.Create(data); //case SupportedFileType.IniFile: return IniFile.Create(data); //case SupportedFileType.InstallShieldArchiveV3: return InstallShieldArchiveV3.Create(data); case SupportedFileType.InstallShieldCAB: return InstallShieldCabinet.Create(data); - //case SupportedFileType.LDSCRYPT: return LDSCRYPT.Create(data); + //case SupportedFileType.LDSCRYPT: return BinaryObjectScanner.Wrappers.LDSCRYPT.Create(data); case SupportedFileType.MicrosoftCAB: return MicrosoftCabinet.Create(data); //case SupportedFileType.MicrosoftLZ: return MicrosoftLZ.Create(data); //case SupportedFileType.MPQ: return MoPaQ.Create(data); case SupportedFileType.N3DS: return N3DS.Create(data); case SupportedFileType.NCF: return NCF.Create(data); case SupportedFileType.Nitro: return Nitro.Create(data); - case SupportedFileType.PAK: return BinaryObjectScanner.Wrappers.PAK.Create(data); - case SupportedFileType.PFF: return BinaryObjectScanner.Wrappers.PFF.Create(data); + case SupportedFileType.PAK: return PAK.Create(data); + case SupportedFileType.PFF: return PFF.Create(data); //case SupportedFileType.PKZIP: return PKZIP.Create(data); case SupportedFileType.PLJ: return PlayJAudioFile.Create(data); case SupportedFileType.Quantum: return Quantum.Create(data); //case SupportedFileType.RAR: return RAR.Create(data); //case SupportedFileType.SevenZip: return SevenZip.Create(data); //case SupportedFileType.SFFS: return SFFS.Create(data); - case SupportedFileType.SGA: return BinaryObjectScanner.Wrappers.SGA.Create(data); + case SupportedFileType.SGA: return SGA.Create(data); //case SupportedFileType.TapeArchive: return TapeArchive.Create(data); //case SupportedFileType.Textfile: return Textfile.Create(data); - case SupportedFileType.VBSP: return BinaryObjectScanner.Wrappers.VBSP.Create(data); - case SupportedFileType.VPK: return BinaryObjectScanner.Wrappers.VPK.Create(data); - case SupportedFileType.WAD: return BinaryObjectScanner.Wrappers.WAD.Create(data); + case SupportedFileType.VBSP: return VBSP.Create(data); + case SupportedFileType.VPK: return VPK.Create(data); + case SupportedFileType.WAD: return WAD.Create(data); //case SupportedFileType.XZ: return XZ.Create(data); - case SupportedFileType.XZP: return BinaryObjectScanner.Wrappers.XZP.Create(data); + case SupportedFileType.XZP: return XZP.Create(data); default: return null; } } diff --git a/Coding Guide.md b/Coding Guide.md index 5b6da79e..d52568bf 100644 --- a/Coding Guide.md +++ b/Coding Guide.md @@ -324,6 +324,7 @@ This section contains information on project and class organization principles t | `BinaryObjectScanner.ASN1` | Flat directory structure. | | `BinaryObjectScanner.Builders` | One file per executable type. | | `BinaryObjectScanner.Compression` | One directory per compression type. | +| `BinaryObjectScanner.FileType` | One file per file type. | | `BinaryObjectScanner.Interfaces` | One file per interface. | | `BinaryObjectScanner.Matching` | Flat directory structure. Include interfaces and base classes. | | `BinaryObjectScanner.Models` | One directory per executable type. One file per object model. | @@ -343,11 +344,12 @@ This section contains information on in-code organization principles that depend | Project | Description | | --- | --- | | `BurnOutSharp` | Varies from file to file. | -| `BurnOutSharp/FileType` | `IExtractable` implementations, `IScannable` implementations, helper methods. | +| `BurnOutSharp/FileType` | `IDetectable` implementations, `IExtractable` implementations, `IScannable` implementations, helper methods. | | `BurnOutSharp/Tools` | Methods grouped by function. Regions ordered alphabetically. | | `BinaryObjectScanner.ASN1` | Partial classes suggested for different implmentations. | | `BinaryObjectScanner.Builders` | Two copies of each non-generic method: one for byte arrays and one for Streams. | | `BinaryObjectScanner.Compression` | Varies from file to file. | +| `BinaryObjectScanner.FileType` | `IDetectable` implementations, `IExtractable` implementations, helper methods. | | `BinaryObjectScanner.Interfaces` | Methods ordered alphabetically. | | `BinaryObjectScanner.Matching` | Varies from file to file. | | `BinaryObjectScanner.Models` | No methods at all, just properties. | diff --git a/Developer Guide.md b/Developer Guide.md index 2516c3fd..0f0fe7c5 100644 --- a/Developer Guide.md +++ b/Developer Guide.md @@ -12,6 +12,7 @@ This is a guide for any developers who wish to research protections, implement n | `BinaryObjectScanner.ASN1` | Library containing classes and methods associated with Abstract Syntax Notation One and OID parsing. | | `BinaryObjectScanner.Builder` | Library containing classes that assist in populating the various object models defined in `BinaryObjectScanner.Models`. Builders can work with either byte arrays or streams for input. At the time of writing, the following executable types have builders: **MS-DOS**, **New Executable**, **Portable Executable**. | | `BinaryObjectScanner.Compression` | Library containing classes that deal with different compression formats. This library is used extensively by the wrappers in `BinaryObjectScanner.Wrappers`. | +| `BinaryObjectScanner.FileType` | Library containing file type definitions specific to scanning. | | `BinaryObjectScanner.Interfaces` | Library containing interface definitions for scanning and detection. | | `BinaryObjectScanner.Matching` | Library containing models and logic for generic searching and matching. This library is used extensively by the packer and protection checks in `BurnOutSharp`. | | `BinaryObjectScanner.Models` | Library containing object models that represent various pieces of known executable formats. At the time of writing, the following executable types have models: **MS-DOS**, **New Executable**, **Linear Executable (partial)**, **Portable Executable**. | @@ -88,7 +89,7 @@ Adding a new checker or format should happen in a few distinct steps: 1. Create a skeleton class representing the new checker or format - - If it is a new supported file type (such as an archive format), create the file in `BurnOutSharp/FileType/`. By default, you will need to implement `BurnOutSharp.Interfaces.IScannable` or `BinaryObjectScanner.Interfaces.IExtractable`. Do not implement any other interfaces. Please consider asking project maintainers before doing this work, especially if there are external dependencies. + - If it is a new supported file type (such as an archive format), create the file in `BinaryObjectScanner.FileType`. By default, you will need to implement `BurnOutSharp.Interfaces.IDetectable` or `BinaryObjectScanner.Interfaces.IExtractable`. Do not implement any other interfaces. Please consider asking project maintainers before doing this work, especially if there are external dependencies. - If it is a new supported executable packer, compressor, or installer format, create the file in `BinaryObjectScanner.Packer`. By default, you will need to implement `BinaryObjectScanner.Interfaces.IExtractable` as well as at least one of: `BinaryObjectScanner.Interfaces.ILinearExecutableCheck`, `BinaryObjectScanner.Interfaces.INewExecutableCheck`, and `BinaryObjectScanner.Interfaces.IPortableExecutableCheck`. It is exceptionally rare to need to implement `BinaryObjectScanner.Interfaces.IPathCheck`.