mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-09-24 07:44:55 +00:00
Use framework for more content protections
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using BurnOutSharp.Matching;
|
||||
|
||||
namespace BurnOutSharp.ProtectionType
|
||||
{
|
||||
@@ -12,68 +13,80 @@ namespace BurnOutSharp.ProtectionType
|
||||
/// <inheritdoc/>
|
||||
public string CheckContents(string file, byte[] fileContent, bool includePosition = false)
|
||||
{
|
||||
// "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"
|
||||
byte?[] check = new byte?[] { 0x44, 0x00, 0x56, 0x00, 0x4D, 0x00, 0x20, 0x00, 0x4C, 0x00, 0x69, 0x00, 0x62, 0x00, 0x72, 0x00, 0x61, 0x00, 0x72, 0x00, 0x79 };
|
||||
if (fileContent.FirstPosition(check, out int position))
|
||||
return $"SolidShield {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty);
|
||||
|
||||
// "S" + (char)0x00 + "o" + (char)0x00 + "l" + (char)0x00 + "i" + (char)0x00 + "d" + (char)0x00 + "s" + (char)0x00 + "h" + (char)0x00 + "i" + (char)0x00 + "e" + (char)0x00 + "l" + (char)0x00 + "d" + (char)0x00 + " " + (char)0x00 + "L" + (char)0x00 + "i" + (char)0x00 + "b" + (char)0x00 + "r" + (char)0x00 + "a" + (char)0x00 + "r" + (char)0x00 + "y"
|
||||
check = new byte?[] { 0x53, 0x00, 0x6F, 0x00, 0x6C, 0x00, 0x69, 0x00, 0x64, 0x00, 0x73, 0x00, 0x68, 0x00, 0x69, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x64, 0x00, 0x20, 0x00, 0x4C, 0x00, 0x69, 0x00, 0x62, 0x00, 0x72, 0x00, 0x61, 0x00, 0x72, 0x00, 0x79 };
|
||||
if (fileContent.FirstPosition(check, out position))
|
||||
var matchers = new List<Matcher>
|
||||
{
|
||||
string companyName = string.Empty;
|
||||
if (file != null)
|
||||
companyName = FileVersionInfo.GetVersionInfo(file).CompanyName.ToLower();
|
||||
// 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 Matcher(new byte?[]
|
||||
{
|
||||
0x44, 0x00, 0x56, 0x00, 0x4D, 0x00, 0x20, 0x00,
|
||||
0x4C, 0x00, 0x69, 0x00, 0x62, 0x00, 0x72, 0x00,
|
||||
0x61, 0x00, 0x72, 0x00, 0x79, 0x00
|
||||
}, Utilities.GetFileVersion, "SolidShield"),
|
||||
|
||||
if (companyName.Contains("solidshield") || companyName.Contains("tages"))
|
||||
return $"SolidShield Core.dll {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty);
|
||||
}
|
||||
// S + (char)0x00 + o + (char)0x00 + l + (char)0x00 + i + (char)0x00 + d + (char)0x00 + s + (char)0x00 + h + (char)0x00 + i + (char)0x00 + e + (char)0x00 + l + (char)0x00 + d + (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 Matcher(new byte?[]
|
||||
{
|
||||
0x53, 0x00, 0x6F, 0x00, 0x6C, 0x00, 0x69, 0x00,
|
||||
0x64, 0x00, 0x73, 0x00, 0x68, 0x00, 0x69, 0x00,
|
||||
0x65, 0x00, 0x6C, 0x00, 0x64, 0x00, 0x20, 0x00,
|
||||
0x4C, 0x00, 0x69, 0x00, 0x62, 0x00, 0x72, 0x00,
|
||||
0x61, 0x00, 0x72, 0x00, 0x79, 0x00
|
||||
}, GetFileVersion, "SolidShield Core.dll"),
|
||||
|
||||
// "S" + (char)0x00 + "o" + (char)0x00 + "l" + (char)0x00 + "i" + (char)0x00 + "d" + (char)0x00 + "s" + (char)0x00 + "h" + (char)0x00 + "i" + (char)0x00 + "e" + (char)0x00 + "l" + (char)0x00 + "d" + (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 + " " + (char)0x00 + "L" + (char)0x00 + "i" + (char)0x00 + "b" + (char)0x00 + "r" + (char)0x00 + "a" + (char)0x00 + "r" + (char)0x00 + "y"
|
||||
check = new byte?[] { 0x53, 0x00, 0x6F, 0x00, 0x6C, 0x00, 0x69, 0x00, 0x64, 0x00, 0x73, 0x00, 0x68, 0x00, 0x69, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x64, 0x00, 0x20, 0x00, 0x41, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00, 0x76, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x20, 0x00, 0x4C, 0x00, 0x69, 0x00, 0x62, 0x00, 0x72, 0x00, 0x61, 0x00, 0x72, 0x00, 0x79 };
|
||||
if (fileContent.FirstPosition(check, out position))
|
||||
{
|
||||
string companyName = string.Empty;
|
||||
if (file != null)
|
||||
companyName = FileVersionInfo.GetVersionInfo(file).CompanyName.ToLower();
|
||||
// S + (char)0x00 + o + (char)0x00 + l + (char)0x00 + i + (char)0x00 + d + (char)0x00 + s + (char)0x00 + h + (char)0x00 + i + (char)0x00 + e + (char)0x00 + l + (char)0x00 + d + (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 + + (char)0x00 + L + (char)0x00 + i + (char)0x00 + b + (char)0x00 + r + (char)0x00 + a + (char)0x00 + r + (char)0x00 + y + (char)0x00
|
||||
new Matcher(new byte?[]
|
||||
{
|
||||
0x53, 0x00, 0x6F, 0x00, 0x6C, 0x00, 0x69, 0x00,
|
||||
0x64, 0x00, 0x73, 0x00, 0x68, 0x00, 0x69, 0x00,
|
||||
0x65, 0x00, 0x6C, 0x00, 0x64, 0x00, 0x20, 0x00,
|
||||
0x41, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00,
|
||||
0x76, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00,
|
||||
0x6F, 0x00, 0x6E, 0x00, 0x20, 0x00, 0x4C, 0x00,
|
||||
0x69, 0x00, 0x62, 0x00, 0x72, 0x00, 0x61, 0x00,
|
||||
0x72, 0x00, 0x79, 0x00
|
||||
}, GetFileVersion, "SolidShield Core.dll"),
|
||||
|
||||
if (companyName.Contains("solidshield") || companyName.Contains("tages"))
|
||||
return $"SolidShield Core.dll {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty);
|
||||
}
|
||||
// (char)0xEF + (char)0xBE + (char)0xAD + (char)0xDE
|
||||
new Matcher(new byte?[] { 0xEF, 0xBE, 0xAD, 0xDE }, GetExeWrapperVersion, "SolidShield"),
|
||||
|
||||
// (char)0xEF + (char)0xBE + (char)0xAD + (char)0xDE
|
||||
check = new byte?[] { };
|
||||
if (fileContent.FirstPosition(check, out position))
|
||||
{
|
||||
var id1 = new ArraySegment<byte>(fileContent, position + 5, 3);
|
||||
var id2 = new ArraySegment<byte>(fileContent, position + 16, 4);
|
||||
// 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 + + (char)0x00 + M + (char)0x00 + a + (char)0x00 + n + (char)0x00 + a + (char)0x00 + g + (char)0x00 + e + (char)0x00 + r + (char)0x00
|
||||
new Matcher(new byte?[]
|
||||
{
|
||||
0x41, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00,
|
||||
0x76, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00,
|
||||
0x6f, 0x00, 0x6e, 0x00, 0x20, 0x00, 0x4d, 0x00,
|
||||
0x61, 0x00, 0x6e, 0x00, 0x61, 0x00, 0x67, 0x00,
|
||||
0x65, 0x00, 0x72, 0x00
|
||||
}, GetFileVersion, "SolidShield Activation Manager Module"),
|
||||
|
||||
if (id1.SequenceEqual(new byte[] { 0x00, 0x00, 0x00 }) && id2.SequenceEqual(new byte[] { 0x00, 0x10, 0x00, 0x00 }))
|
||||
return "SolidShield 1 (SolidShield EXE Wrapper)" + (includePosition ? $" (Index {position})" : string.Empty);
|
||||
else if (id1.SequenceEqual(new byte[] { 0x2E, 0x6F, 0x26 }) && id2.SequenceEqual(new byte[] { 0xDB, 0xC5, 0x20, 0x3A, 0xB9 }))
|
||||
return "SolidShield 2 (SolidShield v2 EXE Wrapper)" + (includePosition ? $" (Index {position})" : string.Empty); // TODO: Verify against other SolidShield 2 discs
|
||||
}
|
||||
// dvm.dll
|
||||
new Matcher(new byte?[] { 0x64, 0x76, 0x6D, 0x2E, 0x64, 0x6C, 0x6C }, "SolidShield EXE Wrapper"),
|
||||
|
||||
// "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 + " " + (char)0x00 + "M" + (char)0x00 + "a" + (char)0x00 + "n" + (char)0x00 + "a" + (char)0x00 + "g" + (char)0x00 + "e" + (char)0x00 + "r"
|
||||
check = new byte?[] { 0x41, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00, 0x76, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x6e, 0x00, 0x20, 0x00, 0x4d, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x61, 0x00, 0x67, 0x00, 0x65, 0x00, 0x72 };
|
||||
if (fileContent.FirstPosition(check, out position))
|
||||
{
|
||||
string companyName = string.Empty;
|
||||
if (file != null)
|
||||
companyName = FileVersionInfo.GetVersionInfo(file).CompanyName.ToLower();
|
||||
// Placeholder for the complex SolidShield + TAGES check
|
||||
|
||||
if (companyName.Contains("solidshield") || companyName.Contains("tages"))
|
||||
return $"SolidShield Activation Manager Module {Utilities.GetFileVersion(file)}" + (includePosition ? $" (Index {position})" : string.Empty);
|
||||
}
|
||||
// Solidshield
|
||||
new Matcher(new byte?[]
|
||||
{
|
||||
0x53, 0x6F, 0x6C, 0x69, 0x64, 0x73, 0x68, 0x69,
|
||||
0x65, 0x6C, 0x64
|
||||
}, GetVersion, "SolidShield"),
|
||||
|
||||
// dvm.dll
|
||||
check = new byte?[] { 0x64, 0x76, 0x6D, 0x2E, 0x64, 0x6C, 0x6C };
|
||||
if (fileContent.FirstPosition(check, out position))
|
||||
return $"SolidShield EXE Wrapper" + (includePosition ? $" (Index {position})" : string.Empty);
|
||||
// B + (char)0x00 + I + (char)0x00 + N + (char)0x00 + (char)0x7 + (char)0x00 + I + (char)0x00 + D + (char)0x00 + R + (char)0x00 + _ + (char)0x00 + S + (char)0x00 + G + (char)0x00 + T + (char)0x00
|
||||
new Matcher(new byte?[]
|
||||
{
|
||||
0x42, 0x00, 0x49, 0x00, 0x4E, 0x00, 0x07, 0x00,
|
||||
0x49, 0x00, 0x44, 0x00, 0x52, 0x00, 0x5F, 0x00,
|
||||
0x53, 0x00, 0x47, 0x00, 0x54, 0x00
|
||||
}, "SolidShield"),
|
||||
};
|
||||
|
||||
string firstMatch = MatchUtil.GetFirstContentMatch(file, fileContent, matchers, includePosition);
|
||||
if (firstMatch != null)
|
||||
return firstMatch;
|
||||
|
||||
// (char)0xAD + (char)0xDE + (char)0xFE + (char)0xCA
|
||||
check = new byte?[] { 0xAD, 0xDE, 0xFE, 0xCA };
|
||||
if (fileContent.FirstPosition(check, out position))
|
||||
byte?[] check = new byte?[] { 0xAD, 0xDE, 0xFE, 0xCA };
|
||||
if (fileContent.FirstPosition(check, out int position))
|
||||
{
|
||||
var id1 = new ArraySegment<byte>(fileContent, position + 4, 3);
|
||||
var id2 = new ArraySegment<byte>(fileContent, position + 15, 4);
|
||||
@@ -101,16 +114,6 @@ namespace BurnOutSharp.ProtectionType
|
||||
}
|
||||
}
|
||||
|
||||
// "Solidshield"
|
||||
check = new byte?[] { 0x53, 0x6F, 0x6C, 0x69, 0x64, 0x73, 0x68, 0x69, 0x65, 0x6C, 0x64 };
|
||||
if (fileContent.FirstPosition(check, out position))
|
||||
return $"SolidShield {GetVersion(fileContent, position)}" + (includePosition ? $" (Index {position})" : string.Empty);
|
||||
|
||||
// "B" + (char)0x00 + "I" + (char)0x00 + "N" + (char)0x00 + (char)0x7 + (char)0x00 + "I" + (char)0x00 + "D" + (char)0x00 + "R" + (char)0x00 + "_" + (char)0x00 + "S" + (char)0x00 + "G" + (char)0x00 + "T" + (char)0x0
|
||||
check = new byte?[] { 0x42, 0x00, 0x49, 0x00, 0x4E, 0x00, 0x07, 0x00, 0x49, 0x00, 0x44, 0x00, 0x52, 0x00, 0x5F, 0x00, 0x53, 0x00, 0x47, 0x00, 0x54, 0x00 };
|
||||
if (fileContent.FirstPosition(check, out position))
|
||||
return "SolidShield" + (includePosition ? $" (Index {position})" : string.Empty);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -143,7 +146,32 @@ namespace BurnOutSharp.ProtectionType
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string GetVersion(byte[] fileContent, int position)
|
||||
public static string GetExeWrapperVersion(string file, byte[] fileContent, int position)
|
||||
{
|
||||
var id1 = new ArraySegment<byte>(fileContent, position + 5, 3);
|
||||
var id2 = new ArraySegment<byte>(fileContent, position + 16, 4);
|
||||
|
||||
if (id1.SequenceEqual(new byte[] { 0x00, 0x00, 0x00 }) && id2.SequenceEqual(new byte[] { 0x00, 0x10, 0x00, 0x00 }))
|
||||
return "1 (SolidShield EXE Wrapper)";
|
||||
else if (id1.SequenceEqual(new byte[] { 0x2E, 0x6F, 0x26 }) && id2.SequenceEqual(new byte[] { 0xDB, 0xC5, 0x20, 0x3A, 0xB9 }))
|
||||
return "2 (SolidShield v2 EXE Wrapper)"; // TODO: Verify against other SolidShield 2 discs
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetFileVersion(string file, byte[] fileContent, int position)
|
||||
{
|
||||
string companyName = string.Empty;
|
||||
if (file != null)
|
||||
companyName = FileVersionInfo.GetVersionInfo(file).CompanyName.ToLower();
|
||||
|
||||
if (companyName.Contains("solidshield") || companyName.Contains("tages"))
|
||||
return Utilities.GetFileVersion(file);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetVersion(string file, byte[] fileContent, int position)
|
||||
{
|
||||
int index = position + 12; // Begin reading after "Solidshield"
|
||||
char version = (char)fileContent[index];
|
||||
|
||||
Reference in New Issue
Block a user