summaryrefslogtreecommitdiffstats
path: root/tools/ghidra/gsp-tu104-570.144/scripts/extract_gsp_version.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/ghidra/gsp-tu104-570.144/scripts/extract_gsp_version.py')
-rw-r--r--tools/ghidra/gsp-tu104-570.144/scripts/extract_gsp_version.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/ghidra/gsp-tu104-570.144/scripts/extract_gsp_version.py b/tools/ghidra/gsp-tu104-570.144/scripts/extract_gsp_version.py
new file mode 100644
index 0000000..ef44d7d
--- /dev/null
+++ b/tools/ghidra/gsp-tu104-570.144/scripts/extract_gsp_version.py
@@ -0,0 +1,30 @@
+# Ghidra script to extract version from .fwversion section of GSP binary
+# Usage: analyzeHeadless ... -postScript extract_gsp_version.py
+
+import sys
+
+# Get the current program
+program = getCurrentProgram()
+
+# Get the .fwversion section
+fwversion_section = program.getSection(".fwversion")
+if fwversion_section:
+ # Get the data from the section
+ data = getBytes(fwversion_section.getStart(), fwversion_section.getLength())
+ version_str = data.decode('ascii').strip('\x00')
+ print(f"GSP Firmware Version: {version_str}")
+
+ # Also save to a file
+ with open("/home/rmcore/Git/integdev_gpu_drv/open-iov/tools/ghidra/gsp-tu104-570.144/gsp_version.txt", "w") as f:
+ f.write(version_str)
+else:
+ print("No .fwversion section found")
+
+ # Try to find version in memory
+ listing = program.getListing()
+ for i in range(listing.getNumAddresses()):
+ addr = listing.getAddress(i)
+ data = getBytes(addr, 32)
+ if data and b"570.144" in data:
+ print(f"Found version at {addr}: {data}")
+ break