Created
November 26, 2020 23:56
-
-
Save vxcute/f7ddcdb70f0f4150cb774b79ac78083f to your computer and use it in GitHub Desktop.
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 json | |
# fn_name = "wsprintfW" | |
# api_hash = 0x0B6D391AE | |
export_db = {} | |
def get_api_hash(fn_name): | |
result = 0x2b | |
for c in fn_name: | |
result = result * 0x10f + ord(c) | |
return result & 0x1fffff | |
def transform_hash(api_hash): | |
result = api_hash << 0x10 ^ api_hash ^ 0x8ffcc902; | |
def lookup_hash(api_hash): | |
t_hash = transform_hash(api_hash) | |
return export_db.get(t_hash, "") | |
def setup(json_file): | |
global export_db | |
exports_json = json.loads(open(json_file,'rb').read()) | |
exports_list = exports_json['exports'] | |
for export in exports_list: | |
api_hash = get_api_hash(export) | |
export_db[api_hash] = export | |
def get_imports(base_address): | |
for ptr in range(0,0x2dc,4): | |
hash_value = idc.Dword(base_address + ptr) | |
api_name = lookup_hash(hash_value) | |
if api_name == "": | |
continue | |
idc.MakeName(base_address + ptr, api_name.encode('utf-8')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment