From 6164363ccef8801207d54d69741d55a2a9e51b67 Mon Sep 17 00:00:00 2001 From: 0x35c <> Date: Sat, 31 May 2025 17:10:03 +0200 Subject: [PATCH] fix: better response handling for prints --- include/response.h | 1 + src/main.c | 3 ++- src/thread.c | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/response.h b/include/response.h index eb38f45..510c664 100644 --- a/include/response.h +++ b/include/response.h @@ -22,6 +22,7 @@ typedef enum { }; struct response { + uint16_t port; e_state states[SCAN_ALL]; char *service; }; diff --git a/src/main.c b/src/main.c index 145e123..1f430b6 100644 --- a/src/main.c +++ b/src/main.c @@ -25,6 +25,7 @@ static int scan_host(char *host, const struct option_lst *options) return 1; } + printf("%s\n", ip_addr); struct response responses[1024] = {0}; if (create_threads(options, ip_addr, responses) < 0) return 1; @@ -35,7 +36,7 @@ static int scan_host(char *host, const struct option_lst *options) const e_scantype type = SCAN_SYN; if (responses[i].states[type] == CLOSED) continue; - printf("%d (%s): ", i + 1, + printf("%d (%s): ", responses[i].port, responses[i].service ? responses[i].service : "undefined"); if (responses[i].service) diff --git a/src/thread.c b/src/thread.c index d7969e9..55dffbe 100644 --- a/src/thread.c +++ b/src/thread.c @@ -41,6 +41,7 @@ void *routine(void *p_data) port <= thread_data->port_end; port++) { scan_data.port = port; scan_data.response = &thread_data->responses[port - 1]; + scan_data.response->port = port; if (scan(&scan_data)) { free(p_data); return NULL;