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/liboffsetfinder64/liboffsetfinder64.hpp
Views: 11784
//1// offsetfinder64.hpp2// offsetfinder643//4// Created by tihmstar on 10.01.18.5// Copyright © 2018 tihmstar. All rights reserved.6//78#ifndef offsetfinder64_hpp9#define offsetfinder64_hpp1011#include <string>12#include <stdint.h>13#include <mach-o/loader.h>14#include <mach-o/nlist.h>15#include <mach-o/dyld_images.h>16#include <vector>17#include <functional>1819#include <stdlib.h>20#include "common.h"21#include "insn.hpp"22#include "exception.hpp"23#include "patch.hpp"2425namespace tihmstar {26class offsetfinder64 {27public:28enum tristate{29kfalse = 0,30ktrue = 1,31kuninitialized = 232};33private:34bool _freeKernel;35bool _kernelIsSlid;36uint64_t _kslide;37uint8_t *_kdata;38size_t _ksize;39patchfinder64::loc_t _kernel_entry;40patchfinder64::loc_t _kernel_base;41std::vector<patchfinder64::text_t> _segments;42tristate _haveSymtab = kuninitialized;4344struct symtab_command *__symtab;45void loadSegments();46__attribute__((always_inline)) struct symtab_command *getSymtab();4748public:49offsetfinder64(const char *filename, uint64_t kslide = 0, tristate haveSymbols = kuninitialized);50offsetfinder64(void* buf, size_t size, uint64_t kslide, tristate haveSymbols = kfalse);51const void *kdata();52patchfinder64::loc_t find_entry();53patchfinder64::loc_t find_base();54const std::vector<patchfinder64::text_t> &segments(){return _segments;};55bool haveSymbols();5657patchfinder64::loc_t memmem(const void *little, size_t little_len);58uint64_t deref(patchfinder64::loc_t pos);5960patchfinder64::loc_t find_sym(const char *sym);61patchfinder64::loc_t find_syscall0();62uint64_t find_register_value(patchfinder64::loc_t where, int reg, patchfinder64::loc_t startAddr = 0);6364/*------------------------ v0rtex -------------------------- */65patchfinder64::loc_t find_zone_map();66patchfinder64::loc_t find_kernel_map();67patchfinder64::loc_t find_kernel_task();68patchfinder64::loc_t find_realhost();69patchfinder64::loc_t find_bzero();70patchfinder64::loc_t find_bcopy();71patchfinder64::loc_t find_copyout();72patchfinder64::loc_t find_copyin();73patchfinder64::loc_t find_ipc_port_alloc_special();74patchfinder64::loc_t find_ipc_kobject_set();75patchfinder64::loc_t find_ipc_port_make_send();76patchfinder64::loc_t find_chgproccnt();77patchfinder64::loc_t find_kauth_cred_ref();78patchfinder64::loc_t find_osserializer_serialize();79uint32_t find_vtab_get_external_trap_for_index();80uint32_t find_vtab_get_retain_count();81uint32_t find_iouserclient_ipc();82uint32_t find_ipc_space_is_task();83uint32_t find_ipc_space_is_task_11();84uint32_t find_proc_ucred();85uint32_t find_task_bsd_info();86uint32_t find_vm_map_hdr();87uint32_t find_task_itk_self();88uint32_t find_task_itk_registered();89uint32_t find_sizeof_task();9091patchfinder64::loc_t find_rop_add_x0_x0_0x10();92patchfinder64::loc_t find_rop_ldr_x0_x0_0x10();93patchfinder64::loc_t find_exec(std::function<bool(patchfinder64::insn &i)>cmpfunc);949596/*------------------------ kernelpatches -------------------------- */97patchfinder64::patch find_i_can_has_debugger_patch_off();98patchfinder64::patch find_lwvm_patch_offsets();99patchfinder64::patch find_remount_patch_offset();100std::vector<patchfinder64::patch> find_nosuid_off();101patchfinder64::patch find_proc_enforce();102patchfinder64::patch find_amfi_patch_offsets();103patchfinder64::patch find_cs_enforcement_disable_amfi();104patchfinder64::patch find_amfi_substrate_patch();105patchfinder64::patch find_sandbox_patch();106patchfinder64::loc_t find_sbops();107patchfinder64::patch find_nonceEnabler_patch();108patchfinder64::patch find_nonceEnabler_patch_nosym();109110111/*------------------------ KPP bypass -------------------------- */112patchfinder64::loc_t find_gPhysBase();113patchfinder64::loc_t find_gPhysBase_nosym();114patchfinder64::loc_t find_kernel_pmap();115patchfinder64::loc_t find_kernel_pmap_nosym();116patchfinder64::loc_t find_cpacr_write();117patchfinder64::loc_t find_idlesleep_str_loc();118patchfinder64::loc_t find_deepsleep_str_loc();119120/*------------------------ Util -------------------------- */121patchfinder64::loc_t find_rootvnode();122patchfinder64::loc_t find_allproc();123124125~offsetfinder64();126};127}128129130131#endif /* offsetfinder64_hpp */132133134