From 3628e42f45b02635e3aa150a131e39e62d96b8ed Mon Sep 17 00:00:00 2001 From: hyugogirubato <65763543+hyugogirubato@users.noreply.github.com> Date: Sat, 1 Mar 2025 14:16:02 +0100 Subject: [PATCH] fix symbols analysis crash --- keydive/core.py | 4 +++- keydive/keydive.js | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/keydive/core.py b/keydive/core.py index 1d103dd..ca4a005 100644 --- a/keydive/core.py +++ b/keydive/core.py @@ -215,7 +215,9 @@ class Core: elif not minimum and vendor.oem > 17 and not self.functions: self.logger.warning("For OEM API > 17, specifying '--functions' is required. Refer to https://github.com/hyugogirubato/KeyDive/blob/main/docs/FUNCTIONS.md") - return script.exports_sync.hooklibrary(library["name"]) + # Enable dynamic analysis (symbols) only when necessary + dynamic = minimum and vendor.oem > 17 and not self.functions + return script.exports_sync.hooklibrary(library["name"], dynamic) # Unload the script if the target library is not found. script.unload() diff --git a/keydive/keydive.js b/keydive/keydive.js index 00136e9..ff1afc4 100644 --- a/keydive/keydive.js +++ b/keydive/keydive.js @@ -84,14 +84,14 @@ const getLibrary = (name) => { return libraries.length === 1 ? libraries[0] : undefined; } -const getFunctions = (library) => { +const getFunctions = (library, dynamic) => { try { // https://frida.re/news/2025/01/09/frida-16-6-0-released/ - const functions = library.enumerateSymbols().map(item => ({ + const functions = dynamic ? library.enumerateSymbols().map(item => ({ type: item.type, name: item.name, address: item.address - })); + })) : []; library.enumerateExports().forEach(item => { if (!functions.includes(item)) { @@ -111,7 +111,7 @@ const disableLibrary = (name) => { const library = getLibrary(name); if (library) { // https://github.com/hyugogirubato/KeyDive/issues/23#issuecomment-2230374415 - const functions = getFunctions(library); + const functions = getFunctions(library, false); const disabled = []; functions.forEach(func => { @@ -395,7 +395,7 @@ const RunningCRC = (address) => { // @Hooks -const hookLibrary = (name) => { +const hookLibrary = (name, dynamic) => { // https://github.com/poxyran/misc/blob/master/frida-enumerate-imports.py let library = getLibrary(name); if (!library) return false; @@ -409,7 +409,7 @@ const hookLibrary = (name) => { address: library.base.add(s.address) })); } else { - functions = getFunctions(library); + functions = getFunctions(library, dynamic); } functions = functions.filter(f => !NATIVE_C_API.includes(f.name));