mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-27 22:25:37 +08:00
Merge remote-tracking branch
'origin/GP-1406_ryanmkurtz_macho-encryption' (Closes #1935)
This commit is contained in:
+11
-4
@@ -37,13 +37,15 @@ public class EncryptedInformationCommand extends LoadCommand {
|
|||||||
private int cryptoff;
|
private int cryptoff;
|
||||||
private int cryptsize;
|
private int cryptsize;
|
||||||
private int cryptid;
|
private int cryptid;
|
||||||
|
|
||||||
|
private boolean is32bit;
|
||||||
|
|
||||||
static EncryptedInformationCommand createEncryptedInformationCommand(
|
static EncryptedInformationCommand createEncryptedInformationCommand(
|
||||||
FactoryBundledWithBinaryReader reader) throws IOException {
|
FactoryBundledWithBinaryReader reader, boolean is32bit) throws IOException {
|
||||||
EncryptedInformationCommand command =
|
EncryptedInformationCommand command =
|
||||||
(EncryptedInformationCommand) reader.getFactory().create(
|
(EncryptedInformationCommand) reader.getFactory().create(
|
||||||
EncryptedInformationCommand.class);
|
EncryptedInformationCommand.class);
|
||||||
command.initEncryptedInformationCommand(reader);
|
command.initEncryptedInformationCommand(reader, is32bit);
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,9 +55,11 @@ public class EncryptedInformationCommand extends LoadCommand {
|
|||||||
public EncryptedInformationCommand() {
|
public EncryptedInformationCommand() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initEncryptedInformationCommand(FactoryBundledWithBinaryReader reader)
|
private void initEncryptedInformationCommand(FactoryBundledWithBinaryReader reader,
|
||||||
throws IOException {
|
boolean is32bit) throws IOException {
|
||||||
initLoadCommand(reader);
|
initLoadCommand(reader);
|
||||||
|
this.is32bit = is32bit;
|
||||||
|
|
||||||
cryptoff = reader.readNextInt();
|
cryptoff = reader.readNextInt();
|
||||||
cryptsize = reader.readNextInt();
|
cryptsize = reader.readNextInt();
|
||||||
cryptid = reader.readNextInt();
|
cryptid = reader.readNextInt();
|
||||||
@@ -102,6 +106,9 @@ public class EncryptedInformationCommand extends LoadCommand {
|
|||||||
struct.add(DWORD, "cryptoff", null);
|
struct.add(DWORD, "cryptoff", null);
|
||||||
struct.add(DWORD, "cryptsize", null);
|
struct.add(DWORD, "cryptsize", null);
|
||||||
struct.add(DWORD, "cryptid", null);
|
struct.add(DWORD, "cryptid", null);
|
||||||
|
if (!is32bit) {
|
||||||
|
struct.add(DWORD, "pad", null);
|
||||||
|
}
|
||||||
struct.setCategoryPath(new CategoryPath(MachConstants.DATA_TYPE_CATEGORY));
|
struct.setCategoryPath(new CategoryPath(MachConstants.DATA_TYPE_CATEGORY));
|
||||||
return struct;
|
return struct;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -124,8 +124,10 @@ public final class LoadCommandTypes {
|
|||||||
case LC_REEXPORT_DYLIB: {
|
case LC_REEXPORT_DYLIB: {
|
||||||
return DynamicLibraryCommand.createDynamicLibraryCommand(reader);
|
return DynamicLibraryCommand.createDynamicLibraryCommand(reader);
|
||||||
}
|
}
|
||||||
case LC_ENCRYPTION_INFO: {
|
case LC_ENCRYPTION_INFO:
|
||||||
return EncryptedInformationCommand.createEncryptedInformationCommand(reader);
|
case LC_ENCRYPTION_INFO_64: {
|
||||||
|
return EncryptedInformationCommand.createEncryptedInformationCommand(reader,
|
||||||
|
header.is32bit());
|
||||||
}
|
}
|
||||||
case LC_DYLD_INFO:
|
case LC_DYLD_INFO:
|
||||||
case LC_DYLD_INFO_ONLY: {
|
case LC_DYLD_INFO_ONLY: {
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ public class MachoProgramBuilder {
|
|||||||
monitor.setCancelEnabled(true);
|
monitor.setCancelEnabled(true);
|
||||||
|
|
||||||
setImageBase();
|
setImageBase();
|
||||||
|
processEncryption();
|
||||||
processEntryPoint();
|
processEntryPoint();
|
||||||
processMemoryBlocks(machoHeader, provider.getName(), true, true);
|
processMemoryBlocks(machoHeader, provider.getName(), true, true);
|
||||||
processUnsupportedLoadCommands();
|
processUnsupportedLoadCommands();
|
||||||
@@ -155,6 +156,17 @@ public class MachoProgramBuilder {
|
|||||||
program.setImageBase(space.getAddress(0), true);
|
program.setImageBase(space.getAddress(0), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void processEncryption() throws Exception {
|
||||||
|
monitor.setMessage("Processing encryption...");
|
||||||
|
for (EncryptedInformationCommand cmd : machoHeader
|
||||||
|
.getLoadCommands(EncryptedInformationCommand.class)) {
|
||||||
|
if (cmd.getCryptID() != 0) {
|
||||||
|
log.appendMsg(String.format("ENCRYPTION DETECTED: (file offset 0x%x, size 0x%x)",
|
||||||
|
cmd.getCryptOffset(), cmd.getCryptSize()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void processEntryPoint() throws Exception {
|
private void processEntryPoint() throws Exception {
|
||||||
monitor.setMessage("Processing entry point...");
|
monitor.setMessage("Processing entry point...");
|
||||||
|
|||||||
Reference in New Issue
Block a user