Skip to content

Instantly share code, notes, and snippets.

@maxdeliso
Created October 18, 2012 18:13
Show Gist options
  • Save maxdeliso/3913861 to your computer and use it in GitHub Desktop.
Save maxdeliso/3913861 to your computer and use it in GitHub Desktop.
snequeil
.exports
.o
snequeil
.swp
*~
.PHONY: clean
LD=ld
ASM=nasm
RM=rm
OUT=snequeil
SRC=$(OUT).asm
OBJ=$(OUT).o
THIS=makefile
LDFLAGS=-e snequeil -macosx_version_min 10.7 -pie -allow_stack_execute -bind_at_load
AFLAGS=-fmacho64
RMFLAGS=-f
DEPS=/usr/lib/libSystem.dylib
snequeil: $(OBJ) $(THIS)
@$(LD) $(LDFLAGS) $(DEPS) -o $(OUT) $(OBJ)
@echo Linked
@size $(OUT)
snequeil.o: $(SRC) $(THIS)
@$(ASM) $(AFLAGS) -o $(OBJ) $(SRC)
@echo Assembled
@size $(OBJ)
clean:
@$(RM) $(RMFLAGS) $(OBJ) $(OUT)
table: libSystem.dylib.exports
@dyldinfo -arch x86_64 -export /usr/lib/libSystem.dylib > libSystem.dylib.exports
global snequeil
section .text
snequeil:
mov rbp, rsp ; overwrite rbp, (it's 0)
sub rsp, 0x8 ; alloc space on main stack frame
; TODO
add rsp, 0x8 ; clean main stack frame
mov rax, 0x2000001 ; exit
xor rdi, rdi ; return 0
syscall ; poke
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment