Avoid frida library hook error

This commit is contained in:
hyugogirubato 2024-04-01 13:00:44 +02:00
parent 262efe8c0c
commit a9b86aa2c1
2 changed files with 11 additions and 9 deletions

View File

@ -115,11 +115,8 @@ class Cdm:
session: Session = self.device.attach(p.name)
script: Script = session.create_script(self.script)
script.load()
try:
script.exports_sync.getlibrary(v[3])
if script.exports_sync.getlibrary(v[3]):
details.append(k)
except RPCException:
pass
session.detach()
if not details:
@ -213,9 +210,8 @@ class Cdm:
script.on('message', self._process_message)
script.load()
try:
library_info = script.exports_sync.getlibrary(self.vendor.library)
library_info = script.exports_sync.getlibrary(self.vendor.library)
if library_info:
self.logger.info('Library: %s (%s)', library_info['name'], library_info['path'])
return script.exports_sync.hooklibrary(library_info['name'])
except RPCException:
return False
return False

View File

@ -61,7 +61,13 @@ const print = (level, message) => {
}
// Identifies and returns the specified library.
const getLibrary = (name) => Process.getModuleByName(name);
const getLibrary = (name) => {
try {
return Process.getModuleByName(name);
} catch (e) {
return undefined;
}
};
// Hooks into specified functions within a library, aiming to extract keys and disable privacy mode.
const hookLibrary = (name) => {