Files
BinaryObjectScanner/BinaryObjectScanner.Protection/Origin.cs

54 lines
1.7 KiB
C#
Raw Normal View History

2021-09-12 13:40:29 -07:00
using System;
using System.Collections.Concurrent;
2021-02-20 22:13:48 -08:00
using System.Collections.Generic;
using BinaryObjectScanner.Interfaces;
2023-03-07 16:59:14 -05:00
using BinaryObjectScanner.Matching;
using BinaryObjectScanner.Wrappers;
2021-02-20 22:13:48 -08:00
namespace BinaryObjectScanner.Protection
2021-02-20 22:13:48 -08:00
{
2022-05-01 17:23:00 -07:00
public class Origin : IPathCheck, IPortableExecutableCheck
2021-02-20 22:13:48 -08:00
{
/// <inheritdoc/>
2022-05-01 17:17:15 -07:00
public string CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug)
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;
2022-04-02 16:12:23 -07:00
string name = pex.FileDescription;
if (name?.Equals("Origin", StringComparison.OrdinalIgnoreCase) == true)
2021-09-12 13:40:29 -07:00
return "Origin";
2022-04-02 16:12:23 -07:00
name = pex.ProductName;
if (name?.Equals("Origin", StringComparison.OrdinalIgnoreCase) == true)
2021-09-12 13:40:29 -07:00
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/>
public ConcurrentQueue<string> CheckDirectoryPath(string path, IEnumerable<string> files)
2021-02-20 22:13:48 -08:00
{
var matchers = new List<PathMatchSet>
{
new PathMatchSet(new PathMatch("OriginSetup.exe", useEndsWith: true), "Origin"),
};
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("OriginSetup.exe", useEndsWith: true), "Origin"),
};
2021-02-20 22:13:48 -08:00
return MatchUtil.GetFirstMatch(path, matchers, any: true);
2021-02-20 22:13:48 -08:00
}
}
}