]>
git.saurik.com Git - apple/security.git/blob - keychain/ResetCloudKeychainAccount/reset_ick_account
1 #!/usr/local/bin/python3
10 parser
= argparse
.ArgumentParser(description
='Reset your iCloud Keychain account')
11 parser
.add_argument('icloudpassword', help='iCloud password')
12 parser
.add_argument('passcode', help='passcode or password of the local device')
13 args
= vars(parser
.parse_args())
16 iCloudPassword
= args
['icloudpassword']
17 passcode
= args
['passcode']
19 def set_security_mac_cmd():
22 def set_security_ios_cmd():
25 def security_cmd_by_platform():
26 swVers
= subprocess
.check_output(["sw_vers"])
27 deviceInformation
= swVers
.decode('utf-8')
28 if "Mac OS X" in deviceInformation
or "macOS" in deviceInformation
:
29 print("using security2 command on macos")
30 return set_security_mac_cmd()
31 elif "iPhone OS" in deviceInformation
:
32 print("using security command on ios")
33 return set_security_ios_cmd()
35 print("unsupported platform")
38 security_cmd
= security_cmd_by_platform()
40 print("deleting all escrow records")
41 subprocess
.check_output(["stingrayutil", "--deleteAll", "ReallyDeleteAll"])
43 print("resetting SOS")
44 subprocess
.check_output([security_cmd
, "sync", "-C"])
45 subprocess
.check_output([security_cmd
, "sync", "-P", "$iCloudPassword"])
46 subprocess
.check_output([security_cmd
, "sync", "-O"])
48 print("resetting octagon")
49 subprocess
.check_output(["otctl", "resetoctagon"])
51 print("creating new escrow record")
52 subprocess
.check_output(["sbdtool", "passcode_request_trigger"])
53 subprocess
.check_output(["sbdtool", "passcode_request_provide_passcode", "$passcode"])