Search in sources :

Example 1 with RegisterSetLattice

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()));
}
Also used : RegisterSetLatticeElement(com.google.security.zynamics.reil.algorithms.mono2.registertracking.RegisterSetLatticeElement) RegisterSetLattice(com.google.security.zynamics.reil.algorithms.mono2.registertracking.RegisterSetLattice) Test(org.junit.Test)

Example 2 with RegisterSetLattice

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));
}
Also used : RegisterSetLattice(com.google.security.zynamics.reil.algorithms.mono2.registertracking.RegisterSetLattice) Test(org.junit.Test)

Example 3 with RegisterSetLattice

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;
}
Also used : IInstructionGraphEdge(com.google.security.zynamics.reil.algorithms.mono2.common.instructiongraph.interfaces.IInstructionGraphEdge) ArrayList(java.util.ArrayList) CReilInstructionGraph(com.google.security.zynamics.reil.yfileswrap.algorithms.mono2.common.instructiongraph.CReilInstructionGraph) MonoReilSolver(com.google.security.zynamics.reil.algorithms.mono2.common.MonoReilSolver) Pair(com.google.security.zynamics.zylib.general.Pair)

Example 4 with RegisterSetLattice

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();
}
Also used : RegisterSetLattice(com.google.security.zynamics.reil.algorithms.mono2.registertracking.RegisterSetLattice) Test(org.junit.Test)

Aggregations

RegisterSetLattice (com.google.security.zynamics.reil.algorithms.mono2.registertracking.RegisterSetLattice)3 Test (org.junit.Test)3 MonoReilSolver (com.google.security.zynamics.reil.algorithms.mono2.common.MonoReilSolver)1 IInstructionGraphEdge (com.google.security.zynamics.reil.algorithms.mono2.common.instructiongraph.interfaces.IInstructionGraphEdge)1 RegisterSetLatticeElement (com.google.security.zynamics.reil.algorithms.mono2.registertracking.RegisterSetLatticeElement)1 CReilInstructionGraph (com.google.security.zynamics.reil.yfileswrap.algorithms.mono2.common.instructiongraph.CReilInstructionGraph)1 Pair (com.google.security.zynamics.zylib.general.Pair)1 ArrayList (java.util.ArrayList)1