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:
hyugogirubato 2024-04-01 18:04:51 +02:00
parent c9b2f8975c
commit 09391e8dac
5 changed files with 128291 additions and 13875 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -43,6 +43,7 @@ class Cdm:
# Determine vendor based on SDK API
self.script = self._prepare_hook_script(functions)
self.logger.info('Successfully loaded script')
self.vendor = self._prepare_vendor()
def _fetch_device_properties(self) -> dict:
@ -82,22 +83,20 @@ class Cdm:
functions = program['FUNCTIONS']['FUNCTION']
# 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
for func in functions:
name = func['@NAME']
params = func['ADDRESS_RANGE']
args = len(params) - 1 if isinstance(params, list) else 0
args = len(func.get('REGISTER_VAR', []))
# Add function if it matches specific criteria
if (
if name not in selected and (
name == target
or any(keyword in name for keyword in ['UsePrivacyMode', 'PrepareKeyRequest'])
or (not target and re.match(r'^[a-z]+$', name) and args >= 6)
):
addr = int(func['@ENTRY_POINT'], 16) - addr_base
selected[addr] = {'name': name, 'address': hex(addr)}
selected[name] = {'name': name, 'address': hex(int(func['@ENTRY_POINT'], 16) - addr_base)}
except Exception:
raise ValueError('Failed to extract functions from Ghidra')

64142
functions_x86.xml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -20,8 +20,8 @@ if __name__ == '__main__':
# Parse command line arguments for device ID
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('--functions', required=False, type=Path, help='Ghidra XML functions file.')
parser.add_argument('-d', '--device', required=False, type=str, help='Target Android device ID.')
parser.add_argument('-f', '--functions', required=False, type=Path, help='Ghidra XML functions file.')
args = parser.parse_args()
try: