From 9c8920067f5f1d254fb14241dc97e59dd19e45b4 Mon Sep 17 00:00:00 2001 From: ptrcnull Date: Wed, 29 Dec 2021 06:05:02 +0100 Subject: [PATCH] fix: Add detecting if /sbin/init is a symlink because systemd --- infect.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/infect.sh b/infect.sh index 1f8524b..c0295fa 100755 --- a/infect.sh +++ b/infect.sh @@ -73,9 +73,15 @@ echo "tty1::wait:/sbin/getty -n -l /third_stage.sh 38400 tty1" > /etc/inittab # here be dragons +init_file=/old_root/sbin/init +init_link=$(readlink $init_file) +if [[ "$init_link" != "" ]]; then + init_file=/old_root$init_link +fi + echo -e "set follow-fork-mode child set solib-absolute-prefix /old_root -file /old_root$(cat /proc/1/cmdline) +file $init_file attach 1 call (int)execl(\"/sbin/init\", \"/sbin/init\", 0) " | gdb