基于trace_natives插件修改完成,仓库地址:Humenger/export_func_code
import
os
from
idaapi
import
plugin_t
from
idaapi
import
PLUGIN_PROC
from
idaapi
import
PLUGIN_OK
import
ida_nalt
import
idaapi
import
idautils
import
idc
import
time
def
getSoPathAndName():
fullpath
=
ida_nalt.get_input_file_path()
filepath,filename
=
os.path.split(fullpath)
return
filepath,filename
def
getSegAddr():
textStart
=
[]
textEnd
=
[]
for
seg
in
idautils.Segments():
if
(idc.get_segm_name(seg)).lower()
=
=
'.text'
or
(
idc.get_segm_name(seg)).lower()
=
=
'text'
:
tempStart
=
idc.get_segm_start(seg)
tempEnd
=
idc.get_segm_end(seg)
textStart.append(tempStart)
textEnd.append(tempEnd)
return
min
(textStart),
max
(textEnd)
class
traceNatives(plugin_t):
flags
=
PLUGIN_PROC
comment
=
"export_func_code"
help
=
""
wanted_name
=
"export_func_code"
wanted_hotkey
=
""
def
init(
self
):
print
(
"export_func_code(v0.1) plugin has been loaded."
)
return
PLUGIN_OK
def
run(
self
, arg):
ea, ed
=
getSegAddr()
so_path, so_name
=
getSoPathAndName()
script_name
=
so_name.split(
"."
)[
0
]
+
"_"
+
str
(
int
(time.time()))
+
".cc"
save_path
=
os.path.join(so_path, script_name)
print
(f
"导出路径:{save_path}"
)
F
=
open
(save_path,
"w+"
, encoding
=
"utf-8"
)
F.write(
"\n#####################################\n"
)
for
func
in
idautils.Functions(ea, ed):
try
:
functionName
=
str
(idaapi.ida_funcs.get_func_name(func))
if
len
(
list
(idautils.FuncItems(func))) >
10
:
arm_or_thumb
=
idc.get_sreg(func,
"T"
)
if
arm_or_thumb:
func
+
=
1
code
=
str
(idaapi.decompile(func))
+
"\n#####################################\n"
print
(code)
F.write(code)
F.flush()
except
Exception as e:
print
(e)
print
(f
"导出完成:{save_path}"
)
F.close()
def
term(
self
):
pass
def
PLUGIN_ENTRY():
return
traceNatives()
import
os
from
idaapi
import
plugin_t
from
idaapi
import
PLUGIN_PROC
from
idaapi
import
PLUGIN_OK
import
ida_nalt
import
idaapi
import
idautils
import
idc
import
time
def
getSoPathAndName():
fullpath
=
ida_nalt.get_input_file_path()
filepath,filename
=
os.path.split(fullpath)
return
filepath,filename
def
getSegAddr():
textStart
=
[]
textEnd
=
[]
for
seg
in
idautils.Segments():
if
(idc.get_segm_name(seg)).lower()
=
=
'.text'
or
(
idc.get_segm_name(seg)).lower()
=
=
'text'
:
tempStart
=
idc.get_segm_start(seg)
tempEnd
=
idc.get_segm_end(seg)
textStart.append(tempStart)
textEnd.append(tempEnd)
return
min
(textStart),
max
(textEnd)
class
traceNatives(plugin_t):
flags
=
PLUGIN_PROC
comment
=
"export_func_code"
help
=
""
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
最后于 2022-11-4 13:01
被逆向涉猎编辑
,原因: