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 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 CDLock : IPathCheck, IPortableExecutableCheck
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2021-08-29 21:49:14 -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-08-29 21:49:14 -07:00
|
|
|
|
// Get the sections from the executable, if possible
|
|
|
|
|
|
var sections = pex?.SectionTable;
|
|
|
|
|
|
if (sections == null)
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
// Get the .data section, if it exists
|
2021-09-11 16:47:25 -07:00
|
|
|
|
if (pex.DataSectionRaw != null)
|
2021-07-17 23:40:16 -07:00
|
|
|
|
{
|
2021-08-29 21:49:14 -07:00
|
|
|
|
var matchers = new List<ContentMatchSet>
|
2021-07-17 23:40:16 -07:00
|
|
|
|
{
|
2021-08-29 21:49:14 -07:00
|
|
|
|
// 2 + (char)0xF2 + (char)0x02 + (char)0x82 + (char)0xC3 + (char)0xBC + (char)0x0B + $ + (char)0x99 + (char)0xAD + 'C + (char)0xE4 + (char)0x9D + st + (char)0x99 + (char)0xFA + 2$ + (char)0x9D + )4 + (char)0xFF + t
|
2021-09-11 16:47:25 -07:00
|
|
|
|
new ContentMatchSet(new byte?[]
|
|
|
|
|
|
{
|
|
|
|
|
|
0x32, 0xF2, 0x02, 0x82, 0xC3, 0xBC, 0x0B, 0x24,
|
|
|
|
|
|
0x99, 0xAD, 0x27, 0x43, 0xE4, 0x9D, 0x73, 0x74,
|
|
|
|
|
|
0x99, 0xFA, 0x32, 0x24, 0x9D, 0x29, 0x34, 0xFF,
|
|
|
|
|
|
0x74
|
|
|
|
|
|
}, "CD-Lock"),
|
2021-08-29 21:49:14 -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-08-29 21:49:14 -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-22 23:02:01 -07:00
|
|
|
|
var matchers = new List<PathMatchSet>
|
|
|
|
|
|
{
|
|
|
|
|
|
new PathMatchSet(new PathMatch(".AFP", useEndsWith: true), "CD-Lock"),
|
|
|
|
|
|
};
|
2019-09-27 23:52:24 -07:00
|
|
|
|
|
2021-03-23 13:35:12 -07:00
|
|
|
|
return MatchUtil.GetAllMatches(files, matchers, any: true);
|
2019-09-27 23:52:24 -07:00
|
|
|
|
}
|
2021-03-19 15:41:49 -07:00
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public string CheckFilePath(string path)
|
|
|
|
|
|
{
|
2021-03-22 23:02:01 -07:00
|
|
|
|
var matchers = new List<PathMatchSet>
|
|
|
|
|
|
{
|
|
|
|
|
|
new PathMatchSet(new PathMatch(".AFP", useEndsWith: true), "CD-Lock"),
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return MatchUtil.GetFirstMatch(path, matchers, any: true);
|
2021-03-19 15:41:49 -07:00
|
|
|
|
}
|
2019-09-27 23:52:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|