Last active
November 21, 2021 05:54
-
-
Save pawlos/b7f25866cc45132d0ef77d46cf683054 to your computer and use it in GitHub Desktop.
Ghidra's script to automate adding of XREFs for lost_in_your_eyes from DiceCTF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#script for https://www.youtube.com/watch?v=FvH7b_qLmbU | |
import struct | |
from ghidra.program.model.symbol import * | |
xrefs = currentProgram.getReferenceManager() | |
startAddr = currentAddress | |
currAddr = currentAddress | |
while True: | |
createDWord(currAddr) | |
data = getBytes(currAddr, 4) | |
v = struct.unpack("<i", data)[0] | |
if v == 0: | |
break | |
dest = startAddr.addWrap(v) | |
xrefs.addMemoryReference(currAddr, dest, RefType.DATA, SourceType.USER_DEFINED, 0) | |
currAddr = currAddr.add(4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment