Some checks failed
Discord Push Notification / notify (push) Has been cancelled
Phase 1 of v0.4.0 offensive modules: - Promiscuous dispatcher (rt_promisc): shared IRAM callback multiplexer for stealth scan, karma, capture — solves single-callback ESP-IDF limit - Attack manager (rt_attack): mutual exclusion ensuring only one offensive operation runs at a time - Deauth refactored to use shared promisc dispatcher + attack lock - Stealth passive scan migrated to promisc dispatcher - Karma attack (rt_karma): probe request listener + probe response injection + rogue SoftAP with most-requested SSID + DNS responder - WPA handshake capture (rt_capture): EAPOL frame capture via promiscuous DATA filter, 4-way handshake identification, optional deauth burst to trigger reconnection - Kconfig: RT_BEACON, RT_KARMA, RT_CAPTURE toggle options - 5 new C2 commands: rt_karma, rt_karma_stop, rt_karma_clients, rt_capture, rt_capture_stop (14 total in mod_redteam)
97 lines
2.0 KiB
C
97 lines
2.0 KiB
C
/*
|
|
* rt_attack.c
|
|
* Mutual exclusion for offensive operations.
|
|
*
|
|
* Ensures only one attack runs at a time (deauth, beacon, karma, capture).
|
|
*/
|
|
#include "sdkconfig.h"
|
|
|
|
#ifdef CONFIG_MODULE_REDTEAM
|
|
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/semphr.h"
|
|
#include "esp_log.h"
|
|
|
|
#include "rt_attack.h"
|
|
|
|
#define TAG "RT_ATTACK"
|
|
|
|
static SemaphoreHandle_t s_mutex = NULL;
|
|
static rt_attack_type_t s_current = RT_ATTACK_NONE;
|
|
static bool s_inited = false;
|
|
|
|
static const char *s_names[] = {
|
|
[RT_ATTACK_NONE] = "none",
|
|
[RT_ATTACK_DEAUTH] = "deauth",
|
|
[RT_ATTACK_BEACON] = "beacon",
|
|
[RT_ATTACK_KARMA] = "karma",
|
|
[RT_ATTACK_CAPTURE] = "capture",
|
|
};
|
|
|
|
void rt_attack_init(void)
|
|
{
|
|
if (s_inited) return;
|
|
|
|
s_mutex = xSemaphoreCreateMutex();
|
|
configASSERT(s_mutex);
|
|
|
|
s_current = RT_ATTACK_NONE;
|
|
s_inited = true;
|
|
}
|
|
|
|
esp_err_t rt_attack_start(rt_attack_type_t type)
|
|
{
|
|
if (!s_inited) rt_attack_init();
|
|
|
|
xSemaphoreTake(s_mutex, portMAX_DELAY);
|
|
|
|
if (s_current != RT_ATTACK_NONE) {
|
|
ESP_LOGW(TAG, "Cannot start %s: %s already running",
|
|
s_names[type], s_names[s_current]);
|
|
xSemaphoreGive(s_mutex);
|
|
return ESP_ERR_INVALID_STATE;
|
|
}
|
|
|
|
s_current = type;
|
|
ESP_LOGI(TAG, "Attack started: %s", s_names[type]);
|
|
|
|
xSemaphoreGive(s_mutex);
|
|
return ESP_OK;
|
|
}
|
|
|
|
void rt_attack_stop(void)
|
|
{
|
|
if (!s_inited) return;
|
|
|
|
xSemaphoreTake(s_mutex, portMAX_DELAY);
|
|
|
|
if (s_current != RT_ATTACK_NONE) {
|
|
ESP_LOGI(TAG, "Attack stopped: %s", s_names[s_current]);
|
|
}
|
|
s_current = RT_ATTACK_NONE;
|
|
|
|
xSemaphoreGive(s_mutex);
|
|
}
|
|
|
|
rt_attack_type_t rt_attack_current(void)
|
|
{
|
|
if (!s_inited) return RT_ATTACK_NONE;
|
|
|
|
xSemaphoreTake(s_mutex, portMAX_DELAY);
|
|
rt_attack_type_t t = s_current;
|
|
xSemaphoreGive(s_mutex);
|
|
return t;
|
|
}
|
|
|
|
const char *rt_attack_name(void)
|
|
{
|
|
return s_names[rt_attack_current()];
|
|
}
|
|
|
|
bool rt_attack_is_active(void)
|
|
{
|
|
return rt_attack_current() != RT_ATTACK_NONE;
|
|
}
|
|
|
|
#endif /* CONFIG_MODULE_REDTEAM */
|