2021-07-18 09:44:23 -07:00
|
|
|
|
using System.Collections.Concurrent;
|
|
|
|
|
|
using System.Collections.Generic;
|
2022-05-13 21:03:13 -07:00
|
|
|
|
using System.IO;
|
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 15:34:19 -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 WTMCDProtect : IPathCheck, IPortableExecutableCheck
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2021-09-08 00:51:25 -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-08 00:51:25 -07:00
|
|
|
|
// Get the sections from the executable, if possible
|
|
|
|
|
|
var sections = pex?.SectionTable;
|
|
|
|
|
|
if (sections == null)
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
2022-04-02 16:12:23 -07:00
|
|
|
|
string name = pex.FileDescription;
|
2022-03-14 15:00:20 -07:00
|
|
|
|
if (!string.IsNullOrEmpty(name) && name.Contains("Copy Protection Viewer"))
|
|
|
|
|
|
return "WTM Protection Viewer";
|
|
|
|
|
|
|
2022-04-02 16:12:23 -07:00
|
|
|
|
name = pex.ProductName;
|
2022-03-14 15:00:20 -07:00
|
|
|
|
if (!string.IsNullOrEmpty(name) && name.Contains("WTM Copy Protection Viewer"))
|
|
|
|
|
|
return "WTM Protection Viewer";
|
|
|
|
|
|
|
2021-09-08 00:51:25 -07:00
|
|
|
|
// Get the CODE section, if it exists
|
2022-03-14 23:01:06 -07:00
|
|
|
|
var codeSectionRaw = pex.ReadRawSection("CODE", first: true);
|
2021-09-11 21:03:36 -07:00
|
|
|
|
if (codeSectionRaw != null)
|
2021-07-17 23:40:16 -07:00
|
|
|
|
{
|
2021-09-08 00:51:25 -07:00
|
|
|
|
var matchers = new List<ContentMatchSet>
|
|
|
|
|
|
{
|
|
|
|
|
|
// wtmdum.imp
|
2021-09-11 21:03:36 -07:00
|
|
|
|
new ContentMatchSet(new byte?[]
|
|
|
|
|
|
{
|
|
|
|
|
|
0x77, 0x74, 0x6D, 0x64, 0x75, 0x6D, 0x2E, 0x69,
|
|
|
|
|
|
0x6D, 0x70
|
|
|
|
|
|
}, "WTM CD Protect"),
|
2021-09-08 00:51:25 -07:00
|
|
|
|
};
|
2021-06-30 10:36:02 -06:00
|
|
|
|
|
2021-09-11 21:03:36 -07:00
|
|
|
|
string match = MatchUtil.GetFirstMatch(file, codeSectionRaw, matchers, includeDebug);
|
2021-09-08 00:51:25 -07:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(match))
|
|
|
|
|
|
return match;
|
|
|
|
|
|
}
|
2021-06-30 10:36:02 -06:00
|
|
|
|
|
2021-09-08 00:51:25 -07:00
|
|
|
|
// Get the .text section, if it exists
|
2021-09-11 16:47:25 -07:00
|
|
|
|
if (pex.TextSectionRaw != null)
|
2021-09-08 00:51:25 -07:00
|
|
|
|
{
|
|
|
|
|
|
var matchers = new List<ContentMatchSet>
|
2021-07-17 23:40:16 -07:00
|
|
|
|
{
|
2021-09-08 00:51:25 -07:00
|
|
|
|
// WTM DIGITAL Photo Protect
|
2021-09-11 16:47:25 -07:00
|
|
|
|
new ContentMatchSet(new byte?[]
|
|
|
|
|
|
{
|
|
|
|
|
|
0x57, 0x54, 0x4D, 0x20, 0x44, 0x49, 0x47, 0x49,
|
|
|
|
|
|
0x54, 0x41, 0x4C, 0x20, 0x50, 0x68, 0x6F, 0x74,
|
|
|
|
|
|
0x6F, 0x20, 0x50, 0x72, 0x6F, 0x74, 0x65, 0x63,
|
|
|
|
|
|
0x74
|
|
|
|
|
|
}, "WTM Protection Viewer"),
|
2021-03-23 09:52:09 -07:00
|
|
|
|
|
2021-09-08 00:51:25 -07:00
|
|
|
|
// WTM Copy Protection Viewer
|
2021-09-11 16:47:25 -07:00
|
|
|
|
new ContentMatchSet(new byte?[]
|
|
|
|
|
|
{
|
|
|
|
|
|
0x57, 0x54, 0x4D, 0x20, 0x43, 0x6F, 0x70, 0x79,
|
|
|
|
|
|
0x20, 0x50, 0x72, 0x6F, 0x74, 0x65, 0x63, 0x74,
|
|
|
|
|
|
0x69, 0x6F, 0x6E, 0x20, 0x56, 0x69, 0x65, 0x77,
|
|
|
|
|
|
0x65, 0x72
|
|
|
|
|
|
}, "WTM Protection Viewer"),
|
2021-09-08 00:51:25 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
2021-09-11 16:47:25 -07:00
|
|
|
|
string match = MatchUtil.GetFirstMatch(file, pex.TextSectionRaw, matchers, includeDebug);
|
2021-09-08 00:51:25 -07:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(match))
|
|
|
|
|
|
return match;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2019-09-27 23:52:24 -07: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 10:36:14 -07:00
|
|
|
|
var matchers = new List<PathMatchSet>
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2021-08-16 22:58:36 -06:00
|
|
|
|
new PathMatchSet(new List<PathMatch>
|
|
|
|
|
|
{
|
2022-05-13 21:03:13 -07:00
|
|
|
|
new PathMatch($"{Path.DirectorySeparatorChar}wtmfiles.dat", useEndsWith: true),
|
|
|
|
|
|
new PathMatch($"{Path.DirectorySeparatorChar}Viewer.exe", useEndsWith: true),
|
2021-08-16 22:58:36 -06:00
|
|
|
|
}, "WTM Protection Viewer"),
|
2021-03-23 10:36:14 -07:00
|
|
|
|
};
|
2021-03-19 15:41:49 -07:00
|
|
|
|
|
2021-06-30 10:36:02 -06:00
|
|
|
|
return MatchUtil.GetAllMatches(files, matchers, any: false);
|
2021-03-19 15:41:49 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public string CheckFilePath(string path)
|
|
|
|
|
|
{
|
2022-03-02 08:56:26 -08:00
|
|
|
|
// TODO: Add ImageX.imp as a wildcard, if possible
|
2021-03-23 10:36:14 -07:00
|
|
|
|
var matchers = new List<PathMatchSet>
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2022-05-13 21:03:13 -07:00
|
|
|
|
new PathMatchSet(new PathMatch($"{Path.DirectorySeparatorChar}Image.imp", useEndsWith: true), "WTM CD Protect"),
|
|
|
|
|
|
new PathMatchSet(new PathMatch($"{Path.DirectorySeparatorChar}Image1.imp", useEndsWith: true), "WTM CD Protect"),
|
|
|
|
|
|
new PathMatchSet(new PathMatch($"{Path.DirectorySeparatorChar}imp.dat", useEndsWith: true), "WTM CD Protect"),
|
|
|
|
|
|
new PathMatchSet(new PathMatch($"{Path.DirectorySeparatorChar}wtmfiles.dat", useEndsWith: true), "WTM Protection Viewer"),
|
2021-03-23 10:36:14 -07:00
|
|
|
|
};
|
2019-09-27 23:52:24 -07:00
|
|
|
|
|
2021-03-23 10:36:14 -07:00
|
|
|
|
return MatchUtil.GetFirstMatch(path, matchers, any: true);
|
2019-09-27 23:52:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|