Files
BinaryObjectScanner/BurnOutSharp/ProtectionType/SmartE.cs

71 lines
2.5 KiB
C#
Raw Normal View History

using System.Collections.Concurrent;
using System.Collections.Generic;
2021-04-01 11:20:13 -07:00
using System.IO;
2022-05-01 17:41:50 -07:00
using BurnOutSharp.Interfaces;
2021-03-21 15:34:19 -07:00
using BurnOutSharp.Matching;
using BurnOutSharp.Wrappers;
namespace BurnOutSharp.ProtectionType
{
2022-05-01 17:23:00 -07:00
public class SmartE : IPathCheck, IPortableExecutableCheck
{
/// <inheritdoc/>
2022-05-01 17:17:15 -07:00
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
2021-09-03 13:26:52 -07:00
{
// Get the sections from the executable, if possible
var sections = pex?.SectionTable;
if (sections == null)
return null;
2022-12-05 10:21:15 -08:00
// Get the last section
2022-12-08 17:18:09 -08:00
var lastSetionData = pex.GetSectionData(sections.Length - 1);
2022-12-05 10:21:15 -08:00
if (lastSetionData != null)
{
var matchers = new List<ContentMatchSet>
{
// BITARTS
new ContentMatchSet(
new ContentMatch(
new byte?[] { 0x42, 0x49, 0x54, 0x41, 0x52, 0x54, 0x53 },
start: 18319,
end: 18320),
"SmartE"),
};
string match = MatchUtil.GetFirstMatch(file, lastSetionData, matchers, includeDebug);
if (!string.IsNullOrWhiteSpace(match))
return match;
}
2021-09-03 13:26:52 -07:00
return null;
}
2021-02-26 00:32:09 -08:00
/// <inheritdoc/>
public ConcurrentQueue<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
var matchers = new List<PathMatchSet>
{
2021-09-03 13:26:52 -07:00
new PathMatchSet(new List<PathMatch>
{
new PathMatch($"{Path.DirectorySeparatorChar}00001.TMP", useEndsWith: true),
new PathMatch($"{Path.DirectorySeparatorChar}00002.TMP", useEndsWith: true)
}, "SmartE"),
};
return MatchUtil.GetAllMatches(files, matchers, any: true);
2021-03-19 15:41:49 -07:00
}
/// <inheritdoc/>
public string CheckFilePath(string path)
{
var matchers = new List<PathMatchSet>
{
2021-04-01 11:20:13 -07:00
new PathMatchSet(new PathMatch($"{Path.DirectorySeparatorChar}00001.TMP", useEndsWith: true), "SmartE"),
new PathMatchSet(new PathMatch($"{Path.DirectorySeparatorChar}00002.TMP", useEndsWith: true), "SmartE"),
};
return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
}
}