Skip to content

Fixes #81: Supervision mode#82

Open
zner0L wants to merge 8 commits intomainfrom
z_supervision
Open

Fixes #81: Supervision mode#82
zner0L wants to merge 8 commits intomainfrom
z_supervision

Conversation

@zner0L
Copy link
Contributor

@zner0L zner0L commented May 30, 2023

No description provided.

@zner0L zner0L marked this pull request as ready for review June 1, 2023 15:02
@zner0L zner0L requested a review from baltpeter June 1, 2023 15:03
Copy link
Member

@baltpeter baltpeter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enabling and removing supervision did work in my tests, but SSH doesn't come back afterwards (#81 (comment)).

@zner0L zner0L requested a review from baltpeter June 16, 2023 20:38
@baltpeter
Copy link
Member

With my iOS 15 on palera1n-c, SSH does now come back after the userspace restart but I am still getting an error in ensureDevice() if I enable the supervision capability:

node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at __node_internal_captureLargerStackTrace (node:internal/errors:490:5)
    at __node_internal_errnoException (node:internal/errors:620:12)
    at TCP.onStreamRead (node:internal/stream_base_commons:217:20)
Emitted 'error' event on Client instance at:
    at Socket.<anonymous> (/home/benni/coding/JS/tweasel/appstraction/node_modules/ssh2/lib/client.js:745:12)
    at Socket.emit (node:events:513:28)
    at Socket.emit (node:domain:489:12)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -104,
  code: 'ECONNRESET',
  syscall: 'read',
  level: 'client-socket'
}

Removing supervision doesn't throw an error, but that's only because it doesn't wait for the device to come back. If I wanted to run another command afterwards, it would fail.

@baltpeter
Copy link
Member

Curiously, on the other iPhone with iOS 16 (still on palera1n-legacy), it just hangs after removing supervision, even after the process is already done. Afterwards, I need to do "" in the palera1n app to get SSH back.

Enabling supervision also hangs after the phone has "rebooted".

@baltpeter
Copy link
Member

Also, I wouldn't consider this ready to merge unless the device is actually ready to be used again automatically (i.e. unlocked) after enabling or removing supervision.

@zner0L
Copy link
Contributor Author

zner0L commented Jun 21, 2023

I have researched a bit into how to unlock devices automatically, and I would like to finish this, but I am unsure of how much time I should poor into this now. I could try to get it done in 5 hours and if that works out fine we merge and if not, we move on for now.

@baltpeter
Copy link
Member

Five hours is a lot…

: never;

/** Simulates key presses to unlock the screen. This only works if no passcode is set on the device. */
unlockScreen: () => Promise<void>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen unlocking seems like something worthy of inclusion in the README feature list.

Comment on lines +585 to +589
python('pymobiledevice3', ['processes', 'ps', '--no-color']).then(({ stdout }) =>
Object.values(JSON.parse(stdout) as Record<string, Record<string, string>>).some(
(p) => p['ProcessName'] === 'assistivetouchd'
)
),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use Frida's device.enumerateProcesses() since we need Frida here anyway?

Comment on lines +141 to +142
Object.getOwnPropertyNames(atServer)
atServer._home()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Object.getOwnPropertyNames(atServer)
atServer._home()
Object.getOwnPropertyNames(atServer);
atServer._home();

);
// TODO: Enable AssistiveTouch automatically. This can be done via lockdownd, but is not supported by pymobiledevice3, yet.
});
// Since assistivetouchd always crashes after the simulated home button press, we need to wait for it to restart.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't reproduce that crashing on either of my iPhones. But I guess if you want to keep the waiting, you should also wait after the second home button press. Otherwise, I would two unlockScreen() calls to fail1 on your device.

Footnotes

  1. With a prompt to enable Assistive Touch, which is wrong in that case.

*/
setupEnvironment: () => Promise<void>;
ensureFrida: () => Promise<void>;
/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should advertise enabling and disabling supervision without resetting on rooted devices in the feature list as well.

Comment on lines +419 to +427
('supervision' extends Capability
? {
/**
* The password of the private key of the supervision certificate, defaults to `appstraction` if
* not set.
*/
supervisionKeyPassword?: string;
}
: unknown);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't we say we wanted to disable the capability until it is actually needed for anything?

@baltpeter
Copy link
Member

I'm still getting ECONNRESET in the supervision operations during the reboot:

node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

Error: read ECONNRESET
    at __node_internal_captureLargerStackTrace (node:internal/errors:490:5)
    at __node_internal_errnoException (node:internal/errors:620:12)
    at TCP.onStreamRead (node:internal/stream_base_commons:217:20) {
  errno: -104,
  code: 'ECONNRESET',
  syscall: 'read',
  level: 'client-socket'
}

And I'm pretty sure you've already spent a lot more than 5 hours…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants