use of com.google.security.zynamics.reil.ReilInstruction in project binnavi by google.
the class ForwardRegisterTrackingTransformationProviderTest method testTransformMulSecondInputIsZero.
@Test
public void testTransformMulSecondInputIsZero() {
final RegisterTrackingTransformationProvider transformationProvider = new RegisterTrackingTransformationProvider(new RegisterTrackingOptions(false, new TreeSet<String>(), false, AnalysisDirection.DOWN));
final ReilInstruction instruction = ReilHelpers.createMul(0, OperandSize.DWORD, "ecx", OperandSize.DWORD, String.valueOf("0"), OperandSize.DWORD, "eax");
final Pair<RegisterSetLatticeElement, RegisterSetLatticeElement> transformationResult = transformationProvider.transformMul(instruction, createTaintedState("ecx"));
Assert.assertNull(transformationResult.second());
transformationResult.first().onInstructionExit();
Assert.assertTrue(transformationResult.first().getNewlyTaintedRegisters().isEmpty());
Assert.assertTrue(transformationResult.first().getReadRegisters().isEmpty());
Assert.assertTrue(transformationResult.first().getTaintedRegisters().contains("ecx"));
Assert.assertFalse(transformationResult.first().getTaintedRegisters().contains("eax"));
Assert.assertTrue(transformationResult.first().getUntaintedRegisters().isEmpty());
Assert.assertTrue(transformationResult.first().getUpdatedRegisters().isEmpty());
}
use of com.google.security.zynamics.reil.ReilInstruction in project binnavi by google.
the class ForwardRegisterTrackingTransformationProviderTest method testTransformMulSecondInputRegisterIsTainted.
@Test
public void testTransformMulSecondInputRegisterIsTainted() {
final RegisterTrackingTransformationProvider transformationProvider = new RegisterTrackingTransformationProvider(new RegisterTrackingOptions(false, new TreeSet<String>(), false, AnalysisDirection.DOWN));
final ReilInstruction instruction = ReilHelpers.createMul(0, OperandSize.DWORD, "ebx", OperandSize.DWORD, "ecx", OperandSize.DWORD, "eax");
final Pair<RegisterSetLatticeElement, RegisterSetLatticeElement> transformationResult = transformationProvider.transformMul(instruction, createTaintedState("ecx"));
Assert.assertNull(transformationResult.second());
transformationResult.first().onInstructionExit();
Assert.assertTrue(transformationResult.first().getNewlyTaintedRegisters().contains("eax"));
Assert.assertTrue(transformationResult.first().getReadRegisters().contains("ecx"));
Assert.assertTrue(transformationResult.first().getTaintedRegisters().contains("eax"));
Assert.assertTrue(transformationResult.first().getTaintedRegisters().contains("ecx"));
Assert.assertTrue(transformationResult.first().getUntaintedRegisters().isEmpty());
Assert.assertTrue(transformationResult.first().getUpdatedRegisters().isEmpty());
}
use of com.google.security.zynamics.reil.ReilInstruction in project binnavi by google.
the class ForwardRegisterTrackingTransformationProviderTest method testTransformXorSameOperands.
@Test
public void testTransformXorSameOperands() {
final RegisterTrackingTransformationProvider transformationProvider = new RegisterTrackingTransformationProvider(new RegisterTrackingOptions(false, new TreeSet<String>(), false, AnalysisDirection.DOWN));
final ReilInstruction instruction = ReilHelpers.createXor(0, OperandSize.DWORD, "ecx", OperandSize.DWORD, "ecx", OperandSize.DWORD, "eax");
final Pair<RegisterSetLatticeElement, RegisterSetLatticeElement> transformationResult = transformationProvider.transformXor(instruction, createTaintedState("ecx", "eax"));
Assert.assertNull(transformationResult.second());
transformationResult.first().onInstructionExit();
Assert.assertTrue(transformationResult.first().getNewlyTaintedRegisters().isEmpty());
Assert.assertTrue(transformationResult.first().getReadRegisters().isEmpty());
Assert.assertFalse(transformationResult.first().getTaintedRegisters().contains("eax"));
Assert.assertTrue(transformationResult.first().getTaintedRegisters().contains("ecx"));
Assert.assertTrue(transformationResult.first().getUntaintedRegisters().contains("eax"));
}
use of com.google.security.zynamics.reil.ReilInstruction in project binnavi by google.
the class ForwardRegisterTrackingTransformationProviderTest method testTransformJccNoFunctionCallClear.
@Test
public void testTransformJccNoFunctionCallClear() {
final Set<String> cleared = new TreeSet<String>();
cleared.add("ecx");
final RegisterTrackingTransformationProvider transformationProvider = new RegisterTrackingTransformationProvider(new RegisterTrackingOptions(false, cleared, false, AnalysisDirection.DOWN));
final ReilInstruction instruction = ReilHelpers.createJcc(0, OperandSize.DWORD, "eax", OperandSize.DWORD, "ecx");
final Pair<RegisterSetLatticeElement, RegisterSetLatticeElement> transformationResult = transformationProvider.transformJcc(instruction, createTaintedState("ecx"));
transformationResult.first().onInstructionExit();
Assert.assertTrue(transformationResult.first().getNewlyTaintedRegisters().isEmpty());
Assert.assertTrue(transformationResult.first().getReadRegisters().isEmpty());
Assert.assertTrue(transformationResult.first().getTaintedRegisters().contains("ecx"));
Assert.assertTrue(transformationResult.first().getUntaintedRegisters().isEmpty());
Assert.assertTrue(transformationResult.first().getUpdatedRegisters().isEmpty());
}
use of com.google.security.zynamics.reil.ReilInstruction in project binnavi by google.
the class BackwardRegisterTrackingTransformationProviderTest method testTransformBisz.
@Test
public void testTransformBisz() {
final RegisterTrackingTransformationProvider transformationProvider = new RegisterTrackingTransformationProvider(new RegisterTrackingOptions(false, new TreeSet<String>(), false, AnalysisDirection.UP));
final ReilInstruction instruction = ReilHelpers.createBisz(0, OperandSize.DWORD, "ecx", OperandSize.DWORD, "eax");
final Pair<RegisterSetLatticeElement, RegisterSetLatticeElement> transformationResult = transformationProvider.transformBisz(instruction, createTaintedState("eax"));
Assert.assertTrue(transformationResult.first().getTaintedRegisters().contains("ecx"));
}
Aggregations