Search in sources :

Example 36 with ReilInstruction

use of com.google.security.zynamics.reil.ReilInstruction in project binnavi by google.

the class BackwardRegisterTrackingTransformationProviderTest method testTransformAndZeroSecondArgument.

@Test
public void testTransformAndZeroSecondArgument() {
    final RegisterTrackingTransformationProvider transformationProvider = new RegisterTrackingTransformationProvider(new RegisterTrackingOptions(false, new TreeSet<String>(), false, AnalysisDirection.UP));
    final ReilInstruction instruction = ReilHelpers.createAnd(0, OperandSize.DWORD, "ecx", OperandSize.DWORD, String.valueOf(0), OperandSize.DWORD, "eax");
    final Pair<RegisterSetLatticeElement, RegisterSetLatticeElement> transformationResult = transformationProvider.transformAnd(instruction, createTaintedState("eax"));
    Assert.assertNull(transformationResult.second());
    Assert.assertFalse(transformationResult.first().isTainted("eax"));
    transformationResult.first().onInstructionExit();
    Assert.assertTrue(transformationResult.first().getReadRegisters().isEmpty());
    Assert.assertTrue(transformationResult.first().getNewlyTaintedRegisters().isEmpty());
    Assert.assertTrue(transformationResult.first().getUpdatedRegisters().isEmpty());
    Assert.assertTrue(transformationResult.first().getUntaintedRegisters().contains("eax"));
}
Also used : ReilInstruction(com.google.security.zynamics.reil.ReilInstruction) TreeSet(java.util.TreeSet) Test(org.junit.Test)

Example 37 with ReilInstruction

use of com.google.security.zynamics.reil.ReilInstruction in project binnavi by google.

the class BackwardRegisterTrackingTransformationProviderTest method testTransformMul.

@Test
public void testTransformMul() {
    final RegisterTrackingTransformationProvider transformationProvider = new RegisterTrackingTransformationProvider(new RegisterTrackingOptions(false, new TreeSet<String>(), false, AnalysisDirection.UP));
    final ReilInstruction instruction = ReilHelpers.createMul(0, OperandSize.DWORD, "ecx", OperandSize.DWORD, "ebx", OperandSize.DWORD, "eax");
    final Pair<RegisterSetLatticeElement, RegisterSetLatticeElement> transformationResult = transformationProvider.transformMul(instruction, createTaintedState("eax"));
    Assert.assertNull(transformationResult.second());
    Assert.assertFalse(transformationResult.first().isTainted("eax"));
    Assert.assertTrue(transformationResult.first().isTainted("ecx"));
    Assert.assertTrue(transformationResult.first().isTainted("ebx"));
    transformationResult.first().onInstructionExit();
    Assert.assertTrue(transformationResult.first().getReadRegisters().contains("eax"));
    Assert.assertTrue(transformationResult.first().getNewlyTaintedRegisters().contains("ecx"));
    Assert.assertTrue(transformationResult.first().getNewlyTaintedRegisters().contains("ebx"));
    Assert.assertTrue(transformationResult.first().getUpdatedRegisters().isEmpty());
}
Also used : ReilInstruction(com.google.security.zynamics.reil.ReilInstruction) TreeSet(java.util.TreeSet) Test(org.junit.Test)

Example 38 with ReilInstruction

use of com.google.security.zynamics.reil.ReilInstruction in project binnavi by google.

the class BackwardRegisterTrackingTransformationProviderTest method testTransformUnknown.

@Test
public void testTransformUnknown() {
    final RegisterTrackingTransformationProvider transformationProvider = new RegisterTrackingTransformationProvider(new RegisterTrackingOptions(false, new TreeSet<String>(), false, AnalysisDirection.UP));
    final ReilInstruction instruction = ReilHelpers.createUnknown(0);
    final Pair<RegisterSetLatticeElement, RegisterSetLatticeElement> transformationResult = transformationProvider.transformUndef(instruction, createTaintedState("eax"));
    Assert.assertNull(transformationResult.second());
    transformationResult.first().onInstructionExit();
    Assert.assertTrue(transformationResult.first().getTaintedRegisters().contains("eax"));
    Assert.assertTrue(transformationResult.first().getReadRegisters().isEmpty());
    Assert.assertTrue(transformationResult.first().getUntaintedRegisters().isEmpty());
    Assert.assertTrue(transformationResult.first().getNewlyTaintedRegisters().isEmpty());
    Assert.assertTrue(transformationResult.first().getUpdatedRegisters().isEmpty());
}
Also used : ReilInstruction(com.google.security.zynamics.reil.ReilInstruction) TreeSet(java.util.TreeSet) Test(org.junit.Test)

Example 39 with ReilInstruction

use of com.google.security.zynamics.reil.ReilInstruction in project binnavi by google.

the class BackwardRegisterTrackingTransformationProviderTest method testTransformMod.

@Test
public void testTransformMod() {
    final RegisterTrackingTransformationProvider transformationProvider = new RegisterTrackingTransformationProvider(new RegisterTrackingOptions(false, new TreeSet<String>(), false, AnalysisDirection.UP));
    final ReilInstruction instruction = ReilHelpers.createMod(0, OperandSize.DWORD, "ecx", OperandSize.DWORD, "ebx", OperandSize.DWORD, "eax");
    final Pair<RegisterSetLatticeElement, RegisterSetLatticeElement> transformationResult = transformationProvider.transformMod(instruction, createTaintedState("eax"));
    Assert.assertNull(transformationResult.second());
    Assert.assertFalse(transformationResult.first().isTainted("eax"));
    Assert.assertTrue(transformationResult.first().isTainted("ecx"));
    Assert.assertTrue(transformationResult.first().isTainted("ebx"));
    transformationResult.first().onInstructionExit();
    Assert.assertTrue(transformationResult.first().getReadRegisters().contains("eax"));
    Assert.assertTrue(transformationResult.first().getNewlyTaintedRegisters().contains("ecx"));
    Assert.assertTrue(transformationResult.first().getNewlyTaintedRegisters().contains("ebx"));
    Assert.assertTrue(transformationResult.first().getUpdatedRegisters().isEmpty());
}
Also used : ReilInstruction(com.google.security.zynamics.reil.ReilInstruction) TreeSet(java.util.TreeSet) Test(org.junit.Test)

Example 40 with ReilInstruction

use of com.google.security.zynamics.reil.ReilInstruction in project binnavi by google.

the class BackwardRegisterTrackingTransformationProviderTest method testTransformStm.

@Test
public void testTransformStm() {
    final RegisterTrackingTransformationProvider transformationProvider = new RegisterTrackingTransformationProvider(new RegisterTrackingOptions(false, new TreeSet<String>(), false, AnalysisDirection.UP));
    final ReilInstruction instruction = ReilHelpers.createStm(0, OperandSize.DWORD, "ecx", OperandSize.DWORD, "eax");
    final Pair<RegisterSetLatticeElement, RegisterSetLatticeElement> transformationResult = transformationProvider.transformStm(instruction, createTaintedState("eax"));
    Assert.assertNull(transformationResult.second());
    transformationResult.first().onInstructionExit();
    Assert.assertTrue(transformationResult.first().getTaintedRegisters().contains("eax"));
    Assert.assertTrue(transformationResult.first().getReadRegisters().isEmpty());
    Assert.assertTrue(transformationResult.first().getNewlyTaintedRegisters().isEmpty());
    Assert.assertTrue(transformationResult.first().getUpdatedRegisters().isEmpty());
    Assert.assertTrue(transformationResult.first().getUntaintedRegisters().isEmpty());
}
Also used : ReilInstruction(com.google.security.zynamics.reil.ReilInstruction) TreeSet(java.util.TreeSet) Test(org.junit.Test)

Aggregations

ReilInstruction (com.google.security.zynamics.reil.ReilInstruction)144 Test (org.junit.Test)102 TreeSet (java.util.TreeSet)73 ArrayList (java.util.ArrayList)35 IInstruction (com.google.security.zynamics.zylib.disassembly.IInstruction)18 OperandSize (com.google.security.zynamics.reil.OperandSize)16 ReilBlock (com.google.security.zynamics.reil.ReilBlock)16 MockInstruction (com.google.security.zynamics.zylib.disassembly.MockInstruction)16 MockOperandTree (com.google.security.zynamics.zylib.disassembly.MockOperandTree)16 MockOperandTreeNode (com.google.security.zynamics.zylib.disassembly.MockOperandTreeNode)16 ReilEdge (com.google.security.zynamics.reil.ReilEdge)12 HashMap (java.util.HashMap)12 TranslationResult (com.google.security.zynamics.reil.translators.TranslationResult)9 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)7 List (java.util.List)7 ReilGraph (com.google.security.zynamics.reil.ReilGraph)6 InternalTranslationException (com.google.security.zynamics.reil.translators.InternalTranslationException)6 BigInteger (java.math.BigInteger)6 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)5 ValueTrackerElement (com.google.security.zynamics.reil.algorithms.mono.valuetracking.ValueTrackerElement)5