Search in sources :

Example 11 with ReilFunction

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

the class CombineTest method testIndependentBaseRegisters.

@Test
public void testIndependentBaseRegisters() {
    final ReilInstruction instruction1 = ReilHelpers.createAdd(100, OperandSize.DWORD, "esi", OperandSize.DWORD, "4", OperandSize.DWORD, "eax");
    final ReilInstruction instruction2 = ReilHelpers.createAdd(101, OperandSize.DWORD, "edi", OperandSize.DWORD, "8", OperandSize.DWORD, "eax");
    final ReilInstruction instruction3 = ReilHelpers.createStr(102, OperandSize.DWORD, "eax", OperandSize.DWORD, "ebx");
    final ReilBlock block1 = new ReilBlock(Lists.newArrayList(instruction1));
    final ReilBlock block2 = new ReilBlock(Lists.newArrayList(instruction2));
    final ReilBlock block3 = new ReilBlock(Lists.newArrayList(instruction3));
    final ReilEdge edge1 = new ReilEdge(block1, block3, EdgeType.JUMP_UNCONDITIONAL);
    final ReilEdge edge2 = new ReilEdge(block2, block3, EdgeType.JUMP_UNCONDITIONAL);
    ReilBlock.link(block1, block3, edge1);
    ReilBlock.link(block2, block3, edge2);
    final ReilFunction function = new ReilFunction("Fark", new ReilGraph(Lists.newArrayList(block1, block2, block3), Lists.newArrayList(edge1, edge2)));
    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 12 with ReilFunction

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

the class RegisterTrackerTest method setUp.

@Before
public void setUp() throws InternalTranslationException {
    final MockOperandTree operandTreeFirst1 = new MockOperandTree();
    operandTreeFirst1.root = new MockOperandTreeNode(ExpressionType.SIZE_PREFIX, "dword");
    operandTreeFirst1.root.m_children.add(new MockOperandTreeNode(ExpressionType.REGISTER, "ecx"));
    final MockOperandTree operandTreeFirst2 = new MockOperandTree();
    operandTreeFirst2.root = new MockOperandTreeNode(ExpressionType.SIZE_PREFIX, "dword");
    operandTreeFirst2.root.m_children.add(new MockOperandTreeNode(ExpressionType.MEMDEREF, "["));
    operandTreeFirst2.root.m_children.get(0).m_children.add(new MockOperandTreeNode(ExpressionType.OPERATOR, "+"));
    operandTreeFirst2.root.m_children.get(0).m_children.get(0).m_children.add(new MockOperandTreeNode(ExpressionType.REGISTER, "ebp"));
    operandTreeFirst2.root.m_children.get(0).m_children.get(0).m_children.add(new MockOperandTreeNode(ExpressionType.IMMEDIATE_INTEGER, "5"));
    final List<MockOperandTree> operandsFirst = Lists.newArrayList(operandTreeFirst1, operandTreeFirst2);
    m_movInstruction = new MockInstruction(Long.parseLong("5"), "mov", operandsFirst);
    final MockOperandTree operandTreeSecond1 = new MockOperandTree();
    operandTreeSecond1.root = new MockOperandTreeNode(ExpressionType.SIZE_PREFIX, "dword");
    operandTreeSecond1.root.m_children.add(new MockOperandTreeNode(ExpressionType.REGISTER, "ecx"));
    final MockOperandTree operandTreeSecond2 = new MockOperandTree();
    operandTreeSecond2.root = new MockOperandTreeNode(ExpressionType.SIZE_PREFIX, "dword");
    operandTreeSecond2.root.m_children.add(new MockOperandTreeNode(ExpressionType.REGISTER, "edx"));
    final MockOperandTree operandTreesecond3 = new MockOperandTree();
    operandTreesecond3.root = new MockOperandTreeNode(ExpressionType.SIZE_PREFIX, "byte");
    operandTreesecond3.root.m_children.add(new MockOperandTreeNode(ExpressionType.IMMEDIATE_INTEGER, "9"));
    final List<MockOperandTree> operandsSecond = Lists.newArrayList(operandTreeSecond1, operandTreeSecond2, operandTreesecond3);
    m_shldInstruction = new MockInstruction(Long.parseLong("8"), "shld", operandsSecond);
    final MockCodeContainer block = new MockCodeContainer();
    block.m_instructions.add(m_movInstruction);
    block.m_instructions.add(m_shldInstruction);
    final ReilTranslator<MockInstruction> reilTranslator = new ReilTranslator<MockInstruction>();
    m_graph = reilTranslator.translate(environment, block);
    m_function = new ReilFunction("REGISTER_TRACKER_TEST", m_graph);
}
Also used : MockCodeContainer(com.google.security.zynamics.zylib.disassembly.MockCodeContainer) MockOperandTreeNode(com.google.security.zynamics.zylib.disassembly.MockOperandTreeNode) MockInstruction(com.google.security.zynamics.zylib.disassembly.MockInstruction) ReilTranslator(com.google.security.zynamics.reil.translators.ReilTranslator) MockOperandTree(com.google.security.zynamics.zylib.disassembly.MockOperandTree) ReilFunction(com.google.security.zynamics.reil.ReilFunction) Before(org.junit.Before)

Aggregations

ReilFunction (com.google.security.zynamics.reil.ReilFunction)12 Test (org.junit.Test)9 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)6 HashSet (java.util.HashSet)6 MockInstruction (com.google.security.zynamics.zylib.disassembly.MockInstruction)5 MockOperandTree (com.google.security.zynamics.zylib.disassembly.MockOperandTree)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 ReilInstruction (com.google.security.zynamics.reil.ReilInstruction)4 MockOperandTreeNode (com.google.security.zynamics.zylib.disassembly.MockOperandTreeNode)4 ReilBlock (com.google.security.zynamics.reil.ReilBlock)3 ReilEdge (com.google.security.zynamics.reil.ReilEdge)3 ReilGraph (com.google.security.zynamics.reil.ReilGraph)3 InstructionGraphNode (com.google.security.zynamics.reil.algorithms.mono.InstructionGraphNode)3 ValueTrackerElement (com.google.security.zynamics.reil.algorithms.mono.valuetracking.ValueTrackerElement)3 StandardEnvironment (com.google.security.zynamics.reil.translators.StandardEnvironment)3 MockCodeContainer (com.google.security.zynamics.zylib.disassembly.MockCodeContainer)3 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)2 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)2 RegisterSetLatticeElement (com.google.security.zynamics.reil.algorithms.mono2.registertracking.RegisterSetLatticeElement)2