2021-09-10 15:32:37 -07:00
using System.Collections.Generic ;
2021-09-07 21:08:25 -07:00
using System.Linq ;
using System.Text ;
using BurnOutSharp.ExecutableType.Microsoft ;
2021-03-21 15:34:19 -07:00
using BurnOutSharp.Matching ;
2021-03-21 14:30:37 -07:00
namespace BurnOutSharp.ProtectionType
2020-10-29 10:05:56 -07:00
{
2021-02-26 01:26:49 -08:00
public class ThreeTwoOneStudios : IContentCheck
2020-10-29 10:05:56 -07:00
{
2021-09-07 21:08:25 -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-03-23 09:52:09 -07:00
{
2021-09-07 21:08:25 -07:00
// Get the sections from the executable, if possible
var sections = pex ? . SectionTable ;
if ( sections = = null )
return null ;
2021-09-10 15:32:37 -07:00
// TODO: Find this inside of the .rsrc section using the executable header
2021-09-07 21:08:25 -07:00
// Get the .rsrc section, if it exists
var rsrcSection = sections . FirstOrDefault ( s = > Encoding . ASCII . GetString ( s . Name ) . StartsWith ( ".rsrc" ) ) ;
if ( rsrcSection ! = null )
2021-07-17 23:40:16 -07:00
{
2021-09-07 21:08:25 -07:00
int sectionAddr = ( int ) rsrcSection . PointerToRawData ;
int sectionEnd = sectionAddr + ( int ) rsrcSection . VirtualSize ;
var matchers = new List < ContentMatchSet >
2021-07-17 23:40:16 -07:00
{
2021-09-07 21:08:25 -07:00
// 3 + (char)0x00 + 2 + (char)0x00 + 1 + (char)0x00 + S + (char)0x00 + t + (char)0x00 + u + (char)0x00 + d + (char)0x00 + i + (char)0x00 + o + (char)0x00 + s + (char)0x00 + + (char)0x00 + A + (char)0x00 + c + (char)0x00 + t + (char)0x00 + i + (char)0x00 + v + (char)0x00 + a + (char)0x00 + t + (char)0x00 + i + (char)0x00 + o + (char)0x00 + n + (char)0x00
new ContentMatchSet (
new ContentMatch ( new byte? [ ]
{
0x33 , 0x00 , 0x32 , 0x00 , 0x31 , 0x00 , 0x53 , 0x00 ,
0x74 , 0x00 , 0x75 , 0x00 , 0x64 , 0x00 , 0x69 , 0x00 ,
0x6F , 0x00 , 0x73 , 0x00 , 0x20 , 0x00 , 0x41 , 0x00 ,
0x63 , 0x00 , 0x74 , 0x00 , 0x69 , 0x00 , 0x76 , 0x00 ,
0x61 , 0x00 , 0x74 , 0x00 , 0x69 , 0x00 , 0x6F , 0x00 ,
0x6E , 0x00
} , start : sectionAddr , end : sectionEnd ) ,
"321Studios Online Activation" ) ,
} ;
2021-07-17 23:40:16 -07:00
2021-09-07 21:08:25 -07:00
string match = MatchUtil . GetFirstMatch ( file , fileContent , matchers , includeDebug ) ;
if ( ! string . IsNullOrWhiteSpace ( match ) )
return match ;
}
return null ;
}
2020-10-29 10:05:56 -07:00
}
}