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"));
}
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());
}
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());
}
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());
}
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());
}
Aggregations