2

In Ghidra, there is Defined Strings window, that lists all the strings in the binary and their location.

I want to access the strings from Ghidra Python, and to get all the x-refs to those strings.

Any ideas on how is it possible to access this string info from Ghidra Python?

1 Answer 1

3

This is one method to do it.

from ghidra.program.util import DefinedDataIterator
from ghidra.app.util import XReferenceUtil

for string in DefinedDataIterator.definedStrings(currentProgram):
  for ref in XReferenceUtil.getXRefList(string):
    print(string, ref)

There are alternative definedStrings iterators and other ways to use XReferenceUtil in the docs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.