2021-09-10 15:32:37 -07:00
|
|
|
|
using System.Linq;
|
2021-09-07 21:02:52 -07:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
using BurnOutSharp.ExecutableType.Microsoft;
|
2021-03-21 22:19:38 -07:00
|
|
|
|
|
|
|
|
|
|
namespace BurnOutSharp.ProtectionType
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2021-02-26 01:26:49 -08:00
|
|
|
|
public class ThreePLock : IContentCheck
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2021-09-07 21:02:52 -07:00
|
|
|
|
/// <inheritdoc/>
|
2021-09-10 16:10:15 -07:00
|
|
|
|
public string CheckContents(string file, byte[] fileContent, bool includeDebug, PortableExecutable pex, NewExecutable nex)
|
2019-09-27 23:52:24 -07:00
|
|
|
|
{
|
2021-09-07 21:02:52 -07:00
|
|
|
|
// Get the sections from the executable, if possible
|
|
|
|
|
|
var sections = pex?.SectionTable;
|
|
|
|
|
|
if (sections == null)
|
|
|
|
|
|
return null;
|
2021-03-21 22:19:38 -07:00
|
|
|
|
|
2021-09-10 15:32:37 -07:00
|
|
|
|
//This produced false positives in some DirectX 9.0c installer files
|
|
|
|
|
|
//"Y" + (char)0xC3 + "U" + (char)0x8B + (char)0xEC + (char)0x83 + (char)0xEC + "0SVW"
|
|
|
|
|
|
|
2021-09-07 21:02:52 -07:00
|
|
|
|
// Get the .ldr and .ldt sections, if they exist -- TODO: Confirm if both are needed or either/or is fine
|
|
|
|
|
|
var cmsdSection = sections.FirstOrDefault(s => Encoding.ASCII.GetString(s.Name).StartsWith(".ldr"));
|
|
|
|
|
|
var cmstSection = sections.FirstOrDefault(s => Encoding.ASCII.GetString(s.Name).StartsWith(".ldt"));
|
|
|
|
|
|
if (cmsdSection != null || cmstSection != null)
|
|
|
|
|
|
return $"3PLock";
|
2020-09-10 21:10:32 -07:00
|
|
|
|
|
2021-09-07 21:02:52 -07:00
|
|
|
|
return null;
|
2021-08-25 19:37:32 -07:00
|
|
|
|
}
|
2019-09-27 23:52:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|