Move command registry from components/command/ into components/core/. New modules: mod_canbus, mod_honeypot, mod_fallback, mod_redteam, mod_ota. Replace mod_proxy with tun_core (multiplexed SOCKS5 tunnel). Kconfig extended with per-module settings and async worker config.
61 lines
1.7 KiB
C
61 lines
1.7 KiB
C
/*
|
|
* svc_telnet.c
|
|
* Telnet honeypot handler — login prompt + user/pass capture + tarpit.
|
|
*/
|
|
#include "sdkconfig.h"
|
|
|
|
#ifdef CONFIG_MODULE_HONEYPOT
|
|
|
|
#include "svc_common.h"
|
|
|
|
void handle_telnet_client(int client_fd, const char *client_ip,
|
|
uint16_t client_port, hp_svc_desc_t *svc)
|
|
{
|
|
char banner[128];
|
|
hp_config_get_banner("telnet", banner, sizeof(banner));
|
|
send(client_fd, banner, strlen(banner), 0);
|
|
|
|
svc->connections++;
|
|
event_send("SVC_CONNECT", "LOW", "00:00:00:00:00:00",
|
|
client_ip, client_port, 23, "service=telnet", NULL);
|
|
|
|
/* Read username */
|
|
char user[64] = {0};
|
|
int n = recv(client_fd, user, sizeof(user) - 1, 0);
|
|
if (n > 0) {
|
|
user[n] = '\0';
|
|
while (n > 0 && (user[n-1] == '\r' || user[n-1] == '\n'))
|
|
user[--n] = '\0';
|
|
}
|
|
|
|
/* Send password prompt */
|
|
const char *pass_prompt = "Password: ";
|
|
send(client_fd, pass_prompt, strlen(pass_prompt), 0);
|
|
|
|
char pass[64] = {0};
|
|
n = recv(client_fd, pass, sizeof(pass) - 1, 0);
|
|
if (n > 0) {
|
|
pass[n] = '\0';
|
|
while (n > 0 && (pass[n-1] == '\r' || pass[n-1] == '\n'))
|
|
pass[--n] = '\0';
|
|
}
|
|
|
|
if (user[0] || pass[0]) {
|
|
svc->auth_attempts++;
|
|
char detail[192];
|
|
snprintf(detail, sizeof(detail),
|
|
"service=telnet user='%.32s' pass='%.32s'", user, pass);
|
|
event_send("SVC_AUTH_ATTEMPT", "HIGH", "00:00:00:00:00:00",
|
|
client_ip, client_port, 23, detail, NULL);
|
|
}
|
|
|
|
const char *fail = "\r\nLogin incorrect\r\n";
|
|
send(client_fd, fail, strlen(fail), 0);
|
|
|
|
int tarpit = hp_config_get_threshold("tarpit_ms");
|
|
if (tarpit > 0)
|
|
vTaskDelay(pdMS_TO_TICKS(tarpit));
|
|
}
|
|
|
|
#endif
|