Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Andrea Gussoni
artifacts-asiaccs20
Commits
0be1fd16
Commit
0be1fd16
authored
Dec 03, 2020
by
Andrea Gussoni
Browse files
Add IDA python scripts
parent
98b229be
Changes
2
Hide whitespace changes
Inline
Side-by-side
scripting/ida-extraction-scripts/ida-function-boundaries.py
0 → 100755
View file @
0be1fd16
import
idaapi
import
idc
import
os
import
sys
import
json
import
jsonpickle
class
Function
:
def
__init__
(
self
,
name
,
startAddr
,
endAddr
,
instruction_number
):
self
.
name
=
name
self
.
startAddr
=
startAddr
self
.
endAddr
=
endAddr
self
.
basicBlocks
=
[]
self
.
arguments
=
[]
self
.
instruction_number
=
instruction_number
def
addBB
(
self
,
BB
):
self
.
basicBlocks
.
append
(
BB
)
def
addArg
(
self
,
arg
):
self
.
arguments
.
append
(
arg
)
class
BasicBlock
:
def
__init__
(
self
,
startAddr
,
endAddr
):
self
.
startAddr
=
startAddr
self
.
endAddr
=
endAddr
class
Argument
:
def
__init__
(
self
,
location
=
None
):
self
.
location
=
location
functions
=
[]
start
=
SegStart
(
BeginEA
())
for
function_start
in
Functions
(
SegStart
(
start
),
SegEnd
(
start
)):
# Count the number of instructions
instruction_counter
=
0
for
i
in
FuncItems
(
function_start
):
instruction_counter
+=
1
f
=
idaapi
.
FlowChart
(
idaapi
.
get_func
(
function_start
))
curFunc
=
Function
(
GetFunctionName
(
function_start
),
"0x%08x"
%
f
[
0
].
startEA
,
"0x%08x"
%
FindFuncEnd
(
function_start
),
instruction_counter
)
visited
=
set
()
visited
.
add
(
f
[
0
].
startEA
)
wl
=
[
f
[
0
]]
while
len
(
wl
)
>
0
:
bb
=
wl
.
pop
()
start
=
"0x%08x"
%
bb
.
startEA
end
=
"0x%08x"
%
bb
.
endEA
block
=
BasicBlock
(
start
,
end
)
curFunc
.
basicBlocks
.
append
(
block
)
for
successor
in
bb
.
succs
():
if
successor
.
startEA
not
in
visited
:
visited
.
add
(
successor
.
startEA
)
wl
.
append
(
successor
)
functions
.
append
(
curFunc
)
with
open
(
idc
.
ARGV
[
1
],
"w"
)
as
output
:
json
.
dump
(
json
.
loads
(
jsonpickle
.
encode
(
functions
,
unpicklable
=
False
)),
output
,
indent
=
4
)
idc
.
Exit
(
0
)
scripting/ida-extraction-scripts/ida-generate-source.py
0 → 100755
View file @
0be1fd16
import
idaapi
import
idc
import
os
import
sys
outputfile
=
idc
.
ARGV
[
1
]
# Load the right plugin
is_ida64
=
GetIdbPath
().
endswith
(
".i64"
)
# hackhackhack - check if we're ida64 or ida32
print
(
is_ida64
)
if
is_ida64
:
idaapi
.
load_plugin
(
'hexx64'
)
else
:
idaapi
.
load_plugin
(
'hexarm'
)
idaapi
.
decompile_many
(
outputfile
,
None
,
0
)
idc
.
Exit
(
0
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment