Release 1.0.3
- Fix target analyse - Fix function arg count - Fix selected functions by name - Show loaded script - Add extracted function for SDK 34 - Add simple arg
This commit is contained in:
parent
c9b2f8975c
commit
09391e8dac
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -43,6 +43,7 @@ class Cdm:
|
||||||
|
|
||||||
# Determine vendor based on SDK API
|
# Determine vendor based on SDK API
|
||||||
self.script = self._prepare_hook_script(functions)
|
self.script = self._prepare_hook_script(functions)
|
||||||
|
self.logger.info('Successfully loaded script')
|
||||||
self.vendor = self._prepare_vendor()
|
self.vendor = self._prepare_vendor()
|
||||||
|
|
||||||
def _fetch_device_properties(self) -> dict:
|
def _fetch_device_properties(self) -> dict:
|
||||||
|
@ -82,22 +83,20 @@ class Cdm:
|
||||||
functions = program['FUNCTIONS']['FUNCTION']
|
functions = program['FUNCTIONS']['FUNCTION']
|
||||||
|
|
||||||
# Find a target function from a predefined list
|
# Find a target function from a predefined list
|
||||||
target = next((f'@NAME' for f in functions if f['@NAME'] in self.OEM_CRYPTO_API), None)
|
target = next((f['@NAME'] for f in functions if f['@NAME'] in self.OEM_CRYPTO_API), None)
|
||||||
|
|
||||||
# Extract relevant functions
|
# Extract relevant functions
|
||||||
for func in functions:
|
for func in functions:
|
||||||
name = func['@NAME']
|
name = func['@NAME']
|
||||||
params = func['ADDRESS_RANGE']
|
args = len(func.get('REGISTER_VAR', []))
|
||||||
args = len(params) - 1 if isinstance(params, list) else 0
|
|
||||||
|
|
||||||
# Add function if it matches specific criteria
|
# Add function if it matches specific criteria
|
||||||
if (
|
if name not in selected and (
|
||||||
name == target
|
name == target
|
||||||
or any(keyword in name for keyword in ['UsePrivacyMode', 'PrepareKeyRequest'])
|
or any(keyword in name for keyword in ['UsePrivacyMode', 'PrepareKeyRequest'])
|
||||||
or (not target and re.match(r'^[a-z]+$', name) and args >= 6)
|
or (not target and re.match(r'^[a-z]+$', name) and args >= 6)
|
||||||
):
|
):
|
||||||
addr = int(func['@ENTRY_POINT'], 16) - addr_base
|
selected[name] = {'name': name, 'address': hex(int(func['@ENTRY_POINT'], 16) - addr_base)}
|
||||||
selected[addr] = {'name': name, 'address': hex(addr)}
|
|
||||||
except Exception:
|
except Exception:
|
||||||
raise ValueError('Failed to extract functions from Ghidra')
|
raise ValueError('Failed to extract functions from Ghidra')
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -20,8 +20,8 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
# Parse command line arguments for device ID
|
# Parse command line arguments for device ID
|
||||||
parser = argparse.ArgumentParser(description='Extract Widevine L3 keys from an Android device.')
|
parser = argparse.ArgumentParser(description='Extract Widevine L3 keys from an Android device.')
|
||||||
parser.add_argument('--device', required=False, type=str, help='Target Android device ID.')
|
parser.add_argument('-d', '--device', required=False, type=str, help='Target Android device ID.')
|
||||||
parser.add_argument('--functions', required=False, type=Path, help='Ghidra XML functions file.')
|
parser.add_argument('-f', '--functions', required=False, type=Path, help='Ghidra XML functions file.')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue