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
ebe715d5
Commit
ebe715d5
authored
Dec 10, 2020
by
Andrea Gussoni
Browse files
Add IDA script for reparsing the decompiled source
parent
19e1aa2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripting/ida-extraction-scripts/clang-parse-all.sh
0 → 100755
View file @
ebe715d5
#!/bin/bash
if
[
$#
-eq
0
]
;
then
echo
"No arguments supplied"
exit
1
fi
basepath
=
$(
pwd
)
workdir
=
$basepath
/workdir-
$1
ida_sources
=
$workdir
/ida-sources
clang_dir
=
$basepath
/scripting/ida-extraction-scripts/clang-parser/
cyclomatic_dir
=
$workdir
/ida-cyclomatic
if
[
!
-d
$cyclomatic_dir
]
;
then
mkdir
$cyclomatic_dir
;
fi
cd
$ida_sources
for
filename
in
*
do
echo
"Parsing with clang input:
$filename
"
# Copy the file under analysis in the folder with the support scripts.
cp
$filename
$clang_dir
/
cd
$clang_dir
# Remove newlines inhside commands, this will make easier our fixed-point purgin.
clang-format
-style
=
'{ColumnLimit: 5000}'
-i
$filename
# Invoke the normalizer pass for the IDA decompiled output.
./ida-normalizer-wrapper.sh
$filename
# Parse the source with clang
clang-7
-std
=
c11
-S
-emit-llvm
-w
$filename
.normalized.c
# Invoke the analys passes which collect the metrics we are interested in.
revng opt
-cyclomatic
-cyclomatic-output
=
$cyclomatic_dir
/
$filename
.csv
-S
-o
/dev/null
$filename
.normalized.ll
# Remove the temporary files we created.
rm
$filename
$filename
.normalized.c
$filename
.normalized.ll
# Return to the directory with all the decompiled sources.
cd
$ida_sources
done
;
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