Add TD5 q3 (first part)
This commit is contained in:
parent
72564e2e2d
commit
4f61441bb9
7 changed files with 229 additions and 0 deletions
|
@ -0,0 +1,44 @@
|
|||
# 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
|
||||
|
||||
PHONY: opcode
|
||||
opcode: build/shellcode
|
||||
readelf -x .text build/shellcode | sed -e '$$ d' -e '1,2 d' \
|
||||
| awk '{$$1=$$6=""; print $$0}' \
|
||||
| tr -d '[ \n]' \
|
||||
| sed 's/../0x&,/g' > opcode.txt
|
||||
|
||||
PHONY: clean
|
||||
clean:
|
||||
@rm -rf $(BUILD_DIR) pframe .gdbinit opcode.txt
|
Loading…
Add table
Add a link
Reference in a new issue