Files
BinaryObjectScanner/BurnOutSharp/ProtectionType/SafeLock.cs

60 lines
2.2 KiB
C#
Raw Normal View History

using System.Collections.Concurrent;
using System.Collections.Generic;
2021-09-10 15:32:37 -07:00
using System.Linq;
using BurnOutSharp.ExecutableType.Microsoft;
2021-03-21 22:19:38 -07:00
using BurnOutSharp.Matching;
namespace BurnOutSharp.ProtectionType
{
2021-02-26 01:26:49 -08:00
public class SafeLock : IContentCheck, IPathCheck
{
2021-02-26 01:26:49 -08:00
/// <inheritdoc/>
2021-09-10 15:32:37 -07:00
private List<ContentMatchSet> GetContentMatchSets()
{
2021-09-02 16:09:29 -07:00
// TODO: Obtain a sample to find where this string is in a typical executable
return new List<ContentMatchSet>
{
// SafeLock
new ContentMatchSet(new byte?[] { 0x53, 0x61, 0x66, 0x65, 0x4C, 0x6F, 0x63, 0x6B }, "SafeLock"),
};
}
/// <inheritdoc/>
public string CheckContents(string file, byte[] fileContent, bool includeDebug, PortableExecutable pex, NewExecutable nex)
2021-09-10 15:32:37 -07:00
{
var contentMatchSets = GetContentMatchSets();
if (contentMatchSets != null && contentMatchSets.Any())
return MatchUtil.GetFirstMatch(file, fileContent, contentMatchSets, includeDebug);
return null;
}
2021-02-26 00:32:09 -08:00
/// <inheritdoc/>
public ConcurrentQueue<string> CheckDirectoryPath(string path, IEnumerable<string> files)
{
2021-03-19 15:41:49 -07:00
// TODO: Verify if these are OR or AND
var matchers = new List<PathMatchSet>
{
new PathMatchSet(new PathMatch("SafeLock.dat", useEndsWith: true), "SafeLock"),
new PathMatchSet(new PathMatch("SafeLock.001", useEndsWith: true), "SafeLock"),
new PathMatchSet(new PathMatch("SafeLock.128", useEndsWith: true), "SafeLock"),
};
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>
{
new PathMatchSet(new PathMatch("SafeLock.dat", useEndsWith: true), "SafeLock"),
new PathMatchSet(new PathMatch("SafeLock.001", useEndsWith: true), "SafeLock"),
new PathMatchSet(new PathMatch("SafeLock.128", useEndsWith: true), "SafeLock"),
};
return MatchUtil.GetFirstMatch(path, matchers, any: true);
}
}
}