Skip to content

Instantly share code, notes, and snippets.

View DerekSelander's full-sized avatar
👠
Set your status

Derek DerekSelander

👠
Set your status
View GitHub Profile
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/ioctl.h> // for _IOW, a macro required by FSEVENTS_CLONE
#include <sys/types.h> // for uint32_t and friends, on which fsevents.h relies
#include <unistd.h>
#include <string.h> // memset
//#include <sys/_types.h> // for uint32_t and friends, on which fsevents.h relies
#include <sys/stat.h> // for mkdir
csrutil disable
sudo nvram boot-args="intcoproc_unrestricted=1 kext-dev-mode=1 amfi_allow_any_signature=1 amfi_unrestrict_task_for_pid=1 PE_i_can_has_debugger=1 cs_enforcement_disable=1 amfi_get_out_of_my_way=1 amfi=0xff cs_debug=1 ipc_control_port_options=0"
sudo spctl --global-disable
sudo defaults write /Library/Preferences/com.apple.security.coderequirements Entitlements -string always
sudo defaults write /Library/Preferences/com.apple.security.coderequirements AllowUnsafeDynamicLinking -bool YES
sudo defaults write /Library/Preferences/com.apple.security.libraryvalidation.plist DisableLibraryValidation -bool YES
defaults write com.apple.loginwindow DisableScreenLockImmediate -bool yes
@DerekSelander
DerekSelander / dbgspawn.c
Last active October 4, 2023 03:01
A quick Darwin helper tool to diagnose why your program keeps crashing
//
// A simple arm64[e] launcher program that catches program crashes and spits out every thread's state and backtrace
//
// dbgspawn.c
// Created by Derek Selander on 9/27/23.
// Permissive License: do whatever, so long as you keep this header & note that I am not responsible for any damages
//
/* To build for iOS on macOS
@DerekSelander
DerekSelander / karabiner.json
Last active April 10, 2023 16:40
Derek's Karabiner stuff -> ~/.config/karabiner/karabiner.json
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
@DerekSelander
DerekSelander / ipc_poc.c
Created November 19, 2022 13:51
A hello world for complex mach messages
#include <CoreFoundation/CoreFoundation.h>
#include <mach/mach.h>
#define plog(str,args...) printf("[%6d] "str"\n",getpid(), ##args)
#define HandleError(kr) if (kr != KERN_SUCCESS) {\
printf("error: line %d in PID: %d, (%d) 0x%x, %s\n", __LINE__,\
getpid(), kr, kr, mach_error_string(kr));\
exit(1);}
struct favorite_animal_msg {
@DerekSelander
DerekSelander / poc.c
Created February 28, 2022 18:05 — forked from jakeajames/poc.c
CVE-2021-30955 PoC
#include <stdlib.h>
#include <stdio.h>
#include <pthread/pthread.h>
#include <mach/mach.h>
struct ool_msg {
mach_msg_header_t hdr;
mach_msg_body_t body;
mach_msg_ool_ports_descriptor_t ool_ports[];
};
@DerekSelander
DerekSelander / platform_swap.m
Last active June 1, 2024 22:16
Exchange Mach-O platform types with min version
//
// main.m
// platform_swap @LOLgrep
// clang -o /tmp/platform_swap /path/to/platform_swap.m -framework Foundation
#import <Foundation/Foundation.h>
#import <mach-o/fat.h>
#import <mach-o/loader.h>
struct version {
@DerekSelander
DerekSelander / builtin_print_struct.c
Last active November 7, 2021 04:23
Showcase __builtin_dump_struct
//
// clang builtin_print_struct.c && ./a.out
//
// Created by Derek Selander
// dyld_all_image_infos header courtsey of dyld's opensource.apple.com
//
#include <mach/mach.h>
#include <mach/task_info.h>
#include <stdio.h>
xcrun -sdk iphoneos clang -fobjc-arc -arch arm64 -fmodules -g main.m
@DerekSelander
DerekSelander / gist:299f2c3b0443ee785d1508a3220f2aa9
Created September 20, 2020 04:47
Useful Commands to Speed up Global Warming
# Get llvm/clang/lldb shit to build in Xcode and not Ninja or VS Code
cmake -DLLVM_ENABLE_PROJECTS=clang ../llvm -G Xcode -DLLVM_INCLUDE_TESTS=FALSE -DLLVM_TARGETS_TO_BUILD="AArch64;X86" -DLLVM_ENABLE_IDE=TRUE