示例#1
0
def di(bin_s):
    '''
    Disassemble some x86 assembly
    di(\x90A\x90)
    '''
    bin = hexa_representation_to_bytes(bin_s)
    if bin == None:
        return 'An error occured'

    job_done, symbol_pool = set(), asmbloc.asm_symbol_pool()
    all_bloc = asmbloc.dis_bloc_all(x86_mn, bin_stream(bin), 0, job_done, symbol_pool)
    
    disassembly_dic = {}
    for i in all_bloc:
        for b in i.lines:
            # hmm ok, re-order the different instruction from each blocs
            disassembly_dic[b.offset] = b
            
    disass, offset = '', 0
    for k in sorted(disassembly_dic.keys()):
        # add the label for the different blocs ; except for the main label
        if symbol_pool.getby_offset(k) and k != 0:
            disass += '%s: ' % symbol_pool.getby_offset(k).name
        disass += '%s ; ' % clean_assembly(str(disassembly_dic[k]))
    if disass == '':
        return 'No disassembly found.'
    return disass
示例#2
0
def disasm_at_addr(in_str, ad_to_dis, symbol_pool):
    kargs = {}
    all_bloc = asmbloc.dis_bloc_all(arm_arch.arm_mn, in_str, ad_to_dis, set(),
                                    symbol_pool=symbol_pool,
                                    dontdis_retcall=False,
                                    follow_call=False,
                                    **kargs)
    for i in all_bloc:
        bytecode._PrintDefault("%s\n" % i.label)
        for j in i.lines:
            bytecode._PrintDefault("\t %s\n" % j)
        bytecode._PrintDefault("\n")
示例#3
0
def disasm_at_addr(in_str, ad_to_dis, symbol_pool):
    kargs = {}
    all_bloc = asmbloc.dis_bloc_all(arm_arch.arm_mn, in_str, ad_to_dis, set(),
                                        symbol_pool=symbol_pool,
                                        dontdis_retcall = False,
                                        follow_call = False,
                                        **kargs)
    for i in all_bloc:
        bytecode._PrintDefault("%s\n" % i.label)
        for j in i.lines:
            bytecode._PrintDefault("\t %s\n" % j)
        bytecode._PrintDefault("\n")
示例#4
0
    def __disassembleMiasm(self, data, address, mn, dll_dyn_funcs):
        in_str = bin_stream(data)
        job_done = set()
        symbol_pool = asmbloc.asm_symbol_pool()
        for (n,f), ads in dll_dyn_funcs.items():
            for ad in ads:
                l  = symbol_pool.getby_name_create("%s_%s"%(n, f))
                l.offset = ad
                symbol_pool.s_offset[l.offset] = l

        all_bloc = asmbloc.dis_bloc_all(mn, in_str, address, job_done, symbol_pool, follow_call = True, lines_wd = 60)
        lines = []
        for bloc in all_bloc:
            lines.append(str(bloc))
        return ('\n'.join(lines))