diff --git a/pymobiledevice3/cli/activation.py b/pymobiledevice3/cli/activation.py index c09827cb..1557c6e0 100644 --- a/pymobiledevice3/cli/activation.py +++ b/pymobiledevice3/cli/activation.py @@ -26,9 +26,10 @@ def state(lockdown): @activation.command(cls=Command) @click.option('--offline', is_flag=True, help='Allow to send and receive requests manually') -def activate(lockdown, offline): +@click.option('--now', is_flag=True, help='when --offline is used, dont wait for next nonce cycle') +def activate(lockdown, offline, now): """ Activate device """ - MobileActivationService(lockdown, offline).activate() + MobileActivationService(lockdown, offline, now).activate() @activation.command(cls=Command) diff --git a/pymobiledevice3/restore/tss.py b/pymobiledevice3/restore/tss.py index e843c5f5..a9d18f34 100644 --- a/pymobiledevice3/restore/tss.py +++ b/pymobiledevice3/restore/tss.py @@ -11,7 +11,7 @@ from pymobiledevice3.restore.img4 import img4_get_component_tag TSS_CLIENT_VERSION_STRING = 'libauthinstall-776.60.1' -TICKETS_SUBDIR = Path('tickets') +TICKETS_SUBDIR = Path('offline_requests') OFFLINE_REQUEST_SCRIPT = """#!/bin/sh curl -d "@{request}" -H 'Cache-Control: no-cache' -H 'Content-type: text/xml; charset="utf-8"' -H 'User-Agent: InetURL/1.0' -H 'Expect: ' 'http://gs.apple.com/TSS/controller?action=2' | tee {response} diff --git a/pymobiledevice3/services/mobile_activation.py b/pymobiledevice3/services/mobile_activation.py index 7d913766..cc2f7da3 100755 --- a/pymobiledevice3/services/mobile_activation.py +++ b/pymobiledevice3/services/mobile_activation.py @@ -20,17 +20,18 @@ 'Expect': '100-continue', } -ACTIVATION_REQUESTS_SUBDIR = Path('activation') +ACTIVATION_REQUESTS_SUBDIR = Path('offline_requests') NONCE_CYCLE_INTERVAL = 60 * 5 class MobileActivationService: SERVICE_NAME = 'com.apple.mobileactivationd' - def __init__(self, lockdown: LockdownClient, offline=True): + def __init__(self, lockdown: LockdownClient, offline=True, now=False): self.logger = logging.getLogger(__name__) self.lockdown = lockdown self.offline = offline + self._now = now self._offline_start = 0 self._offline_end = 0 @@ -41,7 +42,7 @@ def state(self): def activate(self): blob = self.create_activation_session_info() - if self.offline: + if self.offline and not self._now: self.logger.info('waiting for the next 5 minutes cycle') handshake_request_message = blob['HandshakeRequestMessage'] @@ -123,13 +124,15 @@ def post(self, url, data, headers=None): request.chmod(0o755) self.logger.info(f'Run the following shell script ({request.name})') + # Check for plist response. - pb = tqdm.tqdm(total=int(self._offline_end - self._offline_start), desc='Time Left') - pb.update(int(time.time() - self._offline_start)) - while not response.exists() or b'' not in response.read_bytes(): - time.sleep(1) - pb.update(1) - pb.close() + if not self._now: + pb = tqdm.tqdm(total=int(self._offline_end - self._offline_start), desc='Time Left') + pb.update(int(time.time() - self._offline_start)) + while not response.exists() or b'' not in response.read_bytes(): + time.sleep(1) + pb.update(1) + pb.close() # Check for headers. while not headers.exists() or ': ' not in headers.read_text():