Beispiel #1
0
import unittest
import logging
import copy

from miasm2.ir.symbexec import symbexec
from miasm2.arch.x86.arch import mn_x86 as mn
from miasm2.arch.x86.sem import ir_x86_32 as ir_32, ir_x86_64 as ir_64
from miasm2.arch.x86.regs import *
from miasm2.expression.expression import *
from miasm2.expression.simplifications      import expr_simp
from miasm2.core import parse_asm, asmbloc


logging.getLogger('cpuhelper').setLevel(logging.ERROR)
EXCLUDE_REGS = set([ir_32().IRDst, ir_64().IRDst])

m32 = 32
m64 = 64

def symb_exec(interm, inputstate, debug):
    sympool = dict(regs_init)
    sympool.update(inputstate)
    symexec = symbexec(interm, sympool)
    symexec.emul_ir_blocs(interm, 0)
    if debug:
        for k, v in symexec.symbols.items():
            if regs_init.get(k, None) != v:
                print k, v
    return {k: v for k, v in symexec.symbols.items()
            if k not in EXCLUDE_REGS and regs_init.get(k, None) != v}
Beispiel #2
0
# Loosely based on ARM's sem.py

import unittest
import logging
import copy

from miasm2.ir.symbexec import SymbolicExecutionEngine
from miasm2.arch.x86.arch import mn_x86 as mn
from miasm2.arch.x86.sem import ir_x86_32 as ir_32, ir_x86_64 as ir_64
from miasm2.arch.x86.regs import *
from miasm2.expression.expression import *
from miasm2.expression.simplifications import expr_simp
from miasm2.core import parse_asm, asmblock

logging.getLogger('cpuhelper').setLevel(logging.ERROR)
EXCLUDE_REGS = set([ir_32().IRDst, ir_64().IRDst])

m32 = 32
m64 = 64


def symb_exec(interm, inputstate, debug):
    sympool = dict(regs_init)
    sympool.update(inputstate)
    symexec = SymbolicExecutionEngine(interm, sympool)
    symexec.emul_ir_blocks(0)
    if debug:
        for k, v in symexec.symbols.items():
            if regs_init.get(k, None) != v:
                print k, v
    return {