Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cwe_checker
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-depend
cwe_checker
Commits
b37eb16f
Commit
b37eb16f
authored
Jan 10, 2020
by
Enkelmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replaced Ghidra address computation workaround by correct API function
parent
9a57a3cc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
cwe_checker_ghidra_plugin.py
ghidra_plugin/cwe_checker_ghidra_plugin.py
+11
-6
No files found.
ghidra_plugin/cwe_checker_ghidra_plugin.py
View file @
b37eb16f
...
...
@@ -6,6 +6,7 @@
# - Open the binary in Ghidra and run this file as a script. Select the generated json file when prompted.
import
json
from
ghidra.app.util.opinion
import
ElfLoader
def
bookmark_cwe
(
ghidra_address
,
text
):
...
...
@@ -45,12 +46,16 @@ def compute_ghidra_address(address_string):
fixed_address_string
=
address_string
.
replace
(
':32u'
,
''
)
.
replace
(
':64u'
,
''
)
address_int
=
int
(
fixed_address_string
,
16
)
# Ghidra sometimes adds an offset to all addresses.
# Unfortunately, I havent't found a way to reliably detect this yet.
# Instead we detect the obvious case and hope that it works in most cases.
if
address_int
<
currentProgram
.
getMinAddress
()
.
getOffset
():
return
currentProgram
.
getMinAddress
()
.
add
(
address_int
)
else
:
return
currentProgram
.
getAddressFactory
()
.
getAddress
(
fixed_address_string
)
try
:
# try for ELF-files
offset
=
currentProgram
.
getMinAddress
()
.
getOffset
()
-
int
(
ElfLoader
.
getElfOriginalImageBase
(
currentProgram
))
return
currentProgram
.
getAddressFactory
()
.
getAddress
(
fixed_address_string
)
.
add
(
offset
)
except
:
# the file is probably not an ELF file, so we use a workaround that should work in most cases.
if
address_int
<
currentProgram
.
getMinAddress
()
.
getOffset
():
return
currentProgram
.
getMinAddress
()
.
add
(
address_int
)
else
:
return
currentProgram
.
getAddressFactory
()
.
getAddress
(
fixed_address_string
)
def
main
():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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