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 15:32:37 -07:00
using System.Linq ;
2021-09-10 16:10:15 -07:00
using BurnOutSharp.ExecutableType.Microsoft ;
2021-03-21 15:34:19 -07:00
using BurnOutSharp.Matching ;
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-02-26 01:26:49 -08:00
/// <inheritdoc/>
2021-09-10 15:32:37 -07:00
private List < ContentMatchSet > GetContentMatchSets ( )
2021-02-20 22:13:48 -08:00
{
2021-09-01 14:15:38 -07:00
// TODO: Obtain a sample to find where this string is in a typical executable
2021-08-25 19:37:32 -07:00
return new List < ContentMatchSet >
2021-07-17 23:40:16 -07:00
{
// O + (char)0x00 + r + (char)0x00 + i + (char)0x00 + g + (char)0x00 + i + (char)0x00 + n + (char)0x00 + S + (char)0x00 + e + (char)0x00 + t + (char)0x00 + u + (char)0x00 + p + (char)0x00 + . + (char)0x00 + e + (char)0x00 + x + (char)0x00 + e + (char)0x00
2021-09-01 14:15:38 -07:00
new ContentMatchSet ( new byte? [ ]
{
0x4F , 0x00 , 0x72 , 0x00 , 0x69 , 0x00 , 0x67 , 0x00 ,
0x69 , 0x00 , 0x6E , 0x00 , 0x53 , 0x00 , 0x65 , 0x00 ,
0x74 , 0x00 , 0x75 , 0x00 , 0x70 , 0x00 , 0x2E , 0x00 ,
0x65 , 0x00 , 0x78 , 0x00 , 0x65 , 0x00
} , "Origin" ) ,
2021-07-17 23:40:16 -07:00
} ;
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-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
{
var contentMatchSets = GetContentMatchSets ( ) ;
if ( contentMatchSets ! = null & & contentMatchSets . Any ( ) )
return MatchUtil . GetFirstMatch ( file , fileContent , contentMatchSets , includeDebug ) ;
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
}
}
}