cours/content/secu_logicielle/td5-stackoverflow_shellcode/files/q2/Makefile
2023-03-11 00:26:21 +01:00

35 lines
773 B
Makefile

# CC = gcc
CFLAGS = -g -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
echo '0x7fffffffe490' | ./$(BUILD_DIR)/exploit > hack.txt
PYTHONPATH=${PWD}/pframe${PYTHONPATH:+:${PYTHONPATH}} \
setarch -R gdb ./$(BUILD_DIR)/anodin --command=anodin.gdb
rm hack.txt
PHONY: clean
clean:
@rm -rf $(BUILD_DIR) pframe .gdbinit