Search in sources :

Example 26 with ReilInstruction

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

the class CombineTest method testSimple.

@Test
public void testSimple() {
    final ReilInstruction instruction1 = ReilHelpers.createStr(100, OperandSize.DWORD, "0", OperandSize.DWORD, "eax");
    final ReilInstruction instruction2 = ReilHelpers.createJcc(101, OperandSize.DWORD, "eax", OperandSize.DWORD, "104");
    final ReilInstruction instruction3 = ReilHelpers.createAdd(102, OperandSize.DWORD, "eax", OperandSize.DWORD, "4", OperandSize.DWORD, "ebx");
    final ReilInstruction instruction4 = ReilHelpers.createJcc(103, OperandSize.DWORD, "1", OperandSize.DWORD, "104");
    final ReilInstruction instruction5 = ReilHelpers.createAdd(104, OperandSize.DWORD, "eax", OperandSize.DWORD, "8", OperandSize.DWORD, "ebx");
    final ReilInstruction instruction6 = ReilHelpers.createStr(105, OperandSize.DWORD, "ebx", OperandSize.DWORD, "ecx");
    final ReilBlock block1 = new ReilBlock(Lists.newArrayList(instruction1, instruction2));
    final ReilBlock block2 = new ReilBlock(Lists.newArrayList(instruction3, instruction4));
    final ReilBlock block3 = new ReilBlock(Lists.newArrayList(instruction5));
    final ReilBlock block4 = new ReilBlock(Lists.newArrayList(instruction6));
    final ReilEdge edge1 = new ReilEdge(block1, block2, EdgeType.JUMP_UNCONDITIONAL);
    final ReilEdge edge2 = new ReilEdge(block1, block3, EdgeType.JUMP_UNCONDITIONAL);
    final ReilEdge edge3 = new ReilEdge(block2, block4, EdgeType.JUMP_UNCONDITIONAL);
    final ReilEdge edge4 = new ReilEdge(block3, block4, EdgeType.JUMP_UNCONDITIONAL);
    ReilBlock.link(block1, block2, edge1);
    ReilBlock.link(block1, block3, edge2);
    ReilBlock.link(block2, block4, edge3);
    ReilBlock.link(block3, block4, edge4);
    final ReilFunction function = new ReilFunction("Fark", new ReilGraph(Lists.newArrayList(block1, block2, block3, block4), Lists.newArrayList(edge1, edge2, edge3, edge4)));
    System.out.println(function.getGraph());
    final IStateVector<InstructionGraphNode, ValueTrackerElement> result = ValueTracker.track(function);
    System.out.println(result);
}
Also used : ReilGraph(com.google.security.zynamics.reil.ReilGraph) ReilInstruction(com.google.security.zynamics.reil.ReilInstruction) ReilEdge(com.google.security.zynamics.reil.ReilEdge) ReilBlock(com.google.security.zynamics.reil.ReilBlock) ReilFunction(com.google.security.zynamics.reil.ReilFunction) ValueTrackerElement(com.google.security.zynamics.reil.algorithms.mono.valuetracking.ValueTrackerElement) InstructionGraphNode(com.google.security.zynamics.reil.algorithms.mono.InstructionGraphNode) Test(org.junit.Test)

Example 27 with ReilInstruction

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

the class InterpreterTest method testAdd2.

@Test
public void testAdd2() throws InterpreterException {
    final ReilInterpreter interpreter = new ReilInterpreter(Endianness.LITTLE_ENDIAN, new CpuPolicyX86(), new EmptyInterpreterPolicy());
    final HashMap<BigInteger, List<ReilInstruction>> instructions = new HashMap<BigInteger, List<ReilInstruction>>();
    instructions.put(BigInteger.ZERO, Lists.newArrayList(ReilHelpers.createAdd(0, OperandSize.DWORD, "2147483648", OperandSize.DWORD, "4294967295", OperandSize.QWORD, "t0")));
    interpreter.interpret(instructions, BigInteger.ZERO);
    assertEquals(BigInteger.valueOf(0x17FFFFFFFL), interpreter.getVariableValue("t0"));
}
Also used : ReilInstruction(com.google.security.zynamics.reil.ReilInstruction) ReilInterpreter(com.google.security.zynamics.reil.interpreter.ReilInterpreter) HashMap(java.util.HashMap) CpuPolicyX86(com.google.security.zynamics.reil.interpreter.CpuPolicyX86) BigInteger(java.math.BigInteger) List(java.util.List) EmptyInterpreterPolicy(com.google.security.zynamics.reil.interpreter.EmptyInterpreterPolicy) Test(org.junit.Test)

Example 28 with ReilInstruction

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

the class ReilInstructionTest method testEqualsReflexivity.

@Test
public void testEqualsReflexivity() {
    final ReilInstruction instr0 = createReilInstruction();
    assertTrue(instr0.equals(instr0));
}
Also used : ReilInstruction(com.google.security.zynamics.reil.ReilInstruction) Test(org.junit.Test)

Example 29 with ReilInstruction

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

the class ReilInstructionTest method testEqualsTransitivity.

@Test
public void testEqualsTransitivity() {
    final ReilInstruction instr0 = createReilInstruction();
    final ReilInstruction instr1 = createReilInstruction();
    final ReilInstruction instr2 = createReilInstruction();
    assertTrue(instr0.equals(instr1));
    assertTrue(instr1.equals(instr2));
    assertTrue(instr0.equals(instr2));
}
Also used : ReilInstruction(com.google.security.zynamics.reil.ReilInstruction) Test(org.junit.Test)

Example 30 with ReilInstruction

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

the class ReilInstructionTest method testEqualsSymmetry.

@Test
public void testEqualsSymmetry() {
    final ReilInstruction instr0 = createReilInstruction();
    final ReilInstruction instr1 = createReilInstruction();
    assertTrue(instr0.equals(instr1));
    assertTrue(instr1.equals(instr0));
}
Also used : ReilInstruction(com.google.security.zynamics.reil.ReilInstruction) 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