Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
artifacts-asiaccs20
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andrea Gussoni
artifacts-asiaccs20
Commits
0be1fd16
Commit
0be1fd16
authored
4 years ago
by
Andrea Gussoni
Browse files
Options
Downloads
Patches
Plain Diff
Add IDA python scripts
parent
98b229be
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripting/ida-extraction-scripts/ida-function-boundaries.py
+71
-0
71 additions, 0 deletions
scripting/ida-extraction-scripts/ida-function-boundaries.py
scripting/ida-extraction-scripts/ida-generate-source.py
+20
-0
20 additions, 0 deletions
scripting/ida-extraction-scripts/ida-generate-source.py
with
91 additions
and
0 deletions
scripting/ida-extraction-scripts/ida-function-boundaries.py
0 → 100755
+
71
−
0
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
)
This diff is collapsed.
Click to expand it.
scripting/ida-extraction-scripts/ida-generate-source.py
0 → 100755
+
20
−
0
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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment