From 6bf809731abfd1893e73f6c6b35d0a22dacd6fb2 Mon Sep 17 00:00:00 2001 From: Orfeas <38209077+0xfea5@users.noreply.github.com> Date: Tue, 23 Apr 2024 19:38:50 +0300 Subject: Small changes to the Makefile and the scripts --- Makefile | 2 +- run.sh | 17 +++++++++++++++-- scripts/read.sh | 2 +- scripts/scan.sh | 2 +- src/main.c | 1 - 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 844cc7b..a567d0b 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CC = gcc CFLAGS = -Wall -g OBJS = $(patsubst %.c,%.o,$(wildcard src/*.c)) -OUT = hack.out +OUT = trainer $(OUT): $(OBJS) $(CC) $(CFLAGS) -o $@ $(OBJS) diff --git a/run.sh b/run.sh index 6de5897..c0d4886 100755 --- a/run.sh +++ b/run.sh @@ -6,5 +6,18 @@ then exit 1 fi -gnome-terminal -- bash ./scripts/scan.sh "$1" -gnome-terminal -- bash ./scripts/read.sh "$1" +if [ ! $(cat /proc/sys/kernel/yama/ptrace_scope) -eq 0 ] +then + echo "ptrace_scope is not set to 0 and ptrace attach will subsequently fail + To solve this issue you can run the following command: + + echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope" + exit 1 +fi + +TERM_EMU=gnome-terminal + +# The syntax for the startup command may differ per terminal emulator. +make && \ +${TERM_EMU} -- bash ./scripts/scan.sh "$1" && \ +${TERM_EMU} -- bash ./scripts/read.sh "$1" diff --git a/scripts/read.sh b/scripts/read.sh index 38535e6..f26ba11 100644 --- a/scripts/read.sh +++ b/scripts/read.sh @@ -8,4 +8,4 @@ fi scanfile=${SCANFILE:-/tmp/scanfile} pid="$1" -watch -d -n 1 "xargs -r -a ${scanfile} ./hack.out ${pid} read 8 > /tmp/out 2> /dev/null && pr -t -m ${scanfile} /tmp/out" +watch -d -n 1 "xargs -r -a ${scanfile} ./trainer ${pid} read 8 > /tmp/out 2> /dev/null && pr -t -m ${scanfile} /tmp/out" diff --git a/scripts/scan.sh b/scripts/scan.sh index c700011..bb4f77c 100644 --- a/scripts/scan.sh +++ b/scripts/scan.sh @@ -25,7 +25,7 @@ while true do read -p "Scan pattern (hex): " pattern newscan=$(mktemp) - ./hack.out ${pid} scan ${pattern} > ${newscan} 2> /dev/null + ./trainer ${pid} scan ${pattern} > ${newscan} 2> /dev/null if [ ! -f ${scanfile} ] then mv ${newscan} ${scanfile} diff --git a/src/main.c b/src/main.c index 623d767..efc30d3 100644 --- a/src/main.c +++ b/src/main.c @@ -80,7 +80,6 @@ void action_write(int pid, int argc, const char *argv[]) } Bytes aob = hex2bytes(argv[0]); - printf("%s\n", aob.data); void *address[argc-1]; for (size_t i = 0; i < argc-1; ++i) { sscanf(argv[i+1], "%p", &address[i]); -- cgit v1.2.3