Created
September 16, 2019 01:05
-
-
Save xorhex/5401363d700c9591d227f2d061f3192b to your computer and use it in GitHub Desktop.
Code Snippet 2 - IDAPython script renaming the dword variables.
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
import idc | |
# Function to do the actual renaming of the dword | |
def rename_global_dword(addr, new_name): | |
print 'Old Name %s' % Name(int(addr, 16)) | |
MakeName(int(addr, 16), 'dw_'+new_name) | |
print 'New Name %s' % Name(int(addr, 16)) | |
# Iterate through each line of the text file | |
with open('decoded_api_calls.txt', 'r') as f: | |
for line in f: | |
# Get the address from the first column | |
addr = line.split()[0] | |
# Go to that memory location in the UI | |
Jump(int(addr, 16)) | |
# Get the Comment (DLL + Function Name) from the third column | |
api_name = line.split()[2].strip() | |
# Make sure the size at that location is a dword | |
if ItemSize(int(addr, 16)) < 4: | |
print 'Making %i a dword' %int(addr, 16) | |
MakeDword(int(addr, 16)) | |
# Call our custom function to rename the dword | |
rename_global_dword(addr, api_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment