blob: ef44d7d9b32ebaa1807dde73a7c8e65a6f8e667f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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
|