티스토리 뷰


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from idautils import *
from idaapi import *
from idc import *
 
def decompile_func(ea):
    if not init_hexrays_plugin():
        return False
 
    f = get_func(ea)
    if f is None:
        return False
 
    try:
        cfunc = decompile(f);
        if cfunc is None:
        # Failed to decompile
            return False
    except Exception as e:
        return 'DecompileFail'
        
    lines = []
    sv = cfunc.get_pseudocode();
    for sline in sv:
        line = tag_remove(sline.line);
    lines.append(line)
    return "\n".join(lines)
 
filename = GetInputFile()
 
decom_buf = list()
 
for segea in Segments():
    for funcea in Functions(segea, SegEnd(segea)):
        functionName = GetFunctionName(funcea)
        for (startea, endea) in Chunks(funcea):
            decompiled_result = decompile_func(startea)
 
            if decompiled_result == False:
                pass
 
            elif decompiled_result == 'DecompileFail':
                pass
                #with open('decompileError_{0}'.format(filename), 'a') as error: error.write(str(hex(startea))+'\n')
 
            else:
                decom_buf.append(str(decompiled_result))
 
buf = '\n'.join(decom_buf)
 
with open('decompiled_{0}.log'.format(filename), 'a') as ohoh: ohoh.write(buf)
 
cs


댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함