diff --git a/content/secu_logicielle/td5-stackoverflow_shellcode/files/q4/Makefile b/content/secu_logicielle/td5-stackoverflow_shellcode/files/q4/Makefile new file mode 100644 index 0000000..80ad7a1 --- /dev/null +++ b/content/secu_logicielle/td5-stackoverflow_shellcode/files/q4/Makefile @@ -0,0 +1,37 @@ +# CC = gcc +CFLAGS = -g -zexecstack +SFLASG = +SRC = $(wildcard *.c) $(wildcard *.s) +TGT = $(subst .c,,$(subst. .S,,$(SRC))) +BUILD_DIR = build +DUMP_DIR = dump + + +pframe: + curl -o pframe.tgz https://dept-info.labri.fr/~thibault/SecuLog/pframe.tgz && \ + tar -xf pframe.tgz &&\ + rm -rf pframe.tgz + +.gdbinit: + +configure: pframe .gdbinit + $(shell echo "python import pframe" > .gdbinit) + +$(BUILD_DIR)/%: %.c + $(shell mkdir -p $(BUILD_DIR)) + $(CC) $(CFLAGS) -o $@ $< + +$(BUILD_DIR)/%: %.S + $(shell mkdir -p $(BUILD_DIR)) + $(CC) -g $< -o $@ -static -nostdlib + +build: $(addprefix $(BUILD_DIR)/, $(TGT)) + +PHONY: gdb +gdb: build/shellcode configure + PYTHONPATH=${PWD}/pframe${PYTHONPATH:+:${PYTHONPATH}} \ + setarch -R gdb ./$(BUILD_DIR)/shellcode --command=shellcode.gdb + +PHONY: clean +clean: + @rm -rf $(BUILD_DIR) pframe .gdbinit opcode.txt diff --git a/content/secu_logicielle/td5-stackoverflow_shellcode/files/q4/shellcode.S b/content/secu_logicielle/td5-stackoverflow_shellcode/files/q4/shellcode.S new file mode 100644 index 0000000..11f9d2e --- /dev/null +++ b/content/secu_logicielle/td5-stackoverflow_shellcode/files/q4/shellcode.S @@ -0,0 +1,18 @@ + +.text +.globl _start + +_start: +xor %eax,%eax +movabs $0xff978cd091969dd1,%rbx +neg %rbx +push %rbx +push %rsp +pop %rdi +cltd +push %rdx +push %rdi +push %rsp +pop %rsi +mov $0x3b,%al +syscall diff --git a/content/secu_logicielle/td5-stackoverflow_shellcode/files/q4/shellcode.gdb b/content/secu_logicielle/td5-stackoverflow_shellcode/files/q4/shellcode.gdb new file mode 100644 index 0000000..7025783 --- /dev/null +++ b/content/secu_logicielle/td5-stackoverflow_shellcode/files/q4/shellcode.gdb @@ -0,0 +1,2 @@ +b _start +r