Skip to content

Instantly share code, notes, and snippets.

@shellcromancer
Created January 26, 2023 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shellcromancer/67c2b1b3fe3ba927bd3a40d7d0b5b997 to your computer and use it in GitHub Desktop.
Save shellcromancer/67c2b1b3fe3ba927bd3a40d7d0b5b997 to your computer and use it in GitHub Desktop.
Binja Snippet to create YARA string for selection
import PySide6
length = current_selection[1] - current_selection[0]
code_bytes = bv.read(here, length).hex()
tuples = [code_bytes[i:i+2] for i in range(0, len(code_bytes), 2)]
yara_str = f"$asm_{hex(here)} = {{{' '.join(tuples)}}}"
clip = PySide6.QtGui.QGuiApplication.clipboard()
clip.setText(yara_str)
log_info(f"Wrote \"{yara_str}\" to the clipboard.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment