Skip to content

Instantly share code, notes, and snippets.

View 0xced's full-sized avatar

Cédric Luthi 0xced

View GitHub Profile
@jtbandes
jtbandes / decode-dyn-uti.swift
Last active May 21, 2024 02:42
Dynamic UTI decoding
/// Decodes a dynamically-generated Uniform Type Identifier for inspection purposes. (**NOT FOR PRODUCTION USE!**)
/// Many, many thanks to http://alastairs-place.net/blog/2012/06/06/utis-are-better-than-you-think-and-heres-why/
///
/// <https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/understanding_utis/understand_utis_conc/understand_utis_conc.html#//apple_ref/doc/uid/TP40001319-CH202-BCGCDHIJ>
func decodeDynUTI(_ uti: String) -> String?
{
let vec = Array("abcdefghkmnpqrstuvwxyz0123456789")
let encoded = Array(uti).suffix(from: 5)
var result: [UInt8] = []
@jspahrsummers
jspahrsummers / main.m
Created November 24, 2015 16:11
[NSThread isMainThread] is probably not what you want!
#import <Foundation/Foundation.h>
int main (int argc, const char **argv) {
@autoreleasepool {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
dispatch_sync(dispatch_get_main_queue(), ^{
NSLog(@"is main thread? %i", (int)[NSThread isMainThread]);
});
});
@mattstevens
mattstevens / gist:eb758f55cb2898b670a5
Created November 8, 2015 17:25
Filter breakpoint on frame module
(lldb) b NSLog
Breakpoint 2: 2 locations.
(lldb) breakpoint command add -s python -o "return (frame.GetThread().GetFrameAtIndex(1).GetModule().GetFileSpec().GetFilename() == 'UIKit')"
@xoofx
xoofx / TestCodeGen.cs
Created September 8, 2015 14:45
Simple CodeDom vs Roslyn syntax comparison
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.IO;
using System.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Formatting;
using NUnit.Framework;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
@brentsimmons
brentsimmons / gist:2080595ac8a6f41711af
Last active August 29, 2015 14:25
Swift init from unknown class
import Cocoa
protocol Thing {
var x: String {get}
init(s: String)
}
class Foo: Thing {
let x: String
@steipete
steipete / openssl-build.h
Last active May 30, 2023 11:34
Updated script that builds OpenSSL with Bitcode enabled (tested with Xcode 7.0b3)
#!/bin/bash
# This script downlaods and builds the iOS and Mac openSSL libraries with Bitcode enabled
# Credits:
# https://github.com/st3fan/ios-openssl
# https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh
# Peter Steinberger, PSPDFKit GmbH, @steipete.
set -e
@AliSoftware
AliSoftware / Generics-Macros.h
Last active December 11, 2020 17:18
ObjCGenerics
// Allow to use generics even if not supported yet
#if __has_feature(objc_generics)
#define NSArrayOf(x) NSArray<x>
#define NSMutableArrayOf(x) NSMutableArray<x>
#define NSDictionaryOf(x,y) NSDictionary<x, y>
#define NSMutableDictionaryOf(x, y) NSMutableDictionary<x, y>
#define NSSetOf(x) NSSet<x>
#define NSMutableSetOf(x) NSMutableSet<x>
#else
#define NSArrayOf(x) NSArray
@FilippoBiga
FilippoBiga / entitlements.plist
Created March 15, 2015 19:35
lockdown identity
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.private.lockdown.finegrained-get</key>
<array>
<string>NULL/ActivationInfo</string>
<string>NULL/ActivationPrivateKey</string>
<string>NULL/ActivationRegulatoryVariant</string>
<string>NULL/ActivationState</string>
anonymous
anonymous / syncs.d
Created February 9, 2015 00:02
#!/usr/sbin/dtrace -q -s
/*
Overly spammy, mostly covered by the other probes (every "read" or "write" is a "request")
CFPreferencesServer$target:::request {
printf("REQUEST from pid %d at %Y ( domain: %s, user: %s, host: %s, container: %s, managed: %d)\n", arg0, walltimestamp, copyinstr(arg1) != NULL ? copyinstr(arg1) : "(NULL)" ?: "(NULL)", copyinstr(arg2) != NULL ? copyinstr(arg2) : "(NULL)", copyinstr(arg3) != NULL ? copyinstr(arg3) : "(NULL)", copyinstr(arg4) != NULL ? copyinstr(arg4) : "(NULL)", arg5);
}
*/
CFPreferencesServer$target:::write_rejected {
printf("REJECTED WRITE OF KEY %s request from pid %d for reason %s at %Y ( domain: %s, user: %s, host: %s, container: %s)\n", copyinstr(arg1) != NULL ? copyinstr(arg1) : "(NULL)", arg0, copyinstr(arg6) != NULL ? copyinstr(arg6) : "(NULL)", walltimestamp, copyinstr(arg2) != NULL ? copyinstr(arg2) : "(NULL)", copyinstr(arg3) != NULL ? copyinstr(arg3) : "(NULL)", copyinstr(arg4) != NULL ? copyinstr(arg4) : "(NULL)", copyinstr(arg5) != NULL ? copyinstr(arg5)
@steventroughtonsmith
steventroughtonsmith / Demangle Swift.py
Created January 31, 2015 09:14
Hopper Swift demangler
import subprocess
def looksLikeBeginning(doc,seg,adr):
if doc.is64Bits() and seg.readByte(adr) == 0x55 and seg.readByte(adr + 1) == 0x48 and seg.readByte(adr + 2) == 0x89 and seg.readByte(adr + 3) == 0xE5:
return True
if not doc.is64Bits() and seg.readByte(adr) == 0x55 and seg.readByte(adr + 1) == 0x89 and seg.readByte(adr + 2) == 0xE5:
return True
return False
doc = Document.getCurrentDocument()