MachO: Throw an exception if file is encrypted with FairPlay DRM
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2017-2019 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com
|
Copyright 2017-2020 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
@@ -24,7 +24,9 @@ namespace Il2CppInspector
|
|||||||
LC_SYMTAB = 0x2,
|
LC_SYMTAB = 0x2,
|
||||||
LC_DYSYMTAB = 0xb,
|
LC_DYSYMTAB = 0xb,
|
||||||
LC_SEGMENT_64 = 0x19,
|
LC_SEGMENT_64 = 0x19,
|
||||||
|
LC_ENCRYPTION_INFO = 0x21,
|
||||||
LC_FUNCTION_STARTS = 0x26,
|
LC_FUNCTION_STARTS = 0x26,
|
||||||
|
LC_ENCRYPTION_INFO_64 = 0x2C,
|
||||||
|
|
||||||
CPU_TYPE_X86 = 7,
|
CPU_TYPE_X86 = 7,
|
||||||
CPU_TYPE_X86_64 = 0x01000000 + CPU_TYPE_X86,
|
CPU_TYPE_X86_64 = 0x01000000 + CPU_TYPE_X86,
|
||||||
@@ -96,6 +98,14 @@ namespace Il2CppInspector
|
|||||||
public uint StrSize;
|
public uint StrSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal class MachOEncryptionInfo
|
||||||
|
{
|
||||||
|
// MachOLoadCommand
|
||||||
|
public uint CryptOffset;
|
||||||
|
public uint CryptSize;
|
||||||
|
public uint CryptID;
|
||||||
|
}
|
||||||
|
|
||||||
internal class MachO_nlist<TWord> where TWord : struct
|
internal class MachO_nlist<TWord> where TWord : struct
|
||||||
{
|
{
|
||||||
public uint n_strx;
|
public uint n_strx;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2017-2019 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com
|
Copyright 2017-2020 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
@@ -39,6 +39,7 @@ namespace Il2CppInspector
|
|||||||
protected override bool checkMagicBE(MachO magic) => magic == MachO.MH_CIGAM_64;
|
protected override bool checkMagicBE(MachO magic) => magic == MachO.MH_CIGAM_64;
|
||||||
|
|
||||||
protected override MachO lc_Segment => MachO.LC_SEGMENT_64;
|
protected override MachO lc_Segment => MachO.LC_SEGMENT_64;
|
||||||
|
|
||||||
public override uint MapVATR(ulong uiAddr) {
|
public override uint MapVATR(ulong uiAddr) {
|
||||||
var section = sections.First(x => uiAddr >= x.Address && uiAddr <= x.Address + x.Size);
|
var section = sections.First(x => uiAddr >= x.Address && uiAddr <= x.Address + x.Size);
|
||||||
return (uint) (uiAddr - (section.Address - section.ImageOffset));
|
return (uint) (uiAddr - (section.Address - section.ImageOffset));
|
||||||
@@ -126,6 +127,15 @@ namespace Il2CppInspector
|
|||||||
case MachO.LC_DYSYMTAB:
|
case MachO.LC_DYSYMTAB:
|
||||||
// TODO: Implement Mach-O dynamic symbol table
|
// TODO: Implement Mach-O dynamic symbol table
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// Encryption check
|
||||||
|
// If cryptid == 1, this binary is encrypted with FairPlay DRM
|
||||||
|
case MachO.LC_ENCRYPTION_INFO:
|
||||||
|
case MachO.LC_ENCRYPTION_INFO_64:
|
||||||
|
var encryptionInfo = ReadObject<MachOEncryptionInfo>();
|
||||||
|
if (encryptionInfo.CryptID != 0)
|
||||||
|
throw new NotImplementedException("This Mach-O executable is encrypted with FairPlay DRM and cannot be processed. Please provide a decrypted version of the executable.");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// There might be other data after the load command so always use the specified total size to step forwards
|
// There might be other data after the load command so always use the specified total size to step forwards
|
||||||
|
|||||||
Reference in New Issue
Block a user