use of com.google.security.zynamics.reil.algorithms.mono2.registertracking.RegisterSetLattice in project binnavi by google.
the class RegisterSetLatticeTest method combine.
@Test
public void combine() {
final RegisterSetLattice lattice = new RegisterSetLattice();
final RegisterSetLatticeElement element = lattice.combine(Lists.newArrayList(m_fullRegisterSetLatticeElement, m_emptyRegisterSetLatticeElement));
Assert.assertTrue(element.getTaintedRegisters().containsAll(m_fullRegisterSetLatticeElement.getTaintedRegisters()));
Assert.assertTrue(element.getUntaintedRegisters().containsAll(m_fullRegisterSetLatticeElement.getUntaintedRegisters()));
Assert.assertTrue(element.getReadRegisters().containsAll(m_fullRegisterSetLatticeElement.getReadRegisters()));
Assert.assertTrue(element.getUpdatedRegisters().containsAll(m_fullRegisterSetLatticeElement.getUpdatedRegisters()));
}
use of com.google.security.zynamics.reil.algorithms.mono2.registertracking.RegisterSetLattice in project binnavi by google.
the class RegisterSetLatticeTest method isSmallerEqual.
@Test
public void isSmallerEqual() {
final RegisterSetLattice lattice = new RegisterSetLattice();
Assert.assertTrue(lattice.isSmallerEqual(lattice.getMinimalElement(), lattice.getMinimalElement()));
Assert.assertTrue(lattice.isSmallerEqual(lattice.getMinimalElement(), m_fullRegisterSetLatticeElement));
Assert.assertFalse(lattice.isSmallerEqual(m_fullRegisterSetLatticeElement, lattice.getMinimalElement()));
Assert.assertTrue(lattice.isSmallerEqual(m_fullRegisterSetLatticeElement, m_fullRegisterSetLatticeElement));
}
use of com.google.security.zynamics.reil.algorithms.mono2.registertracking.RegisterSetLattice in project binnavi by google.
the class RegisterTracker method track.
/**
* Function to do register tracking.
*
* @param function The {@link ReilFunction} in which to do the register tracking.
* @param startInstruction The {@link IInstruction} which is the start instruction.
* @param trackedRegister The register to be tracked.
* @param options The {@link RegisterTrackingOptions}.
*
* @return The {@link MonoReilSolverResult} of the tracking.
*/
public static MonoReilSolverResult<RegisterSetLatticeElement> track(final ReilFunction function, final IInstruction startInstruction, final String trackedRegister, final RegisterTrackingOptions options) {
Preconditions.checkNotNull(function, "Error: function argument can not be null");
Preconditions.checkNotNull(startInstruction, "Error: startInstruction argument can not be null");
Preconditions.checkNotNull(trackedRegister, "Error: trackedRegister argument can not be null");
Preconditions.checkNotNull(options, "Error: options argument can not be null");
final CReilInstructionGraph instructionGraph = new CReilInstructionGraph(function.getGraph());
final RegisterSetLatticeElement registerSetLatticeElement = new RegisterSetLatticeElement(trackedRegister);
final MonoReilSolver<RegisterSetLatticeElement> monoReilSolver = new MonoReilSolver<RegisterSetLatticeElement>(instructionGraph, options.getAnalysisDirection(), new RegisterSetLattice());
final Iterable<IInstructionGraphEdge> relevantEdges = options.trackIncoming() ? instructionGraph.getIncomingEdgesForAddress(startInstruction.getAddress()) : instructionGraph.getOutgoingEdgesForAddress(startInstruction.getAddress());
final List<Pair<IInstructionGraphEdge, RegisterSetLatticeElement>> initialState = new ArrayList<Pair<IInstructionGraphEdge, RegisterSetLatticeElement>>();
for (final IInstructionGraphEdge currentRelevantEdge : relevantEdges) {
initialState.add(new Pair<IInstructionGraphEdge, RegisterSetLatticeElement>(currentRelevantEdge, registerSetLatticeElement));
}
final ITransformationProvider<RegisterSetLatticeElement> transformationProvider = new RegisterTrackingTransformationProvider(options);
final MonoReilSolverResult<RegisterSetLatticeElement> solverResult = monoReilSolver.solve(transformationProvider, initialState, Integer.MAX_VALUE);
return solverResult;
}
use of com.google.security.zynamics.reil.algorithms.mono2.registertracking.RegisterSetLattice in project binnavi by google.
the class RegisterSetLatticeTest method getMinimalElement.
@Test
public void getMinimalElement() {
final RegisterSetLattice lattice = new RegisterSetLattice();
lattice.getMinimalElement().getNewlyTaintedRegisters().isEmpty();
lattice.getMinimalElement().getTaintedRegisters().isEmpty();
lattice.getMinimalElement().getUntaintedRegisters().isEmpty();
lattice.getMinimalElement().getUpdatedRegisters().isEmpty();
lattice.getMinimalElement().getReadRegisters().isEmpty();
}
Aggregations