2021-07-18 09:44:23 -07:00
|
|
|
|
using System.Collections.Concurrent;
|
|
|
|
|
|
using System.Collections.Generic;
|
2022-03-14 10:40:44 -07:00
|
|
|
|
using BurnOutSharp.ExecutableType.Microsoft.PE;
|
2022-05-01 17:41:50 -07:00
|
|
|
|
using BurnOutSharp.Interfaces;
|
2021-03-21 22:19:38 -07:00
|
|
|
|
using BurnOutSharp.Matching;
|
2019-09-27 23:52:24 -07:00
|
|
|
|
|
|
|
|
|
|
namespace BurnOutSharp.ProtectionType
|
|
|
|
|
|
{
|
2022-05-01 17:23:00 -07:00
|
|
|
|
public class MediaMaxCD3 : IPathCheck, IPortableExecutableCheck
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2021-09-01 14:06:19 -07:00
|
|
|
|
/// <inheritdoc/>
|
2022-05-01 17:17:15 -07:00
|
|
|
|
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
|
2021-03-23 09:52:09 -07:00
|
|
|
|
{
|
2021-09-01 14:06:19 -07:00
|
|
|
|
// Get the sections from the executable, if possible
|
|
|
|
|
|
var sections = pex?.SectionTable;
|
|
|
|
|
|
if (sections == null)
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
2022-04-02 15:54:51 -07:00
|
|
|
|
var resource = pex.FindResource(dataContains: "Cd3Ctl");
|
2021-09-10 22:02:57 -07:00
|
|
|
|
if (resource != null)
|
|
|
|
|
|
return $"MediaMax CD-3";
|
|
|
|
|
|
|
2021-09-11 16:47:25 -07:00
|
|
|
|
// Get the .data section, if it exists
|
|
|
|
|
|
if (pex.DataSectionRaw != null)
|
2021-07-17 23:40:16 -07:00
|
|
|
|
{
|
2021-09-01 14:06:19 -07:00
|
|
|
|
var matchers = new List<ContentMatchSet>
|
|
|
|
|
|
{
|
2021-09-11 16:47:25 -07:00
|
|
|
|
// CD3 Launch Error
|
|
|
|
|
|
new ContentMatchSet(new byte?[]
|
|
|
|
|
|
{
|
|
|
|
|
|
0x43, 0x44, 0x33, 0x20, 0x4C, 0x61, 0x75, 0x6E,
|
|
|
|
|
|
0x63, 0x68, 0x20, 0x45, 0x72, 0x72, 0x6F, 0x72
|
|
|
|
|
|
}, "MediaMax CD-3"),
|
2021-09-01 14:06:19 -07:00
|
|
|
|
};
|
2021-07-17 23:40:16 -07:00
|
|
|
|
|
2021-09-11 16:47:25 -07:00
|
|
|
|
string match = MatchUtil.GetFirstMatch(file, pex.DataSectionRaw, matchers, includeDebug);
|
2021-09-01 14:06:19 -07:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(match))
|
|
|
|
|
|
return match;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-09-11 16:47:25 -07:00
|
|
|
|
// Get the .rdata section, if it exists
|
|
|
|
|
|
if (pex.ResourceDataSectionRaw != null)
|
2021-09-01 14:06:19 -07:00
|
|
|
|
{
|
|
|
|
|
|
var matchers = new List<ContentMatchSet>
|
|
|
|
|
|
{
|
2021-09-11 16:47:25 -07:00
|
|
|
|
// DllInstallSbcp
|
|
|
|
|
|
new ContentMatchSet(new byte?[]
|
|
|
|
|
|
{
|
|
|
|
|
|
0x44, 0x6C, 0x6C, 0x49, 0x6E, 0x73, 0x74, 0x61,
|
|
|
|
|
|
0x6C, 0x6C, 0x53, 0x62, 0x63, 0x70
|
|
|
|
|
|
}, "MediaMax CD-3"),
|
2021-09-01 14:06:19 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
2021-09-11 16:47:25 -07:00
|
|
|
|
string match = MatchUtil.GetFirstMatch(file, pex.ResourceDataSectionRaw, matchers, includeDebug);
|
2021-09-01 14:06:19 -07:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(match))
|
|
|
|
|
|
return match;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2020-11-03 14:41:05 -08:00
|
|
|
|
|
2021-02-26 00:32:09 -08:00
|
|
|
|
/// <inheritdoc/>
|
2021-07-18 09:44:23 -07:00
|
|
|
|
public ConcurrentQueue<string> CheckDirectoryPath(string path, IEnumerable<string> files)
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2021-03-23 09:52:09 -07:00
|
|
|
|
var matchers = new List<PathMatchSet>
|
|
|
|
|
|
{
|
|
|
|
|
|
new PathMatchSet(new PathMatch("LaunchCd.exe", useEndsWith: true), "MediaMax CD-3"),
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2021-03-23 13:35:12 -07:00
|
|
|
|
return MatchUtil.GetAllMatches(files, matchers, any: true);
|
2021-03-19 15:41:49 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public string CheckFilePath(string path)
|
|
|
|
|
|
{
|
2021-03-23 09:52:09 -07:00
|
|
|
|
var matchers = new List<PathMatchSet>
|
|
|
|
|
|
{
|
|
|
|
|
|
new PathMatchSet(new PathMatch("LaunchCd.exe", useEndsWith: true), "MediaMax CD-3"),
|
|
|
|
|
|
};
|
2019-09-27 23:52:24 -07:00
|
|
|
|
|
2021-03-23 09:52:09 -07:00
|
|
|
|
return MatchUtil.GetFirstMatch(path, matchers, any: true);
|
2019-09-27 23:52:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|