mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-09-22 06:45:03 +00:00
Add CDS content checks, fix XCP over-detection
This commit is contained in:
@@ -78,6 +78,11 @@ namespace BurnOutSharp.FileType
|
||||
if (!string.IsNullOrWhiteSpace(protection))
|
||||
protections.Add(protection);
|
||||
|
||||
// Cactus Data Shield
|
||||
protection = CactusDataShield.CheckContents(fileContent, includePosition);
|
||||
if (!string.IsNullOrWhiteSpace(protection))
|
||||
protections.Add(protection);
|
||||
|
||||
// CD-Cops
|
||||
protection = CDCops.CheckContents(fileContent, includePosition);
|
||||
if (!string.IsNullOrWhiteSpace(protection))
|
||||
|
||||
@@ -10,6 +10,21 @@ namespace BurnOutSharp.ProtectionType
|
||||
{
|
||||
public static string CheckContents(byte[] fileContent, bool includePosition = false)
|
||||
{
|
||||
// DATA.CDS
|
||||
byte[] check = new byte[] { 0x44, 0x41, 0x54, 0x41, 0x2E, 0x43, 0x44, 0x53 };
|
||||
if (fileContent.Contains(check, out int position))
|
||||
return "Cactus Data Shield 200" + (includePosition ? $" (Index {position})" : string.Empty);
|
||||
|
||||
// \*.CDS
|
||||
check = new byte[] { 0x5C, 0x2A, 0x2E, 0x43, 0x44, 0x53 };
|
||||
if (fileContent.Contains(check, out position))
|
||||
return "Cactus Data Shield 200" + (includePosition ? $" (Index {position})" : string.Empty);
|
||||
|
||||
// CDSPlayer
|
||||
check = new byte[] { 0x43, 0x44, 0x53, 0x50, 0x6C, 0x61, 0x79, 0x65, 0x72 };
|
||||
if (fileContent.Contains(check, out position))
|
||||
return "Cactus Data Shield 200" + (includePosition ? $" (Index {position})" : string.Empty);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -17,36 +32,30 @@ namespace BurnOutSharp.ProtectionType
|
||||
{
|
||||
if (isDirectory)
|
||||
{
|
||||
// TODO: Verify if these are OR or AND
|
||||
string appPath = files.FirstOrDefault(f => Path.GetFileName(f).Equals("CDSPlayer.app", StringComparison.OrdinalIgnoreCase));
|
||||
if (!string.IsNullOrWhiteSpace(appPath))
|
||||
{
|
||||
string version = GetVersion(appPath);
|
||||
if (!string.IsNullOrWhiteSpace(version))
|
||||
return $"Cactus Data Shield {version}";
|
||||
}
|
||||
|
||||
if (files.Any(f => Path.GetFileName(f).Equals("yucca.cds", StringComparison.OrdinalIgnoreCase))
|
||||
|| files.Any(f => Path.GetFileName(f).Equals("wmmp.exe", StringComparison.OrdinalIgnoreCase))
|
||||
|| files.Any(f => Path.GetFileName(f).Equals("PJSTREAM.DLL", StringComparison.OrdinalIgnoreCase))
|
||||
|| files.Any(f => Path.GetFileName(f).Equals("CACTUSPJ.exe", StringComparison.OrdinalIgnoreCase)))
|
||||
|| files.Any(f => Path.GetFileName(f).Equals("CACTUSPJ.exe", StringComparison.OrdinalIgnoreCase))
|
||||
|| files.Any(f => Path.GetFileName(f).Equals("CDSPlayer.app", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
string versionPath = files.FirstOrDefault(f => Path.GetFileName(f).Equals("version.txt", StringComparison.OrdinalIgnoreCase));
|
||||
if (!string.IsNullOrWhiteSpace(versionPath))
|
||||
{
|
||||
string version = GetVersion(versionPath);
|
||||
if (!string.IsNullOrWhiteSpace(version))
|
||||
return $"Cactus Data Shield {version}";
|
||||
}
|
||||
|
||||
return "Cactus Data Shield 200";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Path.GetFileName(path).Equals("CDSPlayer.app", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
string version = GetVersion(path);
|
||||
if (!string.IsNullOrWhiteSpace(version))
|
||||
return $"Cactus Data Shield {version}";
|
||||
}
|
||||
|
||||
if (Path.GetFileName(path).Equals("yucca.cds", StringComparison.OrdinalIgnoreCase)
|
||||
|| Path.GetFileName(path).Equals("wmmp.exe", StringComparison.OrdinalIgnoreCase)
|
||||
|| Path.GetFileName(path).Equals("PJSTREAM.DLL", StringComparison.OrdinalIgnoreCase)
|
||||
|| Path.GetFileName(path).Equals("CACTUSPJ.exe", StringComparison.OrdinalIgnoreCase))
|
||||
|| Path.GetFileName(path).Equals("CACTUSPJ.exe", StringComparison.OrdinalIgnoreCase)
|
||||
|| Path.GetFileName(path).Equals("CDSPlayer.app", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "Cactus Data Shield 200";
|
||||
}
|
||||
@@ -62,10 +71,9 @@ namespace BurnOutSharp.ProtectionType
|
||||
|
||||
try
|
||||
{
|
||||
// TODO: Can we do anything with the contents? Take a look at CDSPlayer.app
|
||||
using (var sr = new StreamReader(path, Encoding.Default))
|
||||
{
|
||||
return sr.ReadLine().Substring(3) + "(" + sr.ReadLine() + ")";
|
||||
return $"{sr.ReadLine().Substring(3)} ({sr.ReadLine()})";
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
||||
@@ -32,33 +32,24 @@ namespace BurnOutSharp.ProtectionType
|
||||
{
|
||||
if (isDirectory)
|
||||
{
|
||||
// INI-like file that can be parsed out
|
||||
string versionDatPath = files.FirstOrDefault(f => Path.GetFileName(f).Equals("VERSION.DAT", StringComparison.OrdinalIgnoreCase));
|
||||
if (!string.IsNullOrWhiteSpace(versionDatPath))
|
||||
{
|
||||
string xcpVersion = GetDatVersion(versionDatPath);
|
||||
if (!string.IsNullOrWhiteSpace(xcpVersion))
|
||||
return xcpVersion;
|
||||
}
|
||||
|
||||
// TODO: Verify if these are OR or AND
|
||||
if (files.Any(f => Path.GetFileName(f).Equals("XCP.DAT", StringComparison.OrdinalIgnoreCase))
|
||||
|| files.Any(f => Path.GetFileName(f).Equals("ECDPlayerControl.ocx", StringComparison.OrdinalIgnoreCase))
|
||||
|| files.Any(f => Path.GetFileName(f).Equals("go.exe", StringComparison.OrdinalIgnoreCase))) // Path.Combine("contents", "go.exe")
|
||||
{
|
||||
string versionDatPath = files.FirstOrDefault(f => Path.GetFileName(f).Equals("VERSION.DAT", StringComparison.OrdinalIgnoreCase));
|
||||
if (!string.IsNullOrWhiteSpace(versionDatPath))
|
||||
{
|
||||
string xcpVersion = GetDatVersion(versionDatPath);
|
||||
if (!string.IsNullOrWhiteSpace(xcpVersion))
|
||||
return xcpVersion;
|
||||
}
|
||||
|
||||
return "XCP";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// INI-like file that can be parsed out
|
||||
if (Path.GetFileName(path).Equals("VERSION.DAT", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
string xcpVersion = GetDatVersion(path);
|
||||
if (!string.IsNullOrWhiteSpace(xcpVersion))
|
||||
return xcpVersion;
|
||||
}
|
||||
|
||||
if (Path.GetFileName(path).Equals("XCP.DAT", StringComparison.OrdinalIgnoreCase)
|
||||
|| Path.GetFileName(path).Equals("ECDPlayerControl.ocx", StringComparison.OrdinalIgnoreCase)
|
||||
|| Path.GetFileName(path).Equals("go.exe", StringComparison.OrdinalIgnoreCase))
|
||||
|
||||
Reference in New Issue
Block a user