-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathbeaconstorekey-extractor.swift
More file actions
35 lines (29 loc) · 1.31 KB
/
Copy pathbeaconstorekey-extractor.swift
File metadata and controls
35 lines (29 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//
// beaconstorekey-extractor.swift
//
// Decrypt all beacons files from ~/Library/com.apple.icloud.searchpartyd - updated when FindMy is running
// Results in /tmp/com.apple.icloud.searchpartyd - same file hierarchy
//
// Created by Matus on 28/01/2024. - https://gist.github.com/YeapGuy/f473de53c2a4e8978bc63217359ca1e4
// Modified by Airy
//
import Foundation
enum ExtractorError: Error {
case notFound
case invalid
case keychainError(status: OSStatus, description: CFString)
}
let query: [String: Any] = [kSecClass as String: kSecClassGenericPassword,
kSecAttrService as String: "BeaconStore",
kSecMatchLimit as String: kSecMatchLimitOne,
kSecReturnData as String: true,
]
var item: CFTypeRef?
let status = SecItemCopyMatching(query as CFDictionary, &item)
let errorDescription = SecCopyErrorMessageString(status,nil)
guard status != errSecItemNotFound else { throw ExtractorError.notFound }
guard status == errSecSuccess else { throw ExtractorError.keychainError(status: status, description: errorDescription!) }
guard let data = item as? Data else { throw ExtractorError.invalid };
let hexString = data.map { String(format: "%02hhx", $0) }.joined()
print("Found key in keychain:")
print(hexString)