Skip to content

Instantly share code, notes, and snippets.

View jslegendre's full-sized avatar

Jeremy Legendre jslegendre

  • Alpine Machine Company
  • Xcode
View GitHub Profile
@saagarjha
saagarjha / README.md
Last active March 12, 2022 08:28
Works around some poor performance in XCBBuildService due to slow reflection machinery (https://twitter.com/_saagarjha/status/1499599539795234816)

To build this:

$ swiftc -emit-object XCBBuildServiceFix.swift -O
$ clang XCBBuildServiceFix.o XCBBuildServiceFix.s -shared -o libXCBBuildServiceFix.dylib -O -L /usr/lib/swift/ -lswiftCore -F /Applications/Xcode.app/Contents/SharedFrameworks/XCBuild.framework/Versions/Current/PlugIns/XCBBuildService.bundle/Contents/Frameworks/ -framework XCBUtil -framework XCBProtocol

Then inject the result into XCBBuildService, which launches from /Applications/Xcode.app/Contents/SharedFrameworks/XCBuild.framework/Versions/Current/PlugIns/XCBBuildService.bundle/Contents/MacOS/XCBBuildService, using your injection tool of choice.

@jakeajames
jakeajames / poc.c
Last active May 1, 2023 19:58
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[];
};
# IDA (disassembler) and Hex-Rays (decompiler) plugin for Apple AMX
#
# WIP research. (This was edited to add more info after someone posted it to
# Hacker News. Click "Revisions" to see full changes.)
#
# Copyright (c) 2020 dougallj
# Based on Python port of VMX intrinsics plugin:
# Copyright (c) 2019 w4kfu - Synacktiv
@zntfdr
zntfdr / invocation.sh
Created July 19, 2020 12:47 — forked from ole/!swiftui-reflection-dump.md
A dump of the SwiftUI.framework binary for the iOS simulator (as of Xcode 12.0 beta 2) using the swift-reflection-dump tool.
# Call this inside the bin directory of a build of the Swift compiler,
# e.g. build/Xcode-ReleaseAssert/swift-macosx-x86_64/Release/bin.
#
# Adjust the path to match your Xode installation or pick a different binary to dump.
#
# Tested with Xcode 12.0 beta 2.
#
# Note: I used a Swift 5.3 compiler build from a few weeks ago that I had laying around.
# Because of ABI stability, I don't think the swift-reflection-dump version has to match
# the compiler version that was used to build the binary, but I'm not 100% sure.
@tom-seddon
tom-seddon / mach.org
Last active November 14, 2024 20:30
Random Mach notes

Random Mach notes

mach_thread_self increments ref count

Each call to mach_thread_self adds another MACH_PORT_RIGHT_SEND refcount. For each call to mach_thread_self, you need to call mach_port_deallocate on the result.

(This does not apply to mach_task_self.)

@knightsc
knightsc / TeslaClient.m
Created June 11, 2019 21:08
Quick XPC client for the teslad daemon which exposes CCDServiceInterface protocol
//
// main.m
// TeslaClient
//
// Created by Scott Knight on 6/11/19.
// Copyright © 2019 Scott Knight. All rights reserved.
//
#import <Foundation/Foundation.h>
@iby
iby / CALayer+CARenderer.swift
Last active June 6, 2023 12:20
Rendering animated CALayer off-screen using CARenderer with MTLTexture, https://stackoverflow.com/q/56150363/458356
import AppKit
import Metal
import QuartzCore
let view = NSView(frame: CGRect(x: 0, y: 0, width: 600, height: 400))
let circle = NSView(frame: CGRect(x: 0, y: 0, width: 50, height: 50))
circle.wantsLayer = true
circle.layer?.backgroundColor = NSColor.red.cgColor
circle.layer?.cornerRadius = 25
@knightsc
knightsc / hijack.c
Created February 26, 2019 21:20
Example of how to hijack a thread on macOS to run code in a remote process
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
#include <mach/mach.h>
#include <mach/mach_vm.h>
#include <dlfcn.h>
#include <objc/runtime.h>
@antoniofrighetto
antoniofrighetto / build-xnu.sh
Last active August 6, 2020 12:59
Script to build any XNU kernel version.
# !/bin/bash
# 2k20 ~antoniofrighetto
# Build any XNU kernel version. Make sure you have the related MacOSX SDK version installed
#
# macOS 10.15.4 kernel compilation successfully tested on macOS 10.15.6 and Xcode 11.6
#
# MACOS_VERSION=10.15.4 BACKUP_SDK=1 OPTIONS=RELEASE,DEVELOPMENT ./build-xnu.sh
# XNU_VERSION=xnu-4570.41.2 ./build-xnu.sh
set_macos_version() {
class Logging(object):
__name__ = 'logger.info(1)'
plist = '/System/Library/Preferences/Logging/Subsystems/'
def __init__(__name__, plist, *args, **kwargs):
super(getLogger/, self).__init__()
logger.info('Input parameters:\n'
'accessibility: "{com.apple.Accessibility.plist}"\n'