mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-02-13 05:35:24 +00:00
200 lines
10 KiB
C#
200 lines
10 KiB
C#
using System.Collections.Generic;
|
|
using BurnOutSharp.ExecutableType.Microsoft.PE;
|
|
using BurnOutSharp.Interfaces;
|
|
using BurnOutSharp.Matching;
|
|
|
|
namespace BurnOutSharp.ProtectionType
|
|
{
|
|
// TODO: Figure out how to get version numbers
|
|
public class ActiveMARK : IContentCheck, IPortableExecutableCheck
|
|
{
|
|
/// <inheritdoc/>
|
|
public string CheckContents(string file, byte[] fileContent, bool includeDebug)
|
|
{
|
|
// 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/>
|
|
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
|
|
{
|
|
// Get the sections from the executable, if possible
|
|
var sections = pex?.SectionTable;
|
|
if (sections == null)
|
|
return null;
|
|
|
|
// Get the entry point data, if it exists
|
|
if (pex.EntryPointRaw != null)
|
|
{
|
|
var matchers = new List<ContentMatchSet>
|
|
{
|
|
new ContentMatchSet(new byte?[]
|
|
{
|
|
0x79, 0x11, 0x7F, 0xAB, 0x9A, 0x4A, 0x83, 0xB5,
|
|
0xC9, 0x6B, 0x1A, 0x48, 0xF9, 0x27, 0xB4, 0x25,
|
|
}, "ActiveMARK"),
|
|
|
|
new ContentMatchSet(new byte?[]
|
|
{
|
|
0x20, 0x2D, 0x2D, 0x4D, 0x50, 0x52, 0x4D, 0x4D,
|
|
0x47, 0x56, 0x41, 0x2D, 0x2D, 0x00, 0x75, 0x73,
|
|
0x65, 0x72, 0x33, 0x32, 0x2E, 0x64, 0x6C, 0x6C,
|
|
0x00, 0x4D, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
|
|
0x42, 0x6F, 0x78, 0x41, 0x00, 0x54, 0x68, 0x69,
|
|
0x73, 0x20, 0x61, 0x70, 0x70, 0x6C, 0x69, 0x63,
|
|
0x61, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x63, 0x61,
|
|
0x6E, 0x6E, 0x6F, 0x74, 0x20, 0x72, 0x75, 0x6E,
|
|
0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x61, 0x6E,
|
|
0x20, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x20,
|
|
0x64, 0x65, 0x62, 0x75, 0x67,
|
|
}, "ActiveMARK 5.x -> Trymedia Systems Inc. (h)"),
|
|
|
|
new ContentMatchSet(new byte?[]
|
|
{
|
|
0x20, 0x2D, 0x2D, 0x4D, 0x50, 0x52, 0x4D, 0x4D,
|
|
0x47, 0x56, 0x41, 0x2D, 0x2D, 0x00, 0x75, 0x73,
|
|
0x65, 0x72, 0x33, 0x32, 0x2E, 0x64, 0x6C, 0x6C,
|
|
0x00, 0x4D, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
|
|
0x42, 0x6F, 0x78, 0x41, 0x00, 0x54, 0x68, 0x69,
|
|
0x73, 0x20, 0x61, 0x70, 0x70, 0x6C, 0x69, 0x63,
|
|
0x61, 0x74, 0x69, 0x6F, 0x6E, 0x20, 0x63, 0x61,
|
|
0x6E, 0x6E, 0x6F, 0x74, 0x20, 0x72, 0x75, 0x6E,
|
|
0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x61, 0x6E,
|
|
0x20, 0x61, 0x63, 0x74, 0x69, 0x76, 0x65, 0x20,
|
|
0x64, 0x65, 0x62, 0x75, 0x67, 0x67, 0x65, 0x72,
|
|
0x20, 0x69, 0x6E, 0x20, 0x6D, 0x65, 0x6D, 0x6F,
|
|
0x72, 0x79, 0x2E, 0x0D, 0x0A, 0x50, 0x6C, 0x65,
|
|
0x61, 0x73, 0x65, 0x20, 0x75, 0x6E, 0x6C, 0x6F,
|
|
0x61, 0x64, 0x20, 0x74, 0x68, 0x65, 0x20, 0x64,
|
|
0x65, 0x62, 0x75, 0x67, 0x67, 0x65, 0x72, 0x20,
|
|
0x61, 0x6E, 0x64, 0x20, 0x72, 0x65, 0x73, 0x74,
|
|
0x61, 0x72, 0x74, 0x20, 0x74, 0x68, 0x65, 0x20,
|
|
0x61, 0x70, 0x70, 0x6C, 0x69, 0x63, 0x61, 0x74,
|
|
0x69, 0x6F, 0x6E, 0x2E, 0x00, 0x57, 0x61, 0x72,
|
|
0x6E, 0x69, 0x6E, 0x67,
|
|
}, "ActiveMARK 5.x -> Trymedia Systems,Inc."),
|
|
|
|
new ContentMatchSet(new byte?[]
|
|
{
|
|
0xBE, 0x48, 0x01, 0x40, 0x00, 0xAD, 0x8B, 0xF8,
|
|
0x95, 0xA5, 0x33, 0xC0, 0x33, 0xC9, 0xAB, 0x48,
|
|
0xAB, 0xF7, 0xD8, 0xB1, 0x04, 0xF3, 0xAB, 0xC1,
|
|
0xE0, 0x0A, 0xB5, 0x1C, 0xF3, 0xAB, 0xAD, 0x50,
|
|
0x97, 0x51, 0xAD, 0x87, 0xF5, 0x58, 0x8D, 0x54,
|
|
0x86, 0x5C, 0xFF, 0xD5, 0x72, 0x5A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96, 0x7C,
|
|
0x07, 0x00, 0x00, 0xFF, 0x55, 0xD0, 0x5B, 0x91,
|
|
0xEB, 0x77, 0x3C, 0x07, 0xB0, 0x07, 0x72, 0x02,
|
|
0xB0, 0x0A, 0x50, 0x87, 0x5E, 0x10, 0x87, 0x5E,
|
|
0x14, 0x89, 0x5E, 0x18, 0x8D, 0x96, 0xC4, 0x0B,
|
|
0x00, 0x00, 0xFF, 0x55, 0xD0, 0x50, 0x48,
|
|
}, "ActiveMARK 5.x -> Trymedia Systems,Inc. (h)"),
|
|
|
|
new ContentMatchSet(new byte?[]
|
|
{
|
|
0x79, 0x07, 0x0F, 0xB7, 0x07, 0x47, 0x50, 0x47,
|
|
0xB9, 0x57, 0x48, 0xF2, 0xAE, 0x55, 0xFF, 0x96,
|
|
0x84, null, 0x00, 0x00, 0x09, 0xC0, 0x74, 0x07,
|
|
0x89, 0x03, 0x83, 0xC3, 0x04, 0xEB, 0xD8, 0xFF,
|
|
0x96, 0x88, null, 0x00, 0x00, 0x61, 0xE9, null,
|
|
null, null, 0xFF,
|
|
}, "ActiveMARK R5.31.1140 -> Trymedia"),
|
|
|
|
new ContentMatchSet(new byte?[]
|
|
{
|
|
0x89, 0x25, null, null, null, null, null, null,
|
|
null, null, 0xEB,
|
|
}, "ActiveMark -> Trymedia Systems Inc."),
|
|
|
|
new ContentMatchSet(new byte?[]
|
|
{
|
|
0x89, 0x25, null, null, null, null, 0x33, 0xED,
|
|
0x55, 0x8B, 0xEC, 0xE8, null, null, null, null,
|
|
0x8B, 0xD0, 0x81, 0xE2, 0xFF, 0x00, 0x00, 0x00,
|
|
0x89, 0x15, null, null, null, null, 0x8B, 0xD0,
|
|
0xC1, 0xEA, 0x08, 0x81, 0xE2, 0xFF, 0x00, 0x00,
|
|
0x00, 0xA3, null, null, null, null, 0xD1, 0xE0,
|
|
0x0F, 0x93, 0xC3, 0x33, 0xC0, 0x8A, 0xC3, 0xA3,
|
|
null, null, null, null, 0x68, 0xFF, 0x00, 0x00,
|
|
0x00, 0xE8, null, null, null, null, 0x6A, 0x00,
|
|
0xE8, null, null, null, null, 0xA3, null, null,
|
|
null, null, 0xBB, null, null, null, null, 0xC7,
|
|
0x03, 0x44, 0x00, 0x00, 0x00,
|
|
}, "ActiveMark -> Trymedia Systems Inc."),
|
|
};
|
|
|
|
string match = MatchUtil.GetFirstMatch(file, pex.EntryPointRaw, matchers, includeDebug);
|
|
if (!string.IsNullOrWhiteSpace(match))
|
|
return match;
|
|
}
|
|
|
|
// Get the overlay data, if it exists
|
|
if (pex.OverlayRaw != null)
|
|
{
|
|
var matchers = new List<ContentMatchSet>
|
|
{
|
|
// (char)0x00 + TMSAMVOH
|
|
new ContentMatchSet(new byte?[] { 0x00, 0x54, 0x4D, 0x53, 0x41, 0x4D, 0x56, 0x4F, 0x48, }, "ActiveMARK"),
|
|
};
|
|
|
|
string match = MatchUtil.GetFirstMatch(file, pex.OverlayRaw, matchers, includeDebug);
|
|
if (!string.IsNullOrWhiteSpace(match))
|
|
return match;
|
|
}
|
|
|
|
// Get the last .bss section, if it exists
|
|
var bssSectionRaw = pex.ReadRawSection(".bss", first: false);
|
|
if (bssSectionRaw != null)
|
|
{
|
|
var matchers = new List<ContentMatchSet>
|
|
{
|
|
// TMSAMVOF
|
|
new ContentMatchSet(new byte?[] { 0x54, 0x4D, 0x53, 0x41, 0x4D, 0x56, 0x4F, 0x46 }, "ActiveMARK"),
|
|
};
|
|
|
|
string match = MatchUtil.GetFirstMatch(file, bssSectionRaw, matchers, includeDebug);
|
|
if (!string.IsNullOrWhiteSpace(match))
|
|
return match;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|