This repository has been archived by the owner on Feb 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (60 loc) · 2.12 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
KDIR = /lib/modules/`uname -r`/build
CCFLAGS += -Wall -Wextra -Werror -ldl -export-dynamic -Iclient/include -Iclient/payload
ifneq ($(IMLOG_LEVEL),)
CCFLAGS += -DIMLOG_LEVEL=$(IMLOG_LEVEL)
endif
ifneq ($(IMPLANT_DEVICE_PATH),)
CCFLAGS += -DIMPLANT_DEVICE_PATH=$(IMPLANT_DEVICE_PATH)
endif
ifeq ($(COVERAGE), true)
CCFLAGS += -coverage
endif
ifeq ($(DEBUG), true)
CCFLAGS += -g
endif
ifeq ($(PACKER),)
PACKER = true
endif
# Builds the kernel module.
kmodule:
make -C $(KDIR) M=`pwd`
include client/payload/Makefile
# Builds an object file for the kernel module that can be embedded.
implant.ko.o: kmodule
ld -r -b binary implant.ko -o $@
# Builds the client application.
CLIENTSRCS := $(wildcard client/src/*.c) $(wildcard client/src/*/*.c)
sc-client: implant.ko.o $(CLIENTSRCS) $(TARGETSRCS) $(TARGETOBJS)
$(CC) $(CFLAGS) $(CCFLAGS) $^ -o $@
if [ $(PACKER) = true ]; then upx $@; fi
# Compile the Linux kernel.
#
# This rule allows for the compilation of the kernel module from a different
# host machine.
#
# A useful side-effect is that smart completion and navigation can be provided.
kbuild: ksource
cd ./usr/src/linux-source-4.19; \
make -j4 && make modules; \
wget -nc https://raw.githubusercontent.com/torvalds/linux/master/scripts/gen_compile_commands.py; \
python2 gen_compile_commands.py;
# Download and patch the Linux kernel.
ksource:
wget -nc http://security.debian.org/debian-security/pool/updates/main/l/linux/linux-source-4.19_4.19.67-2+deb10u1_all.deb; \
touch ksource; # Make can use this to know that the rule has been met.
ar -xv linux-source-4.19_4.19.67-2+deb10u1_all.deb
tar -xvf data.tar.gz
cd ./usr/src/; \
tar -xvf linux-source-4.19.tar.xz
cd ./usr/src/linux-source-4.19; \
xzcat ../linux-patch-4.19-rt.patch.xz | patch -p1; \
make ARCH=x86_64 defconfig; # Use the default configuration.
rm -rf control.tar.gz data.tar.gz debian-binary linux-source-4.19_4.19.67-2+deb10u1_all.deb
clean: payloads_clean
make -C $(KDIR) M=`pwd` clean; \
rm -rf sc-client;
rm -rf *.gcno *.gcda
distclean: clean
rm -rf usr ksource
format:
type clang-format > /dev/null && git ls-files "*.c" "*.h" | xargs clang-format -i