use of com.google.security.zynamics.reil.ReilInstruction in project binnavi by google.
the class BackwardRegisterTrackingTransformationProviderTest method testTransformUndef.
@Test
public void testTransformUndef() {
final RegisterTrackingTransformationProvider transformationProvider = new RegisterTrackingTransformationProvider(new RegisterTrackingOptions(false, new TreeSet<String>(), false, AnalysisDirection.UP));
final ReilInstruction instruction = ReilHelpers.createUndef(0, OperandSize.DWORD, "eax");
final Pair<RegisterSetLatticeElement, RegisterSetLatticeElement> transformationResult = transformationProvider.transformUndef(instruction, createTaintedState("eax"));
Assert.assertNull(transformationResult.second());
transformationResult.first().onInstructionExit();
Assert.assertTrue(transformationResult.first().getTaintedRegisters().isEmpty());
Assert.assertTrue(transformationResult.first().getReadRegisters().isEmpty());
Assert.assertTrue(transformationResult.first().getUntaintedRegisters().contains("eax"));
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 testTransformMulFirstZero.
@Test
public void testTransformMulFirstZero() {
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, String.valueOf("0"), OperandSize.DWORD, "eax");
final Pair<RegisterSetLatticeElement, RegisterSetLatticeElement> transformationResult = transformationProvider.transformMul(instruction, createTaintedState("eax"));
Assert.assertNull(transformationResult.second());
transformationResult.first().onInstructionExit();
Assert.assertTrue(transformationResult.first().getTaintedRegisters().isEmpty());
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 testTransformMulSecondZero.
@Test
public void testTransformMulSecondZero() {
final RegisterTrackingTransformationProvider transformationProvider = new RegisterTrackingTransformationProvider(new RegisterTrackingOptions(false, new TreeSet<String>(), false, AnalysisDirection.UP));
final ReilInstruction instruction = ReilHelpers.createMul(0, OperandSize.DWORD, String.valueOf("0"), OperandSize.DWORD, "ecx", OperandSize.DWORD, "eax");
final Pair<RegisterSetLatticeElement, RegisterSetLatticeElement> transformationResult = transformationProvider.transformMul(instruction, createTaintedState("eax"));
Assert.assertNull(transformationResult.second());
transformationResult.first().onInstructionExit();
Assert.assertTrue(transformationResult.first().getTaintedRegisters().isEmpty());
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 testTransformAddEmptyState.
@Test
public void testTransformAddEmptyState() {
final RegisterTrackingTransformationProvider transformationProvider = new RegisterTrackingTransformationProvider(new RegisterTrackingOptions(false, new TreeSet<String>(), false, AnalysisDirection.UP));
final ReilInstruction instruction = ReilHelpers.createAdd(0, OperandSize.DWORD, "eax", OperandSize.DWORD, "ebx", OperandSize.DWORD, "ecx");
final Pair<RegisterSetLatticeElement, RegisterSetLatticeElement> transformationResult = transformationProvider.transformAdd(instruction, new RegisterSetLatticeElement());
Assert.assertNull(transformationResult.second());
Assert.assertTrue(transformationResult.first().getTaintedRegisters().isEmpty());
}
use of com.google.security.zynamics.reil.ReilInstruction in project binnavi by google.
the class BsfTranslatorTest method testSecond.
@Test
public void testSecond() throws InternalTranslationException, InterpreterException {
interpreter.setRegister("eax", BigInteger.valueOf(0xFFFFFFFFL), OperandSize.DWORD, ReilRegisterStatus.DEFINED);
interpreter.setRegister("ebx", BigInteger.valueOf(0x00000002L), OperandSize.DWORD, ReilRegisterStatus.DEFINED);
final MockOperandTree operandTree1 = new MockOperandTree();
operandTree1.root = new MockOperandTreeNode(ExpressionType.SIZE_PREFIX, "dword");
operandTree1.root.m_children.add(new MockOperandTreeNode(ExpressionType.REGISTER, "eax"));
final MockOperandTree operandTree2 = new MockOperandTree();
operandTree2.root = new MockOperandTreeNode(ExpressionType.SIZE_PREFIX, "dword");
operandTree2.root.m_children.add(new MockOperandTreeNode(ExpressionType.REGISTER, "ebx"));
final List<MockOperandTree> operands = Lists.newArrayList(operandTree1, operandTree2);
final IInstruction instruction = new MockInstruction("bsf", operands);
translator.translate(environment, instruction, instructions);
for (final ReilInstruction mockOperandTree : instructions) {
System.out.println(mockOperandTree);
}
interpreter.interpret(TestHelpers.createMapping(instructions), BigInteger.valueOf(0x100));
assertEquals(4, TestHelpers.filterNativeRegisters(interpreter.getDefinedRegisters()).size());
assertEquals(BigInteger.valueOf(1), interpreter.getVariableValue("eax"));
assertEquals(BigInteger.valueOf(0x00000002L), interpreter.getVariableValue("ebx"));
assertEquals(BigInteger.ZERO, BigInteger.valueOf(interpreter.getMemorySize()));
}
Aggregations