2021-03-21 14:30:37 -07:00
|
|
|
|
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;
|
2021-03-21 14:30:37 -07:00
|
|
|
|
|
|
|
|
|
|
namespace BurnOutSharp.ProtectionType
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2021-09-08 10:14:02 -07:00
|
|
|
|
// TODO: Figure out how to get version numbers
|
2022-05-01 17:17:15 -07:00
|
|
|
|
public class ActiveMARK : IContentCheck, IPortableExecutableCheck
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2021-08-25 19:37:32 -07:00
|
|
|
|
/// <inheritdoc/>
|
2022-05-01 17:17:15 -07:00
|
|
|
|
public string CheckContents(string file, byte[] fileContent, bool includeDebug)
|
2022-03-14 11:20:11 -07:00
|
|
|
|
{
|
|
|
|
|
|
// TODO: Obtain a sample to find where this string is in a typical executable
|
|
|
|
|
|
if (includeDebug)
|
|
|
|
|
|
{
|
|
|
|
|
|
var contentMatchSets = new List<ContentMatchSet>
|
|
|
|
|
|
{
|
|
|
|
|
|
// " " + (char)0xC2 + (char)0x16 + (char)0x00 + (char)0xA8 + (char)0xC1 + (char)0x16 + (char)0x00 + (char)0xB8 + (char)0xC1 + (char)0x16 + (char)0x00 + (char)0x86 + (char)0xC8 + (char)0x16 + (char)0x00 + (char)0x9A + (char)0xC1 + (char)0x16 + (char)0x00 + (char)0x10 + (char)0xC2 + (char)0x16 + (char)0x00
|
|
|
|
|
|
new ContentMatchSet(new byte?[]
|
|
|
|
|
|
{
|
|
|
|
|
|
0x20, 0xC2, 0x16, 0x00, 0xA8, 0xC1, 0x16, 0x00,
|
|
|
|
|
|
0xB8, 0xC1, 0x16, 0x00, 0x86, 0xC8, 0x16, 0x00,
|
|
|
|
|
|
0x9A, 0xC1, 0x16, 0x00, 0x10, 0xC2, 0x16, 0x00
|
|
|
|
|
|
}, "ActiveMARK 5"),
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return MatchUtil.GetFirstMatch(file, fileContent, contentMatchSets, includeDebug);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
2022-05-01 17:17:15 -07:00
|
|
|
|
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
|
2021-09-08 10:14:02 -07:00
|
|
|
|
{
|
|
|
|
|
|
// Get the sections from the executable, if possible
|
|
|
|
|
|
var sections = pex?.SectionTable;
|
|
|
|
|
|
if (sections == null)
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
// Get the last .bss section, if it exists
|
2022-03-14 23:01:06 -07:00
|
|
|
|
var bssSectionRaw = pex.ReadRawSection(".bss", first: false);
|
2021-09-11 22:27:52 -07:00
|
|
|
|
if (bssSectionRaw != null)
|
2021-09-08 10:14:02 -07:00
|
|
|
|
{
|
|
|
|
|
|
var matchers = new List<ContentMatchSet>
|
|
|
|
|
|
{
|
|
|
|
|
|
// TMSAMVOF
|
2021-09-11 22:27:52 -07:00
|
|
|
|
new ContentMatchSet(new byte?[] { 0x54, 0x4D, 0x53, 0x41, 0x4D, 0x56, 0x4F, 0x46 }, "ActiveMARK"),
|
2021-09-08 10:14:02 -07:00
|
|
|
|
};
|
|
|
|
|
|
|
2021-09-11 22:27:52 -07:00
|
|
|
|
string match = MatchUtil.GetFirstMatch(file, bssSectionRaw, matchers, includeDebug);
|
2021-09-08 10:14:02 -07:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(match))
|
|
|
|
|
|
return match;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-03-02 08:56:26 -08:00
|
|
|
|
return null;
|
2021-09-08 10:14:02 -07:00
|
|
|
|
}
|
2019-09-27 23:52:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|