cours/content/secu_logicielle/td5-stackoverflow_shellcode/files/q2/Makefile

35 lines
799 B
Makefile

CC = gcc
CFLAGS = -Wall -Wextra -O0 -no-pie -lm -g -std=c99 -zexecstack
SRC = $(wildcard *.c)
TGT = $(subst .c,,$(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: $(addprefix $(BUILD_DIR)/, $(TGT)))
PHONY: gdb
gdb: build/exploit build/anodin configure
./$(BUILD_DIR)/exploit > hack.txt &
PYTHONPATH=${PWD}/pframe${PYTHONPATH:+:${PYTHONPATH}} \
setarch -R gdb ./$(BUILD_DIR)/anodin --command=$(subst gdb_,,$@).gdb
rm hack.txt
PHONY: clean
clean:
@rm -rf $(BUILD_DIR) pframe .gdbinit