Created
May 19, 2022 20:39
-
-
Save migueldeicaza/adb5a3ccabab75a14381d02b25d6942e to your computer and use it in GitHub Desktop.
Dumps passwords from the iOS keychain
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func dump () { | |
let k = kSecClassGenericPassword | |
let query: [String: Any] = [ | |
kSecClass as String: k, | |
kSecMatchLimit as String: kSecMatchLimitAll, | |
kSecReturnRef as String: true, | |
kSecReturnAttributes as String: true | |
] | |
var itemCopy: AnyObject? | |
let status = SecItemCopyMatching(query as CFDictionary, &itemCopy) | |
if status != 0 { | |
print ("Dump passwords is unable to dump") | |
} | |
if let array = itemCopy as? NSArray { | |
print ("Found \(array.count) elements") | |
for element in array { | |
if let dict = element as? NSDictionary { | |
//let ref = dict.object(forKey: kSecValueRef) | |
if let desc = dict.object(forKey: kSecAttrDescription) { | |
print (" description = \(desc)") | |
} | |
if let comment = dict.object(forKey: kSecAttrComment) { | |
print (" comment = \(comment)") | |
} | |
if let label = dict.object(forKey: kSecAttrLabel) { | |
print (" label = \(label)") | |
} | |
if let account = dict.object(forKey: kSecAttrAccount) { | |
print (" account = \(account)") | |
} | |
} | |
} | |
} else { | |
print ("Dump: was expecting an array, did not get it") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment