Use exposed model directly in more places

This commit is contained in:
Matt Nadareski
2023-09-15 22:21:05 -04:00
parent 57eaa1f04c
commit a52d45f7c2
117 changed files with 876 additions and 7138 deletions

View File

@@ -14,7 +14,7 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;

View File

@@ -14,7 +14,7 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;

View File

@@ -15,7 +15,7 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;

View File

@@ -14,7 +14,7 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;

View File

@@ -19,7 +19,7 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;

View File

@@ -41,7 +41,7 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;

View File

@@ -17,7 +17,7 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;

View File

@@ -14,7 +14,7 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;

View File

@@ -16,14 +16,14 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;
// This check may be overly limiting, as it excludes the sample provided to DiE (https://github.com/horsicq/Detect-It-Easy/issues/102).
// TODO: Find further samples and invesitgate if the "peC" section is only present on specific versions.
bool peCSection = pex.ContainsSection("peC", exact: true);
bool importTableMatch = (pex.ImportTable?.ImportDirectoryTable?.Any(idte => idte.Name == "KeRnEl32.dLl") ?? false);
bool importTableMatch = (pex.Model.ImportTable?.ImportDirectoryTable?.Any(idte => idte.Name == "KeRnEl32.dLl") ?? false);
if (peCSection && importTableMatch)
return "HyperTech CrackProof";

View File

@@ -19,7 +19,7 @@ namespace BinaryObjectScanner.Packer
return null;
// Check for "Inno" in the reserved words
if (nex.Stub_Reserved2[4] == 0x6E49 && nex.Stub_Reserved2[5] == 0x6F6E)
if (nex.Model.Stub?.Header?.Reserved2[4] == 0x6E49 && nex.Model.Stub?.Header?.Reserved2[5] == 0x6F6E)
{
string version = GetOldVersion(file, nex);
if (!string.IsNullOrWhiteSpace(version))
@@ -35,7 +35,7 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;

View File

@@ -13,7 +13,7 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;

View File

@@ -15,7 +15,7 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;

View File

@@ -12,7 +12,7 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;

View File

@@ -15,7 +15,7 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;

View File

@@ -13,7 +13,7 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;

View File

@@ -21,7 +21,7 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;

View File

@@ -12,12 +12,12 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;
// 0x4F434550 is "PECO"
if (pex.PointerToSymbolTable == 0x4F434550)
if (pex.Model.COFFFileHeader?.PointerToSymbolTable == 0x4F434550)
return "PE Compact v1.x";
// TODO: Get more granular version detection. PiD is somehow able to detect version ranges based

View File

@@ -12,7 +12,7 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;

View File

@@ -14,7 +14,7 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;

View File

@@ -12,7 +12,7 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;

View File

@@ -12,7 +12,7 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;

View File

@@ -20,7 +20,7 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;

View File

@@ -15,7 +15,7 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;

File diff suppressed because it is too large Load Diff

View File

@@ -47,7 +47,7 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;
@@ -120,7 +120,7 @@ namespace BinaryObjectScanner.Packer
private FormatProperty MatchesNEVersion(NewExecutable nex)
{
// TODO: Offset is _not_ the EXE header address, rather where the data starts. Fix this.
switch (nex.Stub_NewExeHeaderAddr)
switch (nex.Model.Stub?.Header?.NewExeHeaderAddr)
{
case 0x84b0:
return new FormatProperty { Dll = false, ArchiveStart = 0x11, ArchiveEnd = -1, InitText = false, FilenamePosition = 0x04, NoCrc = true };

View File

@@ -13,7 +13,7 @@ namespace BinaryObjectScanner.Packer
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
var sections = pex?.Model.SectionTable;
if (sections == null)
return null;