52e8c99022
- core/module.h: struct iamroot_module + iamroot_result_t
- core/registry.{h,c}: flat-array module registry with find-by-name
- modules/copy_fail_family/iamroot_modules.{h,c}: bridge layer
exposing 5 modules (copy_fail, copy_fail_gcm, dirty_frag_esp,
dirty_frag_esp6, dirty_frag_rxrpc) wired to the absorbed DIRTYFAIL
detect/exploit functions; df_result_t/iamroot_result_t share numeric
values intentionally for zero-cost translation
- iamroot.c: top-level CLI dispatcher with --scan / --list / --exploit /
--mitigate / --cleanup, JSON output, --i-know gate
- Restored modules/copy_fail_family/src/ structure (DIRTYFAIL Makefile
expects it; the initial flat copy broke that contract)
- Top-level Makefile builds one binary; filters out DIRTYFAIL's
original dirtyfail.c main so it doesn't conflict with iamroot.c
Verified end-to-end on kctf-mgr (Linux): clean compile, 5 modules
register, --scan --json output ingest-ready, exit codes propagate.
61 lines
1.4 KiB
C
61 lines
1.4 KiB
C
/*
|
|
* IAMROOT — module registry implementation
|
|
*
|
|
* Simple flat array. Resized in chunks of 16. We never expect more
|
|
* than a few dozen modules, so this is fine.
|
|
*/
|
|
|
|
#include "registry.h"
|
|
|
|
#include <stddef.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#define REGISTRY_CHUNK 16
|
|
|
|
static const struct iamroot_module **g_modules = NULL;
|
|
static size_t g_count = 0;
|
|
static size_t g_cap = 0;
|
|
|
|
void iamroot_register(const struct iamroot_module *m)
|
|
{
|
|
if (m == NULL || m->name == NULL) {
|
|
fprintf(stderr, "[!] iamroot_register: NULL module or unnamed module\n");
|
|
return;
|
|
}
|
|
if (g_count == g_cap) {
|
|
size_t new_cap = g_cap + REGISTRY_CHUNK;
|
|
const struct iamroot_module **n =
|
|
realloc((void *)g_modules, new_cap * sizeof(*g_modules));
|
|
if (n == NULL) {
|
|
fprintf(stderr, "[!] iamroot_register: OOM\n");
|
|
return;
|
|
}
|
|
g_modules = n;
|
|
g_cap = new_cap;
|
|
}
|
|
g_modules[g_count++] = m;
|
|
}
|
|
|
|
size_t iamroot_module_count(void)
|
|
{
|
|
return g_count;
|
|
}
|
|
|
|
const struct iamroot_module *iamroot_module_at(size_t i)
|
|
{
|
|
if (i >= g_count) return NULL;
|
|
return g_modules[i];
|
|
}
|
|
|
|
const struct iamroot_module *iamroot_module_find(const char *name)
|
|
{
|
|
if (name == NULL) return NULL;
|
|
for (size_t i = 0; i < g_count; i++) {
|
|
if (strcmp(g_modules[i]->name, name) == 0)
|
|
return g_modules[i];
|
|
}
|
|
return NULL;
|
|
}
|