gcobb321 / icloud3

iCloud3 v3 - iCloud3 is an advanced iDevice tracker that uses Apple iCloud account and HA Companion App data for presence detection and location based automations.
MIT License
581 stars 54 forks source link

2FA using SMS only #208

Closed ribz closed 2 years ago

ribz commented 2 years ago

My ipod is too old to allow me to add it as a device to use as a trusted device. Therefore, I rely on SMS to receive my 2fa codes.

When I get icloud3 to sign in, I get the configurator notification, which asks me to "Enter the Apple ID Verification Code sent to the Trusted Device", but there is no trusted device and I have not received an SMS message.

I see here: https://github.com/gcobb321/icloud3/issues/83 that there is/used to be a method for selecting a trusted device, but I don't get this step - possible because I only have a single method to receive 2fa codes?

gcobb321 commented 2 years ago

That capability was removed from iCloud3 many versions ago when Apple started requiring 2fa on devices to access the iCloud account for Location information

ribz commented 2 years ago

Thank you for your response.

I've been looking into this, using pyicloud

The following minimally working example gives me cookies and sessions files which I can copy into HAs .storage directory - and I get location data out.

api = PyiCloudService('xxxxxxx','yyyyyyyy')
devices = api.trusted_devices
device = devices[0] # where this device has deviceClass of SMS
api.send_verification_code(device)

wait for SMS text...

code="123456"
api.validate_2fa_code(code)

So, I'm guessing that it's still possible - as Apple still support SMS for 2fa.

iCloud3 would just need a check to see if all of the deviceTypes in api.trusted_devices are SMS and then call api.send_verification_code() for one of (or allowing selection of which one) of these devices, to ensure a code gets sent out somewhere.

gcobb321 commented 2 years ago

I understand the code changes necessary to put SMS back in. However, that won’t happen since I have no way to test it and to support legacy devices such as yours. That function was removed in v2.3.4. I would suggest installing v2.3.3 which can be found at https://github.com/gcobb321/icloud3/releases/tag/v2.3.3 .

———————— Gary Cobb On Mar 29, 2022, 10:08 AM -0400, Ed Morris @.***>, wrote:

Thank you for your response. I've been looking into this, using pyicloud The following minimally working example gives me cookies and sessions files which I can put into HA - and I get location data out. api = PyiCloudService('xxxxxxx','yyyyyyyy') devices = api.trusted_devices device = devices[0] # where this device has deviceClass of SMS api.send_verification_code(device) api.validate_2fa_code(code) So, I'm guessing that it's still possible - as Apple still support SMS for 2fa. iCloud3 would just need a check to see if all of the deviceTypes in api.trusted_devices are SMS and then call api.send_verification_code() for one of (or allowing selection of which one) of these devices, to ensure a code gets sent out somewhere. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

ribz commented 2 years ago

All iCloud accounts need at least one 'Trusted phone number' attached to them, therefore if you ran the above code for your login - and picked a device listed as SMS (or even a Voice), then you could test that way. The only limiting issue would be your ability to have a list of devices that are all 'SMS'/'Voice', so iCloud3 knows to request an SMS be sent.

You could ignore any user interface stuff, and have a simple addition to the config file of 'authviasms: true' or similar, which makes the first SMS on the account get pinged when (re)auth is required - nothing else would need changing and this should work with any iCloud account, so should be testable.

Thank you

gcobb321 commented 2 years ago

I’m deeply into working on the next r release. Once that is done and released,  feel free to review and mod  the code and issue a PR with the updates for me to review.

———————— Gary Cobb On Mar 31, 2022, 5:54 AM -0400, Ed Morris @.***>, wrote:

All iCloud accounts need at least one 'Trusted phone number' attached to them, therefore if you ran the above code for your login - and picked a device listed as SMS (or even a Voice), then you could test that way. The only limiting issue would be your ability to have a list of devices that are all 'SMS'/'Voice', so iCloud3 knows to request an SMS be sent. You could ignore any user interface stuff, and have a simple addition to the config file of 'authviasms: true' or similar, which makes the first SMS on the account get pinged when (re)auth is required - nothing else would need changing and this should work with any iCloud account, so should be testable. Thank you — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>