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
797ab5c2
Commit
797ab5c2
authored
Oct 09, 2020
by
Andrea Gussoni
Browse files
Add Ghidra decompilation plugin
parent
cef588a1
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripting/ghidra-extraction-scripts/DecompileAll.java
0 → 100644
View file @
797ab5c2
private
void
exportToC
(
DecompileResults
results
)
{
try
{
ClangTokenGroup
grp
=
results
.
getCCodeMarkup
();
if
(
grp
!=
null
)
{
File
tmpFile
=
new
File
(
"~/headless-sources"
+
"/"
+
results
.
getFunction
().
getName
()
+
".c"
);
PrintWriter
writer
=
new
PrintWriter
(
new
FileOutputStream
(
tmpFile
));
PrettyPrinter
printer
=
new
PrettyPrinter
(
results
.
getFunction
(),
grp
);
DecompiledFunction
decompFunc
=
printer
.
print
(
true
);
writer
.
write
(
decompFunc
.
getC
());
writer
.
close
();
}
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
e
.
getStackTrace
());
}
}
@Override
public
void
run
()
throws
Exception
{
var
program
=
this
.
getCurrentProgram
();
DecompInterface
ifc
=
new
DecompInterface
();
ifc
.
openProgram
(
program
);
for
(
var
func
:
program
.
getFunctionManager
().
getFunctions
(
true
))
{
var
results
=
ifc
.
decompileFunction
(
func
,
100000
,
null
);
exportToC
(
results
);
}
}
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