Skip to content

Instantly share code, notes, and snippets.

@raspiduino
Created September 28, 2023 11:53
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 raspiduino/a4adeb53452dcaa353faf6ce9d1f22aa to your computer and use it in GitHub Desktop.
Save raspiduino/a4adeb53452dcaa353faf6ce9d1f22aa to your computer and use it in GitHub Desktop.
IDAPython script for loading Linux kernel's generated System.map
import idaapi
import idc
import idautils
# Function to open a file dialog and return the selected file path
def select_map_file():
map_file = idaapi.ask_file(0, "*.map", "Select System.map")
return map_file
# Function to parse the map file and create a dictionary of address-function name mappings
def parse_map_file(map_file):
address_function_map = {}
with open(map_file, "r") as file:
for line in file:
if line.strip(): # Skip empty lines
parts = line.split()
if len(parts) >= 2:
address_function_map[int(parts[0], 16)] = parts[2]
return address_function_map
# Function to rename functions in IDA based on the map file
def rename_functions_using_map(map_file):
address_function_map = parse_map_file(map_file)
for ea in idautils.Functions():
if ea in address_function_map.keys():
idc.set_name(ea, address_function_map[ea], SN_NOCHECK | SN_NOWARN)
def main():
map_file = select_map_file()
if map_file:
rename_functions_using_map(map_file)
print("Function renaming completed!")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment