mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-27 23:17:03 +08:00
Merge remote-tracking branch 'origin/GP-3077_emteere_CrossedConstants--SQUASHED'
This commit is contained in:
@@ -46,6 +46,7 @@ import ghidra.app.script.GhidraScript;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.block.CodeBlock;
|
||||
import ghidra.program.model.block.PartitionCodeSubModel;
|
||||
import ghidra.program.model.data.DataType;
|
||||
import ghidra.program.model.lang.*;
|
||||
import ghidra.program.model.listing.Function;
|
||||
import ghidra.program.model.listing.Instruction;
|
||||
@@ -177,9 +178,9 @@ public class MultiInstructionMemReference extends GhidraScript {
|
||||
|
||||
@Override
|
||||
public boolean evaluateReference(VarnodeContext context, Instruction instr, int pcodeop,
|
||||
Address address, int size, RefType refType) {
|
||||
Address address, int size, DataType dataType, RefType refType) {
|
||||
|
||||
return super.evaluateReference(context, instr, pcodeop, address, size, refType);
|
||||
return super.evaluateReference(context, instr, pcodeop, address, size, dataType, refType);
|
||||
}
|
||||
|
||||
private boolean checkInstructionMatch(final int opIdx, boolean input,
|
||||
|
||||
@@ -70,7 +70,7 @@ public class PropagateConstantReferences extends GhidraScript {
|
||||
|
||||
// follow all flows building up context
|
||||
// use context to fill out addresses on certain instructions
|
||||
ContextEvaluator eval = new ConstantPropagationContextEvaluator(true);
|
||||
ContextEvaluator eval = new ConstantPropagationContextEvaluator(monitor, true);
|
||||
|
||||
SymbolicPropogator symEval = new SymbolicPropogator(currentProgram);
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import ghidra.app.plugin.core.disassembler.AddressTable;
|
||||
import ghidra.app.script.GhidraScript;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.block.*;
|
||||
import ghidra.program.model.data.DataType;
|
||||
import ghidra.program.model.lang.Register;
|
||||
import ghidra.program.model.lang.RegisterValue;
|
||||
import ghidra.program.model.listing.*;
|
||||
@@ -88,7 +89,7 @@ public class PropagateX86ConstantReferences extends GhidraScript {
|
||||
// use context to fill out addresses on certain instructions
|
||||
// Always trust values read from writable memory
|
||||
ConstantPropagationContextEvaluator eval =
|
||||
new ConstantPropagationContextEvaluator(true) {
|
||||
new ConstantPropagationContextEvaluator(monitor, true) {
|
||||
@Override
|
||||
public boolean evaluateDestination(VarnodeContext context,
|
||||
Instruction instruction) {
|
||||
@@ -131,10 +132,13 @@ public class PropagateX86ConstantReferences extends GhidraScript {
|
||||
|
||||
@Override
|
||||
public boolean evaluateReference(VarnodeContext context, Instruction instr,
|
||||
int pcodeop, Address address, int size, RefType refType) {
|
||||
int pcodeop, Address address, int size, DataType dataType, RefType refType) {
|
||||
return true; // just go ahead and mark up the instruction
|
||||
}
|
||||
};
|
||||
|
||||
eval.setTrustWritableMemory(true)
|
||||
.setCreateComplexDataFromPointers(true);
|
||||
|
||||
SymbolicPropogator symEval = new SymbolicPropogator(currentProgram);
|
||||
symEval.setParamRefCheck(true);
|
||||
@@ -144,7 +148,7 @@ public class PropagateX86ConstantReferences extends GhidraScript {
|
||||
symEval.flowConstants(start, func.getBody(), eval, true, monitor);
|
||||
|
||||
// now handle symbolic execution assuming values!
|
||||
eval = new ConstantPropagationContextEvaluator() {
|
||||
eval = new ConstantPropagationContextEvaluator(monitor) {
|
||||
|
||||
@Override
|
||||
public boolean evaluateContext(VarnodeContext context, Instruction instr) {
|
||||
@@ -181,14 +185,14 @@ public class PropagateX86ConstantReferences extends GhidraScript {
|
||||
|
||||
@Override
|
||||
public Address evaluateConstant(VarnodeContext context, Instruction instr,
|
||||
int pcodeop, Address constant, int size, RefType refType) {
|
||||
int pcodeop, Address constant, int size, DataType dataType, RefType refType) {
|
||||
// don't create any references from constants, only looking for flow refs
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean evaluateReference(VarnodeContext context, Instruction instr,
|
||||
int pcodeop, Address address, int size, RefType refType) {
|
||||
int pcodeop, Address address, int size, DataType dataType, RefType refType) {
|
||||
// TODO: if ever loading from instructions in memory, must
|
||||
// EXIT!
|
||||
if (!(instr.getFlowType().isComputed() &&
|
||||
@@ -220,6 +224,9 @@ public class PropagateX86ConstantReferences extends GhidraScript {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
eval.setTrustWritableMemory(true)
|
||||
.setCreateComplexDataFromPointers(true);
|
||||
|
||||
// now flow with the simple block of this branch....
|
||||
|
||||
|
||||
@@ -281,7 +281,7 @@ public class ResolveX86orX64LinuxSyscallsScript extends GhidraScript {
|
||||
Register syscallReg = program.getLanguage().getRegister(syscallRegister);
|
||||
for (Function func : funcsToCalls.keySet()) {
|
||||
Address start = func.getEntryPoint();
|
||||
ContextEvaluator eval = new ConstantPropagationContextEvaluator(true);
|
||||
ContextEvaluator eval = new ConstantPropagationContextEvaluator(monitor, true);
|
||||
SymbolicPropogator symEval = new SymbolicPropogator(program);
|
||||
symEval.flowConstants(start, func.getBody(), eval, true, tMonitor);
|
||||
for (Address callSite : funcsToCalls.get(func)) {
|
||||
|
||||
Reference in New Issue
Block a user