]>
Commit | Line | Data |
---|---|---|
b3971512 A |
1 | #!/usr/bin/python |
2 | # | |
3 | ||
4 | import sys | |
5 | from glob import glob | |
6 | import subprocess | |
7 | import re | |
8 | import os | |
9 | import argparse | |
10 | ||
11 | parser = argparse.ArgumentParser(description='Reset your iCloud Keychain account') | |
12 | parser.add_argument('icloudpassword', help='iCloud password') | |
13 | parser.add_argument('passcode', help='passcode or password of the local device') | |
14 | args = vars(parser.parse_args()) | |
15 | ||
16 | ||
17 | iCloudPassword = args['icloudpassword'] | |
18 | passcode = args['passcode'] | |
19 | ||
20 | def set_security_mac_cmd(): | |
21 | return 'security2' | |
22 | ||
23 | def set_security_ios_cmd(): | |
24 | return 'security' | |
25 | ||
26 | def security_cmd_by_platform(): | |
27 | swVers = subprocess.check_output(["sw_vers"]) | |
28 | deviceInformation = str(swVers, 'utf-8') | |
29 | if "Mac OS X" in deviceInformation: | |
30 | print("using security2 command on macosx") | |
31 | return set_security_mac_cmd() | |
32 | elif "iPhone OS" in deviceInformation: | |
33 | print("using security command on ios") | |
34 | return set_security_ios_cmd() | |
35 | else: | |
36 | print("unsupported platform") | |
37 | sys.exit(1) | |
38 | ||
39 | security_cmd = security_cmd_by_platform() | |
40 | ||
41 | print("resetting octagon") | |
42 | subprocess.check_output(["otctl", "resetoctagon"]) | |
43 | ||
44 | print("resetting ckks") | |
45 | subprocess.check_output(["ckksctl", "reset-cloudkit"]) | |
46 | ||
47 | print("resetting SOS") | |
48 | subprocess.check_output([security_cmd, "sync", "-C"]) | |
49 | subprocess.check_output([security_cmd, "sync", "-P", "$iCloudPassword"]) | |
50 | subprocess.check_output([security_cmd, "sync", "-O"]) | |
51 | ||
52 | print("deleting all escrow records") | |
53 | subprocess.check_output(["stingrayutil", "--deleteAll", "ReallyDeleteAll"]) | |
54 | ||
55 | print("creating new escrow record") | |
56 | subprocess.check_output(["sbdtool", "passcode_request_trigger"]) | |
57 | subprocess.check_output(["sbdtool", "passcode_request_provide_passcode", "$passcode"]) | |
58 |