2021-07-18 09:44:23 -07:00
|
|
|
|
using System.Collections.Concurrent;
|
|
|
|
|
|
using System.Collections.Generic;
|
2021-03-21 22:19:38 -07:00
|
|
|
|
using BurnOutSharp.Matching;
|
2019-09-27 23:52:24 -07:00
|
|
|
|
|
|
|
|
|
|
namespace BurnOutSharp.ProtectionType
|
|
|
|
|
|
{
|
2021-02-26 01:26:49 -08:00
|
|
|
|
public class SafeLock : IContentCheck, IPathCheck
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2021-02-26 01:26:49 -08:00
|
|
|
|
/// <inheritdoc/>
|
2021-08-25 19:37:32 -07:00
|
|
|
|
public List<ContentMatchSet> GetContentMatchSets()
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2021-08-25 19:37:32 -07:00
|
|
|
|
return new List<ContentMatchSet>
|
2021-07-17 23:40:16 -07:00
|
|
|
|
{
|
|
|
|
|
|
// SafeLock
|
|
|
|
|
|
new ContentMatchSet(new byte?[] { 0x53, 0x61, 0x66, 0x65, 0x4C, 0x6F, 0x63, 0x6B }, "SafeLock"),
|
|
|
|
|
|
};
|
2021-08-25 19:37:32 -07:00
|
|
|
|
}
|
2021-07-17 23:40:16 -07:00
|
|
|
|
|
2021-08-25 19:37:32 -07:00
|
|
|
|
/// <inheritdoc/>
|
2021-08-25 20:26:43 -07:00
|
|
|
|
public string CheckContents(string file, byte[] fileContent, bool includeDebug = false) => 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-19 15:41:49 -07:00
|
|
|
|
// TODO: Verify if these are OR or AND
|
2021-03-23 10:36:14 -07:00
|
|
|
|
var matchers = new List<PathMatchSet>
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2021-03-23 10:36:14 -07:00
|
|
|
|
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"),
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2021-03-23 13:35:12 -07:00
|
|
|
|
return MatchUtil.GetAllMatches(files, matchers, any: true);
|
2021-03-19 15:41:49 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public string CheckFilePath(string path)
|
|
|
|
|
|
{
|
2021-03-23 10:36:14 -07:00
|
|
|
|
var matchers = new List<PathMatchSet>
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2021-03-23 10:36:14 -07:00
|
|
|
|
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"),
|
|
|
|
|
|
};
|
2019-09-27 23:52:24 -07:00
|
|
|
|
|
2021-03-23 10:36:14 -07:00
|
|
|
|
return MatchUtil.GetFirstMatch(path, matchers, any: true);
|
2019-09-27 23:52:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|