2021-09-12 13:40:29 -07:00
|
|
|
using System;
|
2021-07-18 09:44:23 -07:00
|
|
|
using System.Collections.Concurrent;
|
2021-02-20 22:13:48 -08:00
|
|
|
using System.Collections.Generic;
|
2021-09-10 16:10:15 -07:00
|
|
|
using BurnOutSharp.ExecutableType.Microsoft;
|
2021-03-21 15:34:19 -07:00
|
|
|
using BurnOutSharp.Matching;
|
2021-09-12 13:40:29 -07:00
|
|
|
using BurnOutSharp.Tools;
|
2021-02-20 22:13:48 -08:00
|
|
|
|
|
|
|
|
namespace BurnOutSharp.ProtectionType
|
|
|
|
|
{
|
2021-02-26 01:26:49 -08:00
|
|
|
public class Origin : IContentCheck, IPathCheck
|
2021-02-20 22:13:48 -08:00
|
|
|
{
|
2021-08-25 19:37:32 -07:00
|
|
|
/// <inheritdoc/>
|
2021-09-10 16:10:15 -07:00
|
|
|
public string CheckContents(string file, byte[] fileContent,bool includeDebug, PortableExecutable pex, NewExecutable nex)
|
2021-09-10 15:32:37 -07:00
|
|
|
{
|
2021-09-12 13:40:29 -07:00
|
|
|
// Get the sections from the executable, if possible
|
|
|
|
|
var sections = pex?.SectionTable;
|
|
|
|
|
if (sections == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
string name = Utilities.GetFileDescription(pex);
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(name) && name.Equals("Origin", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
return "Origin";
|
|
|
|
|
|
|
|
|
|
name = Utilities.GetProductName(pex);
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(name) && name.Equals("Origin", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
return "Origin";
|
2021-09-10 15:32:37 -07:00
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2021-02-20 22:13:48 -08: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)
|
2021-02-20 22:13:48 -08:00
|
|
|
{
|
2021-03-23 09:52:09 -07:00
|
|
|
var matchers = new List<PathMatchSet>
|
|
|
|
|
{
|
|
|
|
|
new PathMatchSet(new PathMatch("OriginSetup.exe", useEndsWith: true), "Origin"),
|
|
|
|
|
};
|
|
|
|
|
|
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 09:52:09 -07:00
|
|
|
var matchers = new List<PathMatchSet>
|
|
|
|
|
{
|
|
|
|
|
new PathMatchSet(new PathMatch("OriginSetup.exe", useEndsWith: true), "Origin"),
|
|
|
|
|
};
|
2021-02-20 22:13:48 -08:00
|
|
|
|
2021-03-23 09:52:09 -07:00
|
|
|
return MatchUtil.GetFirstMatch(path, matchers, any: true);
|
2021-02-20 22:13:48 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|