miasm
Reverse engineering framework
miasm.core.cpu Namespace Reference

Classes

class  bitobj
 
class  bs
 
class  bs8
 
class  bs_cond
 
class  bs_divert
 
class  bs_mod_name
 
class  bs_name
 
class  bs_swapargs
 
class  bsi
 
class  bsopt
 
class  cls_mn
 
class  dum_arg
 
class  imm08_noarg
 
class  imm16_noarg
 
class  imm32_noarg
 
class  imm64_noarg
 
class  imm_noarg
 
class  instruction
 
class  int32_noarg
 
class  m_arg
 
class  m_reg
 
class  metamn
 
class  mn_prefix
 
class  reg_info
 
class  reg_info_dct
 
class  reg_noarg
 

Functions

def literal_list (l)
 
def gen_reg (reg_name, sz=32)
 
def gen_reg_bs (reg_name, reg_info, base_cls)
 
def gen_regs (rnames, env, sz=32)
 
def int2expr (tokens)
 
def parse_op (tokens)
 
def parse_id (tokens)
 
def ast_parse_op (tokens)
 
def ast_id2expr (a)
 
def ast_int2expr (a)
 
def neg_int (tokens)
 
def cb_int (tokens)
 
def cb_parse_id (tokens)
 
def cb_op_not (tokens)
 
def merge_ops (tokens, op)
 
def cb_op_and (tokens)
 
def cb_op_xor (tokens)
 
def cb_op_sign (tokens)
 
def cb_op_div (tokens)
 
def cb_op_plusminus (tokens)
 
def cb_op_mul (tokens)
 
def isbin (s)
 
def int2bin (i, l)
 
def myror32 (v, r)
 
def myrol32 (v, r)
 
def swap16 (v)
 
def swap32 (v)
 
def perm_inv (p)
 
def gen_bsint (value, l, args)
 
def branch2nodes (branch, nodes=None)
 
def factor_one_bit (tree)
 
def factor_fields (tree)
 
def factor_fields_all (tree)
 
def graph_tree (tree)
 
def add_candidate_to_tree (tree, c)
 
def add_candidate (bases, c)
 
def getfieldby_name (fields, fname)
 
def getfieldindexby_name (fields, fname)
 
def swap_uint (size, i)
 
def swap_sint (size, i)
 
def sign_ext (v, s_in, s_out)
 

Variables

 log = logging.getLogger("cpuhelper")
 
 console_handler = logging.StreamHandler()
 
 LPARENTHESIS = pyparsing.Literal("(")
 
 RPARENTHESIS = pyparsing.Literal(")")
 
 integer = pyparsing.Word(pyparsing.nums).setParseAction(lambda tokens: int(tokens[0]))
 
 hex_word = pyparsing.Literal('0x') + pyparsing.Word(pyparsing.hexnums)
 
 hex_int = pyparsing.Combine(hex_word).setParseAction(lambda tokens: int(tokens[0], 16))
 
tuple str_int_pos = (hex_int | integer)
 
tuple str_int_neg
 
tuple str_int = str_int_pos | str_int_neg
 
 logicop = pyparsing.oneOf('& | ^ >> << <<< >>>')
 
 signop = pyparsing.oneOf('+ -')
 
 multop = pyparsing.oneOf('* / %')
 
 plusop = pyparsing.oneOf('+ -')
 
 notop = pyparsing.oneOf('!')
 
 andop = pyparsing.oneOf('&')
 
 orop = pyparsing.oneOf('|')
 
 xorop = pyparsing.oneOf('^')
 
 shiftop = pyparsing.oneOf('>> <<')
 
 rotop = pyparsing.oneOf('<<< >>>')
 
 mulop = pyparsing.oneOf('*')
 
 divop = pyparsing.oneOf('/')
 
 variable = pyparsing.Word(pyparsing.alphas + "_$.", pyparsing.alphanums + "_")
 
tuple operand = str_int | variable
 
 base_expr
 
int default_prio = 0x1337
 
int total_scans = 0
 

Function Documentation

◆ add_candidate()

def miasm.core.cpu.add_candidate (   bases,
  c 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_candidate_to_tree()

def miasm.core.cpu.add_candidate_to_tree (   tree,
  c 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ast_id2expr()

def miasm.core.cpu.ast_id2expr (   a)

◆ ast_int2expr()

def miasm.core.cpu.ast_int2expr (   a)

◆ ast_parse_op()

def miasm.core.cpu.ast_parse_op (   tokens)

◆ branch2nodes()

def miasm.core.cpu.branch2nodes (   branch,
  nodes = None 
)
Here is the caller graph for this function:

◆ cb_int()

def miasm.core.cpu.cb_int (   tokens)

◆ cb_op_and()

def miasm.core.cpu.cb_op_and (   tokens)
Here is the call graph for this function:

◆ cb_op_div()

def miasm.core.cpu.cb_op_div (   tokens)

◆ cb_op_mul()

def miasm.core.cpu.cb_op_mul (   tokens)

◆ cb_op_not()

def miasm.core.cpu.cb_op_not (   tokens)

◆ cb_op_plusminus()

def miasm.core.cpu.cb_op_plusminus (   tokens)

◆ cb_op_sign()

def miasm.core.cpu.cb_op_sign (   tokens)

◆ cb_op_xor()

def miasm.core.cpu.cb_op_xor (   tokens)
Here is the call graph for this function:

◆ cb_parse_id()

def miasm.core.cpu.cb_parse_id (   tokens)

◆ factor_fields()

def miasm.core.cpu.factor_fields (   tree)
Here is the caller graph for this function:

◆ factor_fields_all()

def miasm.core.cpu.factor_fields_all (   tree)
Here is the call graph for this function:

◆ factor_one_bit()

def miasm.core.cpu.factor_one_bit (   tree)

◆ gen_bsint()

def miasm.core.cpu.gen_bsint (   value,
  l,
  args 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gen_reg()

def miasm.core.cpu.gen_reg (   reg_name,
  sz = 32 
)
Gen reg expr and parser

◆ gen_reg_bs()

def miasm.core.cpu.gen_reg_bs (   reg_name,
  reg_info,
  base_cls 
)
Generate:
    class bs_reg_name(base_cls):
        reg = reg_info

    bs_reg_name = bs(l=0, cls=(bs_reg_name,))
Here is the caller graph for this function:

◆ gen_regs()

def miasm.core.cpu.gen_regs (   rnames,
  env,
  sz = 32 
)

◆ getfieldby_name()

def miasm.core.cpu.getfieldby_name (   fields,
  fname 
)

◆ getfieldindexby_name()

def miasm.core.cpu.getfieldindexby_name (   fields,
  fname 
)
Here is the caller graph for this function:

◆ graph_tree()

def miasm.core.cpu.graph_tree (   tree)
Here is the call graph for this function:

◆ int2bin()

def miasm.core.cpu.int2bin (   i,
  l 
)
Here is the caller graph for this function:

◆ int2expr()

def miasm.core.cpu.int2expr (   tokens)

◆ isbin()

def miasm.core.cpu.isbin (   s)
Here is the caller graph for this function:

◆ literal_list()

def miasm.core.cpu.literal_list (   l)

◆ merge_ops()

def miasm.core.cpu.merge_ops (   tokens,
  op 
)
Here is the caller graph for this function:

◆ myrol32()

def miasm.core.cpu.myrol32 (   v,
  r 
)
Here is the caller graph for this function:

◆ myror32()

def miasm.core.cpu.myror32 (   v,
  r 
)
Here is the caller graph for this function:

◆ neg_int()

def miasm.core.cpu.neg_int (   tokens)

◆ parse_id()

def miasm.core.cpu.parse_id (   tokens)

◆ parse_op()

def miasm.core.cpu.parse_op (   tokens)

◆ perm_inv()

def miasm.core.cpu.perm_inv (   p)
Here is the caller graph for this function:

◆ sign_ext()

def miasm.core.cpu.sign_ext (   v,
  s_in,
  s_out 
)
Here is the caller graph for this function:

◆ swap16()

def miasm.core.cpu.swap16 (   v)

◆ swap32()

def miasm.core.cpu.swap32 (   v)

◆ swap_sint()

def miasm.core.cpu.swap_sint (   size,
  i 
)
Here is the caller graph for this function:

◆ swap_uint()

def miasm.core.cpu.swap_uint (   size,
  i 
)
Here is the caller graph for this function:

Variable Documentation

◆ andop

miasm.core.cpu.andop = pyparsing.oneOf('&')

◆ base_expr

miasm.core.cpu.base_expr
Initial value:
1 = pyparsing.operatorPrecedence(operand,
2  [(notop, 1, pyparsing.opAssoc.RIGHT, cb_op_not),
3  (andop, 2, pyparsing.opAssoc.RIGHT, cb_op_and),
4  (xorop, 2, pyparsing.opAssoc.RIGHT, cb_op_xor),
5  (signop, 1, pyparsing.opAssoc.RIGHT, cb_op_sign),
6  (mulop, 2, pyparsing.opAssoc.RIGHT, cb_op_mul),
7  (divop, 2, pyparsing.opAssoc.RIGHT, cb_op_div),
8  (plusop, 2, pyparsing.opAssoc.LEFT, cb_op_plusminus),
9  ])

◆ console_handler

miasm.core.cpu.console_handler = logging.StreamHandler()

◆ default_prio

int miasm.core.cpu.default_prio = 0x1337

◆ divop

miasm.core.cpu.divop = pyparsing.oneOf('/')

◆ hex_int

miasm.core.cpu.hex_int = pyparsing.Combine(hex_word).setParseAction(lambda tokens: int(tokens[0], 16))

◆ hex_word

miasm.core.cpu.hex_word = pyparsing.Literal('0x') + pyparsing.Word(pyparsing.hexnums)

◆ integer

miasm.core.cpu.integer = pyparsing.Word(pyparsing.nums).setParseAction(lambda tokens: int(tokens[0]))

◆ log

miasm.core.cpu.log = logging.getLogger("cpuhelper")

◆ logicop

miasm.core.cpu.logicop = pyparsing.oneOf('& | ^ >> << <<< >>>')

◆ LPARENTHESIS

miasm.core.cpu.LPARENTHESIS = pyparsing.Literal("(")

◆ mulop

miasm.core.cpu.mulop = pyparsing.oneOf('*')

◆ multop

miasm.core.cpu.multop = pyparsing.oneOf('* / %')

◆ notop

miasm.core.cpu.notop = pyparsing.oneOf('!')

◆ operand

tuple miasm.core.cpu.operand = str_int | variable

◆ orop

miasm.core.cpu.orop = pyparsing.oneOf('|')

◆ plusop

miasm.core.cpu.plusop = pyparsing.oneOf('+ -')

◆ rotop

miasm.core.cpu.rotop = pyparsing.oneOf('<<< >>>')

◆ RPARENTHESIS

miasm.core.cpu.RPARENTHESIS = pyparsing.Literal(")")

◆ shiftop

miasm.core.cpu.shiftop = pyparsing.oneOf('>> <<')

◆ signop

miasm.core.cpu.signop = pyparsing.oneOf('+ -')

◆ str_int

tuple miasm.core.cpu.str_int = str_int_pos | str_int_neg

◆ str_int_neg

tuple miasm.core.cpu.str_int_neg
Initial value:
1 = (pyparsing.Suppress('-') + \
2  (hex_int | integer)).setParseAction(neg_int)

◆ str_int_pos

tuple miasm.core.cpu.str_int_pos = (hex_int | integer)

◆ total_scans

int miasm.core.cpu.total_scans = 0

◆ variable

miasm.core.cpu.variable = pyparsing.Word(pyparsing.alphas + "_$.", pyparsing.alphanums + "_")

◆ xorop

miasm.core.cpu.xorop = pyparsing.oneOf('^')