Skip to content

Instantly share code, notes, and snippets.

@lamprosg
Last active July 28, 2023 14:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lamprosg/6d9bc982dfaef418520f5ad4b026a5e8 to your computer and use it in GitHub Desktop.
Save lamprosg/6d9bc982dfaef418520f5ad4b026a5e8 to your computer and use it in GitHub Desktop.
(iOS) Fingerprinting, identifying a device
//https://nshipster.com/device-identifiers/
//Besides identifierForVendor..
/*
Locale information is the greatest source of identifying information on Apple platforms.
The combination of your preferred languages, region, calendar, time zone,
and which keyboards you have installed say a lot about who you are
especially if you have less conventional preferences.
*/
import Foundation
Locale.current.languageCode
log2(Double(Locale.isoLanguageCodes.count)) // 9.217 bits
Locale.current.regionCode
log2(Double(Locale.isoRegionCodes.count)) // 8 bits
Locale.current.calendar.identifier
// ~2^4 (16) Calendars
TimeZone.current.identifier
log2(Double(TimeZone.knownTimeZoneIdentifiers.count)) // 8.775 bits
UserDefaults.standard.object(forKey: "AppleKeyboards")
// ~2^6 (64) iOS keyboards
//-----------------
//Accessibility
UIAccessibility.isBoldTextEnabled
UIAccessibility.isShakeToUndoEnabled
UIAccessibility.isReduceMotionEnabled
UIAccessibility.isDarkerSystemColorsEnabled
UIAccessibility.isReduceTransparencyEnabled
UIAccessibility.isAssistiveTouchRunning
//-----------------
//Dynamic type check
let application = UIApplication.shared
application.preferredContentSizeCategory
//-----------------
//Hardware Information
//On iOS, you can get the current model and amount of storage of a user’s device:
import UIKit
let device = UIDevice.current
device.name // "iPhone 11 Pro"
let fileManager = FileManager.default
if let path = fileManager.urls(for: .libraryDirectory, in: .systemDomainMask).last?.path,
let systemSize = try? fileManager.attributesOfFileSystem(forPath: path)[.systemSize] as? Int
{
Measurement<UnitInformationStorage>(value: Double(systemSize), unit: .bytes)
.converted(to: .gigabytes) // ~256GB
}
//processor count and amount of RAM:
processInfo.processorCount // 8
Measurement<UnitInformationStorage>(value: Double(processInfo.physicalMemory),
unit: .bytes)
.converted(to: .gigabytes) // 16GB
//-----------------
//Cellular Network
import CoreTelephony
let networkInfo = CTTelephonyNetworkInfo()
let carriers = networkInfo.serviceSubscriberCellularProviders?.values
carriers?.map { ($0.mobileNetworkCode, $0.mobileCountryCode) }
//-----------------
//Communication Preferences (2 bits)
import MessageUI
MFMailComposeViewController.canSendMail()
MFMessageComposeViewController.canSendText()
//-----------------
//Battery health
var timestampedBatteryLevels: [(Date, Float)] = []
if UIDevice.current.isBatteryMonitoringEnabled {
timestampedBatteryLevels.append((Date(), UIDevice.current.batteryLevel))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment