feature: print (wip)

This commit is contained in:
0x35c
2025-06-03 13:05:52 +02:00
parent abb1d1f364
commit d640c95224
7 changed files with 54 additions and 30 deletions

View File

@ -1,6 +1,40 @@
#include "print.h"
#include <stdio.h>
#include "parsing.h"
#include "response.h"
#include "scan.h"
void print_usage(void)
{
// TODO print options list
// TODO
}
static void print_port_state(const struct response *response, e_scantype type)
{
if (type != SCAN_ALL && response->states[type] == CLOSED)
return;
printf("%-5d %-12s ", response->port,
response->service ? response->service : "Unassigned");
if (type == SCAN_ALL)
for (e_scantype i = SCAN_NULL; i < SCAN_ALL; i++)
printf("%s(%s) ", types_str[i],
states_str[response->states[i]]);
else
printf("%s(%s) ", types_str[type],
states_str[response->states[type]]);
printf("\n");
}
void print_host_results(const char *ip_addr, const struct response *responses,
const struct option_lst *options, double scan_time)
{
printf("Scan took %lf secs\n", scan_time);
printf("IP address: %s\n", ip_addr);
printf("Open ports:\n");
uint16_t port_start = 1, port_end = 1024;
parse_ports(get_option_arg(options, FL_PORTS), &port_start, &port_end);
e_scantype type = parse_type(get_option_arg(options, FL_SCAN));
for (uint16_t i = port_start; i < port_end - port_start; i++) {
print_port_state(&responses[i], type);
}
}