Combine CD-Cops and DVD-Cops

This commit is contained in:
Matt Nadareski
2021-09-11 16:49:54 -07:00
parent 214e8d41c7
commit 7195ed3587
3 changed files with 18 additions and 50 deletions

View File

@@ -93,7 +93,7 @@ namespace BurnOutSharp.ExecutableType.Microsoft
//
// Here is a list of non-standard sections whose contents are read by various protections:
// - CODE *1 protection WTM CD Protect
// - .grand 2 protections? CD-Cops / DVD-Cops(?)
// - .grand *1 protection CD-Cops / DVD-Cops
// - .init *1 protection SolidShield
// - .NOS0 *1 protection UPX (NOS Variant)
// - .NOS1 *1 protection UPX (NOS Variant)

View File

@@ -8,8 +8,7 @@ using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
{
// TODO: Can this be combined with DVD-Cops?
public class CDCops : IContentCheck, IPathCheck
public class CDDVDCops : IContentCheck, IPathCheck
{
/// <inheritdoc/>
private List<ContentMatchSet> GetContentMatchSets()
@@ -23,6 +22,13 @@ namespace BurnOutSharp.ProtectionType
0x43, 0x44, 0x2D, 0x43, 0x6F, 0x70, 0x73, 0x2C,
0x20, 0x20, 0x76, 0x65, 0x72, 0x2E, 0x20
}, GetVersion, "CD-Cops"),
// DVD-Cops, ver.
new ContentMatchSet(new byte?[]
{
0x44, 0x56, 0x44, 0x2D, 0x43, 0x6F, 0x70, 0x73,
0x2C, 0x20, 0x20, 0x76, 0x65, 0x72, 0x2E, 0x20
}, GetVersion, "DVD-Cops"),
};
}
@@ -50,6 +56,15 @@ namespace BurnOutSharp.ProtectionType
0x20, 0x20, 0x76, 0x65, 0x72, 0x2E, 0x20
}, start: sectionAddr, end: sectionEnd),
GetVersion, "CD-Cops"),
// DVD-Cops, ver.
new ContentMatchSet(
new ContentMatch(new byte?[]
{
0x44, 0x56, 0x44, 0x2D, 0x43, 0x6F, 0x70, 0x73,
0x2C, 0x20, 0x20, 0x76, 0x65, 0x72, 0x2E, 0x20
}, start: sectionAddr, end: sectionEnd),
GetVersion, "DVD-Cops"),
};
string match = MatchUtil.GetFirstMatch(file, fileContent, matchers, includeDebug);

View File

@@ -1,47 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using BurnOutSharp.ExecutableType.Microsoft;
using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
{
// TODO: Can this be combined with CD-Cops?
public class DVDCops : IContentCheck
{
/// <inheritdoc/>
private List<ContentMatchSet> GetContentMatchSets()
{
// TODO: Obtain a sample to find where this string is in a typical executable
return new List<ContentMatchSet>
{
// DVD-Cops, ver.
new ContentMatchSet(new byte?[]
{
0x44, 0x56, 0x44, 0x2D, 0x43, 0x6F, 0x70, 0x73,
0x2C, 0x20, 0x20, 0x76, 0x65, 0x72, 0x2E, 0x20
}, GetVersion, "DVD-Cops"),
};
}
/// TODO: Does this look for the `.grand` section like CD-Cops?
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug, PortableExecutable pex, NewExecutable nex)
{
var contentMatchSets = GetContentMatchSets();
if (contentMatchSets != null && contentMatchSets.Any())
return MatchUtil.GetFirstMatch(file, fileContent, contentMatchSets, includeDebug);
return null;
}
public static string GetVersion(string file, byte[] fileContent, List<int> positions)
{
char[] version = new ArraySegment<byte>(fileContent, positions[0] + 15, 4).Select(b => (char)b).ToArray();
if (version[0] == 0x00)
return string.Empty;
return new string(version);
}
}
}