ContentMatchSets are now expected in IContentCheck

This commit is contained in:
Matt Nadareski
2021-08-25 19:37:32 -07:00
parent 7548646ba2
commit 3ab0bcc0ae
63 changed files with 478 additions and 182 deletions

View File

@@ -91,6 +91,8 @@ namespace BurnOutSharp.FileType
// Iterate through all content checks
Parallel.ForEach(contentCheckClasses, contentCheckClass =>
{
// TODO: Find a way to combine the outputs of GetContentMatchSet
// TODO: Have CheckContents take priority over GetContentMatchSet results
string protection = contentCheckClass.CheckContents(file, fileContent, scanner.IncludeDebug);
// If we have a valid content check based on settings

View File

@@ -1,9 +1,18 @@
namespace BurnOutSharp
using System.Collections.Generic;
using BurnOutSharp.Matching;
namespace BurnOutSharp
{
// TODO: This should either include an override that takes a Stream instead of the byte[]
// OR have a completely separate check for when it's an executable specifically
internal interface IContentCheck
{
/// <summary>
/// Get a list of content match sets that represent a protection
/// </summary>
/// <returns>List of content match sets, null if not applicable</returns>
List<ContentMatchSet> GetContentMatchSets();
/// <summary>
/// Check a path for protections based on file contents
/// </summary>

View File

@@ -3,7 +3,7 @@ namespace BurnOutSharp.Matching
/// <summary>
/// Content matching criteria
/// </summary>
internal class ContentMatch : IMatch<byte?[]>
public class ContentMatch : IMatch<byte?[]>
{
/// <summary>
/// Content to match

View File

@@ -7,7 +7,7 @@ namespace BurnOutSharp.Matching
/// <summary>
/// A set of content matches that work together
/// </summary>
internal class ContentMatchSet : MatchSet<ContentMatch, byte?[]>
public class ContentMatchSet : MatchSet<ContentMatch, byte?[]>
{
/// <summary>
/// Function to get a content version

View File

@@ -1,6 +1,6 @@
namespace BurnOutSharp.Matching
{
internal interface IMatch<T>
public interface IMatch<T>
{
T Needle { get; set; }
}

View File

@@ -5,7 +5,7 @@ namespace BurnOutSharp.Matching
/// <summary>
/// Wrapper for a single set of matching criteria
/// </summary>
internal abstract class MatchSet<T, U> where T : IMatch<U>
public abstract class MatchSet<T, U> where T : IMatch<U>
{
/// <summary>
/// Set of all matchers

View File

@@ -7,9 +7,9 @@ namespace BurnOutSharp.PackerType
public class AdvancedInstaller : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// Software\Caphyon\Advanced Installer
new ContentMatchSet(new byte?[]
@@ -21,7 +21,12 @@ namespace BurnOutSharp.PackerType
0x6C, 0x65, 0x72
}, "Caphyon Advanced Installer"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}
}

View File

@@ -6,9 +6,9 @@ namespace BurnOutSharp.PackerType
public class Armadillo : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// .nicode + (char)0x00
new ContentMatchSet(new byte?[] { 0x2E, 0x6E, 0x69, 0x63, 0x6F, 0x64, 0x65, 0x00 }, "Armadillo"),
@@ -16,7 +16,12 @@ namespace BurnOutSharp.PackerType
// ARMDEBUG
new ContentMatchSet(new byte?[] { 0x41, 0x52, 0x4D, 0x44, 0x45, 0x42, 0x55, 0x47 }, "Armadillo"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}
}

View File

@@ -11,11 +11,11 @@ namespace BurnOutSharp.PackerType
{
/// <inheritdoc/>
public bool ShouldScan(byte[] magic) => true;
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// %Wo<57>a6.<2E>a6.<2E>a6.<2E>a6.<2E>{6.<2E>.).<2E>f6.<2E><>).<2E>`6.<2E><>0.<2E>`6.<2E>
new ContentMatchSet(
@@ -29,7 +29,12 @@ namespace BurnOutSharp.PackerType
0xD9, 0x30, 0x07, 0x92, 0x60, 0x36, 0x01, 0x92
}, end: 200), "CExe"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -6,9 +6,9 @@ namespace BurnOutSharp.PackerType
public class EXEStealth : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// ??[[__[[_ + (char)0x00 + {{ + (char)0x0 + (char)0x00 + {{ + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x0 + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + ?;??;??
new ContentMatchSet(new byte?[]
@@ -20,7 +20,12 @@ namespace BurnOutSharp.PackerType
0x3F
}, "EXE Stealth"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}
}

View File

@@ -14,9 +14,9 @@ namespace BurnOutSharp.PackerType
public bool ShouldScan(byte[] magic) => true;
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// Inno Setup Setup Data (
new ContentMatchSet(new byte?[]
@@ -32,7 +32,12 @@ namespace BurnOutSharp.PackerType
GetOldVersion,
"Inno Setup"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -11,18 +11,22 @@ namespace BurnOutSharp.PackerType
public bool ShouldScan(byte[] magic) => true;
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
//TODO: Add exact version detection for Windows builds, make sure versions before 3.X are detected as well, and detect the Mac builds.
// ViseMain
new ContentMatchSet(
new ContentMatch(new byte?[] { 0x56, 0x69, 0x73, 0x65, 0x4D, 0x61, 0x69, 0x6E }, start: 0xE0A4, end: 0xE0A5),
"Installer VISE"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
//TODO: Add exact version detection for Windows builds, make sure versions before 3.X are detected as well, and detect the Mac builds.
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -9,27 +9,9 @@ namespace BurnOutSharp.PackerType
public class IntelInstallationFramework : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var fvinfo = Utilities.GetFileVersionInfo(file);
string name = fvinfo?.FileDescription?.Trim();
if (!string.IsNullOrWhiteSpace(name)
&& (name.Equals("Intel(R) Installation Framework", StringComparison.OrdinalIgnoreCase)
|| name.Equals("Intel Installation Framework", StringComparison.OrdinalIgnoreCase)))
{
return $"Intel Installation Framework {Utilities.GetFileVersion(file)}";
}
name = fvinfo?.ProductName?.Trim();
if (!string.IsNullOrWhiteSpace(name)
&& (name.Equals("Intel(R) Installation Framework", StringComparison.OrdinalIgnoreCase)
|| name.Equals("Intel Installation Framework", StringComparison.OrdinalIgnoreCase)))
{
return $"Intel Installation Framework {Utilities.GetFileVersion(file)}";
}
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// I + (char)0x00 + n + (char)0x00 + t + (char)0x00 + e + (char)0x00 + l + (char)0x00 + ( + (char)0x00 + R + (char)0x00 + ) + (char)0x00 + + (char)0x00 + I + (char)0x00 + n + (char)0x00 + s + (char)0x00 + t + (char)0x00 + a + (char)0x00 + l + (char)0x00 + l + (char)0x00 + a + (char)0x00 + t + (char)0x00 + i + (char)0x00 + o + (char)0x00 + n + (char)0x00 + + (char)0x00 + F + (char)0x00 + r + (char)0x00 + a + (char)0x00 + m + (char)0x00 + e + (char)0x00 + w + (char)0x00 + o + (char)0x00 + r + (char)0x00 + k + (char)0x00
new ContentMatchSet(new byte?[]
@@ -56,7 +38,30 @@ namespace BurnOutSharp.PackerType
0x77, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x6B, 0x00,
}, Utilities.GetFileVersion, "Intel Installation Framework"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var fvinfo = Utilities.GetFileVersionInfo(file);
string name = fvinfo?.FileDescription?.Trim();
if (!string.IsNullOrWhiteSpace(name)
&& (name.Equals("Intel(R) Installation Framework", StringComparison.OrdinalIgnoreCase)
|| name.Equals("Intel Installation Framework", StringComparison.OrdinalIgnoreCase)))
{
return $"Intel Installation Framework {Utilities.GetFileVersion(file)}";
}
name = fvinfo?.ProductName?.Trim();
if (!string.IsNullOrWhiteSpace(name)
&& (name.Equals("Intel(R) Installation Framework", StringComparison.OrdinalIgnoreCase)
|| name.Equals("Intel Installation Framework", StringComparison.OrdinalIgnoreCase)))
{
return $"Intel Installation Framework {Utilities.GetFileVersion(file)}";
}
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}
}

View File

@@ -14,31 +14,9 @@ namespace BurnOutSharp.PackerType
public bool ShouldScan(byte[] magic) => true;
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var fvinfo = Utilities.GetFileVersionInfo(file);
string name = fvinfo?.InternalName?.Trim();
if (!string.IsNullOrWhiteSpace(name) && name.Equals("Wextract", StringComparison.OrdinalIgnoreCase))
{
string version = GetVersion(file, fileContent, null);
if (!string.IsNullOrWhiteSpace(version))
return $"Microsoft CAB SFX v{Utilities.GetFileVersion(file)}";
return "Microsoft CAB SFX";
}
name = fvinfo?.OriginalFilename?.Trim();
if (!string.IsNullOrWhiteSpace(name) && name.Equals("WEXTRACT.EXE", StringComparison.OrdinalIgnoreCase))
{
string version = GetVersion(file, fileContent, null);
if (!string.IsNullOrWhiteSpace(version))
return $"Microsoft CAB SFX v{Utilities.GetFileVersion(file)}";
return "Microsoft CAB SFX";
}
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// wextract_cleanup
new ContentMatchSet(new byte?[]
@@ -67,7 +45,34 @@ namespace BurnOutSharp.PackerType
// MSCFu
new ContentMatchSet(new byte?[] { 0x4D, 0x53, 0x43, 0x46, 0x75 }, GetVersion, "Microsoft CAB SFX"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var fvinfo = Utilities.GetFileVersionInfo(file);
string name = fvinfo?.InternalName?.Trim();
if (!string.IsNullOrWhiteSpace(name) && name.Equals("Wextract", StringComparison.OrdinalIgnoreCase))
{
string version = GetVersion(file, fileContent, null);
if (!string.IsNullOrWhiteSpace(version))
return $"Microsoft CAB SFX v{Utilities.GetFileVersion(file)}";
return "Microsoft CAB SFX";
}
name = fvinfo?.OriginalFilename?.Trim();
if (!string.IsNullOrWhiteSpace(name) && name.Equals("WEXTRACT.EXE", StringComparison.OrdinalIgnoreCase))
{
string version = GetVersion(file, fileContent, null);
if (!string.IsNullOrWhiteSpace(version))
return $"Microsoft CAB SFX v{Utilities.GetFileVersion(file)}";
return "Microsoft CAB SFX";
}
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -9,9 +9,9 @@ namespace BurnOutSharp.PackerType
public class NSIS : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// Nullsoft Install System
new ContentMatchSet(new byte?[]
@@ -28,7 +28,12 @@ namespace BurnOutSharp.PackerType
0x49, 0x6e, 0x73, 0x74
}, "NSIS"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -8,10 +8,10 @@ namespace BurnOutSharp.PackerType
public class PECompact : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
// Another possible version string for version 1 is "PECO" (50 45 43 4F)
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// pec1
new ContentMatchSet(new ContentMatch(new byte?[] { 0x70, 0x65, 0x63, 0x31 }, end: 2048), "PE Compact 1"),
@@ -26,7 +26,12 @@ namespace BurnOutSharp.PackerType
0x74, 0x32
}, "PE Compact 2"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -12,9 +12,10 @@ namespace BurnOutSharp.PackerType
public bool ShouldScan(byte[] magic) => true;
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
// Another possible version string for version 1 is "PECO" (50 45 43 4F)
return new List<ContentMatchSet>
{
// S.e.t.u.p. .F.a.c.t.o.r.y.
new ContentMatchSet(new byte?[]
@@ -45,7 +46,12 @@ namespace BurnOutSharp.PackerType
// 0x69, 0x00, 0x6F, 0x00, 0x6E, 0x00
// }, GetVersion, "Setup Factory"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -7,9 +7,9 @@ namespace BurnOutSharp.PackerType
public class UPX : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// UPX!
new ContentMatchSet(new byte?[] { 0x55, 0x50, 0x58, 0x21 }, GetVersion, "UPX"),
@@ -44,7 +44,12 @@ namespace BurnOutSharp.PackerType
"UPX (NOS Variant) (Unknown Version)"
),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -15,9 +15,9 @@ namespace BurnOutSharp.PackerType
public bool ShouldScan(byte[] magic) => true;
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// Software\WinRAR SFX
new ContentMatchSet(new byte?[]
@@ -27,7 +27,12 @@ namespace BurnOutSharp.PackerType
0x53, 0x46, 0x58
}, "WinRAR SFX"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -15,9 +15,9 @@ namespace BurnOutSharp.PackerType
public bool ShouldScan(byte[] magic) => true;
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// WinZip Self-Extractor
new ContentMatchSet(new byte?[]
@@ -30,7 +30,12 @@ namespace BurnOutSharp.PackerType
// _winzip_
new ContentMatchSet(new byte?[] { 0x5F, 0x77, 0x69, 0x6E, 0x7A, 0x69, 0x70, 0x5F }, GetVersion, "WinZip SFX"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -14,14 +14,19 @@ namespace BurnOutSharp.PackerType
public bool ShouldScan(byte[] magic) => true;
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// WiseMain
new ContentMatchSet(new byte?[] { 0x57, 0x69, 0x73, 0x65, 0x4D, 0x61, 0x69, 0x6E }, "Wise Installation Wizard Module"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -6,9 +6,9 @@ namespace BurnOutSharp.PackerType
public class dotFuscator : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// DotfuscatorAttribute
new ContentMatchSet(new byte?[]
@@ -18,7 +18,12 @@ namespace BurnOutSharp.PackerType
0x62, 0x75, 0x74, 0x65
}, "dotFuscator"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}
}

View File

@@ -6,9 +6,9 @@ namespace BurnOutSharp.ProtectionType
public class ActiveMARK : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// TMSAMVOF
new ContentMatchSet(new byte?[] { 0x54, 0x4D, 0x53, 0x41, 0x4D, 0x56, 0x4F, 0x46 }, "ActiveMARK"),
@@ -21,7 +21,12 @@ namespace BurnOutSharp.ProtectionType
0x9A, 0xC1, 0x16, 0x00, 0x10, 0xC2, 0x16, 0x00
}, "ActiveMARK 5"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}
}

View File

@@ -6,14 +6,19 @@ namespace BurnOutSharp.ProtectionType
public class AlphaROM : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// SETTEC
new ContentMatchSet(new byte?[] { 0x53, 0x45, 0x54, 0x54, 0x45, 0x43 }, "Alpha-ROM"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}
}

View File

@@ -13,9 +13,9 @@ namespace BurnOutSharp.ProtectionType
public class Bitpool : IContentCheck, IPathCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// Sometimes found in CD.IDX
// BITPOOL.RSC
@@ -25,7 +25,12 @@ namespace BurnOutSharp.ProtectionType
0x52, 0x53, 0x43
}, "Bitpool"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -6,9 +6,9 @@ namespace BurnOutSharp.ProtectionType
public class CDCheck : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// MGS CDCheck
new ContentMatchSet(new byte?[]
@@ -20,7 +20,12 @@ namespace BurnOutSharp.ProtectionType
// CDCheck
new ContentMatchSet(new byte?[] { 0x43, 0x44, 0x43, 0x68, 0x65, 0x63, 0x6B }, "Executable-Based CD Check"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -9,9 +9,9 @@ namespace BurnOutSharp.ProtectionType
public class CDCops : IContentCheck, IPathCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// CD-Cops, ver.
new ContentMatchSet(new byte?[]
@@ -23,7 +23,12 @@ namespace BurnOutSharp.ProtectionType
// .grand + (char)0x00
new ContentMatchSet(new byte?[] { 0x2E, 0x67, 0x72, 0x61, 0x6E, 0x64, 0x00 }, "CD-Cops"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -7,9 +7,9 @@ namespace BurnOutSharp.ProtectionType
public class CDKey : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// I + (char)0x00 + n + (char)0x00 + t + (char)0x00 + e + (char)0x00 + r + (char)0x00 + n + (char)0x00 + a + (char)0x00 + l + (char)0x00 + N + (char)0x00 + a + (char)0x00 + m + (char)0x00 + e + (char)0x00 + + (char)0x00 + + (char)0x00 + C + (char)0x00 + D + (char)0x00 + K + (char)0x00 + e + (char)0x00 + y + (char)0x00
new ContentMatchSet(new byte?[]
@@ -21,7 +21,12 @@ namespace BurnOutSharp.ProtectionType
0x65, 0x00, 0x79, 0x00
}, Utilities.GetFileVersion, "CD-Key / Serial"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}
}

View File

@@ -7,9 +7,9 @@ namespace BurnOutSharp.ProtectionType
public class CDLock : IContentCheck, IPathCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// 2 + (char)0xF2 + (char)0x02 + (char)0x82 + (char)0xC3 + (char)0xBC + (char)0x0B + $ + (char)0x99 + (char)0xAD + 'C + (char)0xE4 + (char)0x9D + st + (char)0x99 + (char)0xFA + 2$ + (char)0x9D + )4 + (char)0xFF + t
new ContentMatchSet(new byte?[]
@@ -20,7 +20,12 @@ namespace BurnOutSharp.ProtectionType
0x74
}, "CD-Lock"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -6,14 +6,19 @@ namespace BurnOutSharp.ProtectionType
public class CDSHiELDSE : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// ~0017.tmp
new ContentMatchSet(new byte?[] { 0x7E, 0x30, 0x30, 0x31, 0x37, 0x2E, 0x74, 0x6D, 0x70 }, "CDSHiELD SE"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}
}

View File

@@ -11,9 +11,9 @@ namespace BurnOutSharp.ProtectionType
public class CactusDataShield : IContentCheck, IPathCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// DATA.CDS
new ContentMatchSet(new byte?[] { 0x44, 0x41, 0x54, 0x41, 0x2E, 0x43, 0x44, 0x53 }, "Cactus Data Shield 200"),
@@ -24,7 +24,12 @@ namespace BurnOutSharp.ProtectionType
// CDSPlayer
new ContentMatchSet(new byte?[] { 0x43, 0x44, 0x53, 0x50, 0x6C, 0x61, 0x79, 0x65, 0x72 }, "Cactus Data Shield 200"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -6,14 +6,19 @@ namespace BurnOutSharp.ProtectionType
public class CengaProtectDVD : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// .cenega
new ContentMatchSet(new byte?[] { 0x2E, 0x63, 0x65, 0x6E, 0x65, 0x67, 0x61 }, "Cenega ProtectDVD"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}
}

View File

@@ -6,10 +6,10 @@ namespace BurnOutSharp.ProtectionType
public class CodeLock : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
// TODO: Verify if these are OR or AND
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// icd1 + (char)0x00
new ContentMatchSet(new byte?[] { 0x69, 0x63, 0x64, 0x31, 0x00 }, "Code Lock"),
@@ -24,7 +24,12 @@ namespace BurnOutSharp.ProtectionType
0x4B, 0x2E, 0x4F, 0x43, 0x58
}, "Code Lock"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}
}

View File

@@ -7,9 +7,9 @@ namespace BurnOutSharp.ProtectionType
public class CopyKiller : IContentCheck, IPathCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// Tom Commander
new ContentMatchSet(new byte?[]
@@ -18,7 +18,12 @@ namespace BurnOutSharp.ProtectionType
0x61, 0x6E, 0x64, 0x65, 0x72
}, "CopyKiller"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -8,9 +8,9 @@ namespace BurnOutSharp.ProtectionType
public class DVDCops : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// DVD-Cops, ver.
new ContentMatchSet(new byte?[]
@@ -19,7 +19,12 @@ namespace BurnOutSharp.ProtectionType
0x2C, 0x20, 0x20, 0x76, 0x65, 0x72, 0x2E, 0x20
}, GetVersion, "DVD-Cops"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -11,9 +11,9 @@ namespace BurnOutSharp.ProtectionType
// - Reference to `EASTL` and `EAStdC` are standard for EA products and does not indicate Cucko by itself
// - There's little information outside of PiD detection that actually knows about Cucko
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// EASTL
//new ContentMatchSet(new byte?[] { 0x45, 0x41, 0x53, 0x54, 0x4C }, "Cucko (EA Custom)"),
@@ -96,7 +96,12 @@ namespace BurnOutSharp.ProtectionType
0x72, 0x00
}, "EA DRM Protection"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}
}

View File

@@ -8,9 +8,9 @@ namespace BurnOutSharp.ProtectionType
public class GFWL : IContentCheck, IPathCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// xlive.dll
new ContentMatchSet(new byte?[] { 0x78, 0x6C, 0x69, 0x76, 0x65, 0x2E, 0x64, 0x6C, 0x6C }, "Games for Windows LIVE"),
@@ -44,7 +44,12 @@ namespace BurnOutSharp.ProtectionType
0x4C, 0x00, 0x49, 0x00, 0x56, 0x00, 0x45, 0x00,
}, Utilities.GetFileVersion, "Games for Windows LIVE"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -8,9 +8,9 @@ namespace BurnOutSharp.ProtectionType
public class ImpulseReactor : IContentCheck, IPathCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
new ContentMatchSet(new List<byte?[]>
{
@@ -42,7 +42,12 @@ namespace BurnOutSharp.ProtectionType
0x65, 0x6E, 0x74
}, "Impulse Reactor"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -22,14 +22,19 @@ namespace BurnOutSharp.ProtectionType
*/
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// Trial + (char)0x00 + P
new ContentMatchSet(new byte?[] { 0x54, 0x72, 0x69, 0x61, 0x6C, 0x00, 0x50 }, "INTENIUM Trial & Buy Protection"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}
}

View File

@@ -8,9 +8,9 @@ namespace BurnOutSharp.ProtectionType
public class JoWooDXProt : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// @HC09
new ContentMatchSet(new byte?[] { 0x40, 0x48, 0x43, 0x30, 0x39, 0x20, 0x20, 0x20, 0x20 }, "JoWooD X-Prot v2"),
@@ -33,7 +33,12 @@ namespace BurnOutSharp.ProtectionType
// .ext
new ContentMatchSet(new byte?[] { 0x2E, 0x65, 0x78, 0x74, 0x20, 0x20, 0x20, 0x20 }, "JoWooD X-Prot v1"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -6,9 +6,9 @@ namespace BurnOutSharp.ProtectionType
public class KeyLock : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// KEY-LOCK COMMAND
new ContentMatchSet(new byte?[]
@@ -17,7 +17,12 @@ namespace BurnOutSharp.ProtectionType
0x20, 0x43, 0x4F, 0x4D, 0x4D, 0x41, 0x4E, 0x44
}, "Key-Lock (Dongle)"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}
}

View File

@@ -12,27 +12,9 @@ namespace BurnOutSharp.ProtectionType
public class LaserLock : IContentCheck, IPathCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
// "Packed by SPEEnc V2 Asterios Parlamentas.PE"
byte?[] check = new byte?[] { 0x50, 0x61, 0x63, 0x6B, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x53, 0x50, 0x45, 0x45, 0x6E, 0x63, 0x20, 0x56, 0x32, 0x20, 0x41, 0x73, 0x74, 0x65, 0x72, 0x69, 0x6F, 0x73, 0x20, 0x50, 0x61, 0x72, 0x6C, 0x61, 0x6D, 0x65, 0x6E, 0x74, 0x61, 0x73, 0x2E, 0x50, 0x45 };
bool containsCheck = fileContent.FirstPosition(check, out int position);
// "GetModuleHandleA" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + "GetProcAddress" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + "LoadLibraryA" + (char)0x00 + (char)0x00 + "KERNEL32.dll" + (char)0x00 + "ëy" + (char)0x01 + "SNIF"
byte?[] check2 = { 0x47, 0x65, 0x74, 0x4D, 0x6F, 0x64, 0x75, 0x6C, 0x65, 0x48, 0x61, 0x6E, 0x64, 0x6C, 0x65, 0x41, 0x00, 0x00, 0x00, 0x00, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6F, 0x63, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x6F, 0x61, 0x64, 0x4C, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x41, 0x00, 0x00, 0x4B, 0x45, 0x52, 0x4E, 0x45, 0x4C, 0x33, 0x32, 0x2E, 0x64, 0x6C, 0x6C, 0x00, 0xEB, 0x79, 0x01, 0x53, 0x4E, 0x49, 0x46 };
bool containsCheck2 = fileContent.FirstPosition(check2, out int position2);
if (containsCheck && containsCheck2)
return $"LaserLock {GetVersion(fileContent, position2)} {GetBuild(fileContent, true)}" + (includeDebug ? $" (Index {position}, {position2})" : string.Empty);
else if (containsCheck && !containsCheck2)
return $"LaserLock Marathon {GetBuild(fileContent, false)}" + (includeDebug ? $" (Index {position})" : string.Empty);
else if (!containsCheck && containsCheck2)
return $"LaserLock {GetVersion(fileContent, --position2)} {GetBuild(fileContent, false)}" + (includeDebug ? $" (Index {position2})" : string.Empty);
if (file != null && string.Equals(Path.GetFileName(file), "NOMOUSE.SP", StringComparison.OrdinalIgnoreCase))
return $"LaserLock {GetVersion16Bit(fileContent)}" + (includeDebug ? $" (Index 71)" : string.Empty);
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// :\\LASERLOK\\LASERLOK.IN + (char)0x00 + C:\\NOMOUSE.SP
new ContentMatchSet(new byte?[]
@@ -59,7 +41,30 @@ namespace BurnOutSharp.ProtectionType
0x33
}, "LaserLock 5"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
// "Packed by SPEEnc V2 Asterios Parlamentas.PE"
byte?[] check = new byte?[] { 0x50, 0x61, 0x63, 0x6B, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x53, 0x50, 0x45, 0x45, 0x6E, 0x63, 0x20, 0x56, 0x32, 0x20, 0x41, 0x73, 0x74, 0x65, 0x72, 0x69, 0x6F, 0x73, 0x20, 0x50, 0x61, 0x72, 0x6C, 0x61, 0x6D, 0x65, 0x6E, 0x74, 0x61, 0x73, 0x2E, 0x50, 0x45 };
bool containsCheck = fileContent.FirstPosition(check, out int position);
// "GetModuleHandleA" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + "GetProcAddress" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + "LoadLibraryA" + (char)0x00 + (char)0x00 + "KERNEL32.dll" + (char)0x00 + "ëy" + (char)0x01 + "SNIF"
byte?[] check2 = { 0x47, 0x65, 0x74, 0x4D, 0x6F, 0x64, 0x75, 0x6C, 0x65, 0x48, 0x61, 0x6E, 0x64, 0x6C, 0x65, 0x41, 0x00, 0x00, 0x00, 0x00, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6F, 0x63, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x6F, 0x61, 0x64, 0x4C, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79, 0x41, 0x00, 0x00, 0x4B, 0x45, 0x52, 0x4E, 0x45, 0x4C, 0x33, 0x32, 0x2E, 0x64, 0x6C, 0x6C, 0x00, 0xEB, 0x79, 0x01, 0x53, 0x4E, 0x49, 0x46 };
bool containsCheck2 = fileContent.FirstPosition(check2, out int position2);
if (containsCheck && containsCheck2)
return $"LaserLock {GetVersion(fileContent, position2)} {GetBuild(fileContent, true)}" + (includeDebug ? $" (Index {position}, {position2})" : string.Empty);
else if (containsCheck && !containsCheck2)
return $"LaserLock Marathon {GetBuild(fileContent, false)}" + (includeDebug ? $" (Index {position})" : string.Empty);
else if (!containsCheck && containsCheck2)
return $"LaserLock {GetVersion(fileContent, --position2)} {GetBuild(fileContent, false)}" + (includeDebug ? $" (Index {position2})" : string.Empty);
if (file != null && string.Equals(Path.GetFileName(file), "NOMOUSE.SP", StringComparison.OrdinalIgnoreCase))
return $"LaserLock {GetVersion16Bit(fileContent)}" + (includeDebug ? $" (Index 71)" : string.Empty);
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -7,9 +7,9 @@ namespace BurnOutSharp.ProtectionType
public class MediaMaxCD3 : IContentCheck, IPathCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// Cd3Ctl
new ContentMatchSet(new byte?[] { 0x43, 0x64, 0x33, 0x43, 0x74, 0x6C }, "MediaMax CD-3"),
@@ -21,7 +21,12 @@ namespace BurnOutSharp.ProtectionType
0x6C, 0x6C, 0x53, 0x62, 0x63, 0x70
}, "MediaMax CD-3"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -7,9 +7,9 @@ namespace BurnOutSharp.ProtectionType
public class OnlineRegistration : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// I + (char)0x00 + n + (char)0x00 + t + (char)0x00 + e + (char)0x00 + r + (char)0x00 + n + (char)0x00 + a + (char)0x00 + l + (char)0x00 + N + (char)0x00 + a + (char)0x00 + m + (char)0x00 + e + (char)0x00 + + (char)0x00 + + (char)0x00 + E + (char)0x00 + R + (char)0x00 + e + (char)0x00 + g + (char)0x00
new ContentMatchSet(new byte?[]
@@ -21,7 +21,12 @@ namespace BurnOutSharp.ProtectionType
0x67, 0x00
}, Utilities.GetFileVersion, "Executable-Based Online Registration"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}
}

View File

@@ -7,14 +7,19 @@ namespace BurnOutSharp.ProtectionType
public class Origin : IContentCheck, IPathCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// O + (char)0x00 + r + (char)0x00 + i + (char)0x00 + g + (char)0x00 + i + (char)0x00 + n + (char)0x00 + S + (char)0x00 + e + (char)0x00 + t + (char)0x00 + u + (char)0x00 + p + (char)0x00 + . + (char)0x00 + e + (char)0x00 + x + (char)0x00 + e + (char)0x00
new ContentMatchSet(new byte?[] { 0x4F, 0x00, 0x72, 0x00, 0x69, 0x00, 0x67, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x53, 0x00, 0x65, 0x00, 0x74, 0x00, 0x75, 0x00, 0x70, 0x00, 0x2E, 0x00, 0x65, 0x00, 0x78, 0x00, 0x65, 0x00 }, "Origin"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -5,12 +5,10 @@ namespace BurnOutSharp.ProtectionType
{
public class PSXAntiModchip : IContentCheck
{
// TODO: Figure out PSX binary header so this can be checked explicitly
// TODO: Detect Red Hand protection
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// SOFTWARE TERMINATED\nCONSOLE MAY HAVE BEEN MODIFIED\n CALL 1-888-780-7690
new ContentMatchSet(new byte?[]
@@ -41,7 +39,14 @@ namespace BurnOutSharp.ProtectionType
0x30, 0x59, 0x30, 0x02
}, "PlayStation Anti-modchip (Japanese)"),
};
}
// TODO: Figure out PSX binary header so this can be checked explicitly
// TODO: Detect Red Hand protection
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}
}

View File

@@ -12,9 +12,9 @@ namespace BurnOutSharp.ProtectionType
public class ProtectDisc : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// HúMETINF
new ContentMatchSet(new byte?[] { 0x48, 0xFA, 0x4D, 0x45, 0x54, 0x49, 0x4E, 0x46 }, GetVersion76till10, "ProtectDisc"),
@@ -22,7 +22,12 @@ namespace BurnOutSharp.ProtectionType
// ACE-PCD
new ContentMatchSet(new byte?[] { 0x41, 0x43, 0x45, 0x2D, 0x50, 0x43, 0x44 }, GetVersion6till8, "ProtectDisc"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -6,9 +6,9 @@ namespace BurnOutSharp.ProtectionType
public class RingPROTECH : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// (char)0x00 + Allocator + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00
new ContentMatchSet(new byte?[]
@@ -17,7 +17,12 @@ namespace BurnOutSharp.ProtectionType
0x6F, 0x72, 0x00, 0x00, 0x00, 0x00
}, "Ring PROTECH [Check disc for physical ring]"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}
}

View File

@@ -6,14 +6,19 @@ namespace BurnOutSharp.ProtectionType
public class SVKProtector : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// ?SVKP + (char)0x00 + (char)0x00
new ContentMatchSet(new byte?[] { 0x3F, 0x53, 0x56, 0x4B, 0x50, 0x00, 0x00 }, "SVK Protector"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}
}

View File

@@ -40,9 +40,9 @@ namespace BurnOutSharp.ProtectionType
};
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
new ContentMatchSet(new List<byte?[]>
{
@@ -81,7 +81,12 @@ namespace BurnOutSharp.ProtectionType
// stxt371
new ContentMatchSet(new byte?[] { 0x73, 0x74, 0x78, 0x74, 0x33, 0x37, 0x31 }, Get320to4xVersion, "SafeDisc"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -7,14 +7,19 @@ namespace BurnOutSharp.ProtectionType
public class SafeLock : IContentCheck, IPathCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// SafeLock
new ContentMatchSet(new byte?[] { 0x53, 0x61, 0x66, 0x65, 0x4C, 0x6F, 0x63, 0x6B }, "SafeLock"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -10,9 +10,9 @@ namespace BurnOutSharp.ProtectionType
public class SecuROM : IContentCheck, IPathCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// AddD + (char)0x03 + (char)0x00 + (char)0x00 + (char)0x00)
new ContentMatchSet(new byte?[] { 0x41, 0x64, 0x64, 0x44, 0x03, 0x00, 0x00, 0x00 }, GetV4Version, "SecuROM"),
@@ -53,7 +53,12 @@ namespace BurnOutSharp.ProtectionType
// .cms_d + (char)0x00
new ContentMatchSet(new byte?[] { 0x2E, 0x63, 0x6D, 0x73, 0x5F, 0x64, 0x00 }, "SecuROM 1-3"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -8,14 +8,19 @@ namespace BurnOutSharp.ProtectionType
public class SmartE : IContentCheck, IPathCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// BITARTS
new ContentMatchSet(new byte?[] { 0x42, 0x49, 0x54, 0x41, 0x52, 0x54, 0x53 }, "SmartE"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -21,9 +21,9 @@ namespace BurnOutSharp.ProtectionType
};
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// D + (char)0x00 + V + (char)0x00 + M + (char)0x00 + + (char)0x00 + L + (char)0x00 + i + (char)0x00 + b + (char)0x00 + r + (char)0x00 + a + (char)0x00 + r + (char)0x00 + y + (char)0x00
new ContentMatchSet(new byte?[]
@@ -90,7 +90,12 @@ namespace BurnOutSharp.ProtectionType
0x53, 0x00, 0x47, 0x00, 0x54, 0x00
}, "SolidShield"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -9,9 +9,9 @@ namespace BurnOutSharp.ProtectionType
public class StarForce : IContentCheck, IPathCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
new ContentMatchSet(new List<byte?[]>
{
@@ -114,7 +114,12 @@ namespace BurnOutSharp.ProtectionType
0x64, 0x00, 0x75, 0x00, 0x6c, 0x00, 0x65, 0x00
}, "StarForce 5"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -6,9 +6,9 @@ namespace BurnOutSharp.ProtectionType
public class Sysiphus : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// V SUHPISYSDVD
new ContentMatchSet(new byte?[]
@@ -24,7 +24,12 @@ namespace BurnOutSharp.ProtectionType
0x59, 0x53
}, GetVersion, "Sysiphus"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -12,9 +12,9 @@ namespace BurnOutSharp.ProtectionType
public class Tages : IContentCheck, IPathCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// protected-tages-runtime.exe
new ContentMatchSet(new byte?[]
@@ -36,7 +36,12 @@ namespace BurnOutSharp.ProtectionType
// (char)0xE8 + u + (char)0x00 + (char)0x00 + (char)0x00 + (char)0xE8
new ContentMatchSet(new byte?[] { 0xE8, 0x75, 0x00, 0x00, 0x00, 0xE8 }, GetVersion, "TAGES"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -6,9 +6,9 @@ namespace BurnOutSharp.ProtectionType
public class ThreePLock : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
new ContentMatchSet(new List<byte?[]>
{
@@ -27,7 +27,12 @@ namespace BurnOutSharp.ProtectionType
// 0x53, 0x56, 0x57
// }, "3PLock"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}
}

View File

@@ -6,9 +6,9 @@ namespace BurnOutSharp.ProtectionType
public class ThreeTwoOneStudios : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// 3 + (char)0x00 + 1 + 2 + (char)0x00 + 1 + (char)0x00 + S + (char)0x00 + t + (char)0x00 + u + (char)0x00 + d + (char)0x00 + i + (char)0x00 + o + (char)0x00 + s + (char)0x00 + + (char)0x00 + A + (char)0x00 + c + (char)0x00 + t + (char)0x00 + i + (char)0x00 + v + (char)0x00 + a + (char)0x00 + t + (char)0x00 + i + (char)0x00 + o + (char)0x00 + n + (char)0x00
new ContentMatchSet(new byte?[]
@@ -21,7 +21,12 @@ namespace BurnOutSharp.ProtectionType
0x6E, 0x00
}, "321Studios Online Activation"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}
}

View File

@@ -13,9 +13,9 @@ namespace BurnOutSharp.ProtectionType
public class VOBProtectCDDVD : IContentCheck, IPathCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// VOB ProtectCD
new ContentMatchSet(new byte?[]
@@ -30,7 +30,12 @@ namespace BurnOutSharp.ProtectionType
// .vob.pcd
new ContentMatchSet(new byte?[] { 0x2E, 0x76, 0x6F, 0x62, 0x2E, 0x70, 0x63, 0x64 }, "VOB ProtectCD"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -7,9 +7,9 @@ namespace BurnOutSharp.ProtectionType
public class WTMCDProtect : IContentCheck, IPathCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// This string is found in the .imp files associated with this protection.
// WTM76545
@@ -34,7 +34,12 @@ namespace BurnOutSharp.ProtectionType
0x48, 0x61, 0x6E, 0x73, 0x70, 0x65, 0x74, 0x65, 0x72
}, "WTM Protection Viewer"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -12,9 +12,9 @@ namespace BurnOutSharp.ProtectionType
public class XCP : IContentCheck, IPathCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// Found in GO.EXE
// XCP.DAT
@@ -42,7 +42,12 @@ namespace BurnOutSharp.ProtectionType
0x78, 0x63, 0x70, 0x64, 0x72, 0x69, 0x76, 0x65
}, "XCP"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}

View File

@@ -6,14 +6,19 @@ namespace BurnOutSharp.ProtectionType
public class XtremeProtector : IContentCheck
{
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
public List<ContentMatchSet> GetContentMatchSets()
{
var matchers = new List<ContentMatchSet>
return new List<ContentMatchSet>
{
// XPROT
new ContentMatchSet(new byte?[] { 0x58, 0x50, 0x52, 0x4F, 0x54, 0x20, 0x20, 0x20 }, "Xtreme-Protector"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false)
{
var matchers = GetContentMatchSets();
return MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);
}
}