Skip to content

Commit d43ef9b

Browse files
ozgengreenbonebot
authored andcommitted
add: support host_discovery_ipv6 alive test for openvasd
Add `host_discovery_ipv6` as a new alive test bit for openvasd scans. When `host_discovery_ipv6` is selected, it has priority over other alive test methods. The value is passed to gvm-libs through the new openvasd alive test methods struct. This keeps the gvmd openvasd scan setup aligned with the new openvasd target API.
1 parent 0798cfb commit d43ef9b

5 files changed

Lines changed: 36 additions & 17 deletions

File tree

INSTALL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Prerequisites:
1414
* glib-2.0 >= 2.42
1515
* gnutls >= 3.2.15
1616
* gpgme
17-
* [gvm-libs](https://github.com/greenbone/gvm-libs/) >= 23.0 (or 23.2 if ENABLE_AGENTS)
17+
* [gvm-libs](https://github.com/greenbone/gvm-libs/) >= 23.0 (or 23.2 if ENABLE_AGENTS and 23.3 if ENABLE_OPENVASD)
1818
* libical >= 1.0.0
1919
* libbsd
2020
* pkg-config

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ if(ENABLE_HTTP_SCANNER)
2424
pkg_check_modules(LIBGVM_HTTP_SCANNER REQUIRED libgvm_http_scanner>=22.41)
2525
endif(ENABLE_HTTP_SCANNER)
2626
if(ENABLE_OPENVASD)
27-
pkg_check_modules(LIBGVM_OPENVASD REQUIRED libgvm_openvasd>=23.00)
27+
pkg_check_modules(LIBGVM_OPENVASD REQUIRED libgvm_openvasd>=23.3)
2828
else(ENABLE_OPENVASD)
2929
message(STATUS "ENABLE_OPENVASD flag is not enabled")
3030
endif(ENABLE_OPENVASD)

src/manage.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,10 @@ typedef enum
345345
ALIVE_TEST_ICMP = 2,
346346
ALIVE_TEST_ARP = 4,
347347
ALIVE_TEST_CONSIDER_ALIVE = 8,
348-
ALIVE_TEST_TCP_SYN_SERVICE = 16
348+
ALIVE_TEST_TCP_SYN_SERVICE = 16,
349+
#if ENABLE_OPENVASD
350+
ALIVE_TEST_HOST_DISCOVERY_IPV6 = 32
351+
#endif
349352
} alive_test_t;
350353

351354
/**

src/manage_openvasd.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ launch_openvasd_openvas_task (task_t task, target_t target, const char *scan_id,
170170
char *hosts_str, *ports_str, *exclude_hosts_str, *finished_hosts_str;
171171
gchar *clean_hosts, *clean_exclude_hosts, *clean_finished_hosts_str;
172172
int alive_test, reverse_lookup_only, reverse_lookup_unify;
173-
int arp = 0, icmp = 0, tcp_ack = 0, tcp_syn = 0, consider_alive = 0;
174173
openvasd_target_t *openvasd_target;
175174
GSList *openvasd_targets, *vts;
176175
GHashTable *vts_hash_table;
@@ -241,19 +240,23 @@ launch_openvasd_openvas_task (task_t task, target_t target, const char *scan_id,
241240
if (finished_hosts_str)
242241
openvasd_target_set_finished_hosts (openvasd_target, finished_hosts_str);
243242

243+
openvasd_alive_test_methods_t alive_test_methods = { 0 };
244+
245+
if (alive_test & ALIVE_TEST_HOST_DISCOVERY_IPV6)
246+
alive_test_methods.host_discovery_ipv6 = TRUE;
244247
if (alive_test & ALIVE_TEST_ARP)
245-
arp = 1;
248+
alive_test_methods.arp = TRUE;
246249
if (alive_test & ALIVE_TEST_ICMP)
247-
icmp = 1;
250+
alive_test_methods.icmp = TRUE;
248251
if (alive_test & ALIVE_TEST_TCP_ACK_SERVICE)
249-
tcp_ack = 1;
252+
alive_test_methods.tcp_ack = TRUE;
250253
if (alive_test & ALIVE_TEST_TCP_SYN_SERVICE)
251-
tcp_syn = 1;
254+
alive_test_methods.tcp_syn = TRUE;
252255
if (alive_test & ALIVE_TEST_CONSIDER_ALIVE)
253-
consider_alive = 1;
256+
alive_test_methods.consider_alive = TRUE;
254257

255-
openvasd_target_add_alive_test_methods (openvasd_target, icmp, tcp_syn,
256-
tcp_ack, arp, consider_alive);
258+
openvasd_target_set_alive_test_methods (openvasd_target,
259+
&alive_test_methods);
257260

258261
free (hosts_str);
259262
free (ports_str);

src/manage_sql_targets.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -606,17 +606,25 @@ alive_test_from_array (GPtrArray *alive_tests)
606606
alive_test_bitfield = ALIVE_TEST_CONSIDER_ALIVE;
607607
break;
608608
}
609+
#if ENABLE_OPENVASD
610+
else if (strcasecmp (item, "host_discovery_ipv6") == 0
611+
|| strcasecmp (item, "Host Discovery IPv6") == 0)
612+
{
613+
alive_test_bitfield = ALIVE_TEST_HOST_DISCOVERY_IPV6;
614+
break;
615+
}
616+
#endif
609617
else if (strcasecmp (item, "ARP") == 0
610618
|| strcasecmp (item, "ARP Ping") == 0)
611619
alive_test_bitfield |= ALIVE_TEST_ARP;
612-
else if (strcmp (item, "ICMP") == 0
613-
|| strcmp (item, "ICMP Ping") == 0)
620+
else if (strcasecmp (item, "ICMP") == 0
621+
|| strcasecmp (item, "ICMP Ping") == 0)
614622
alive_test_bitfield |= ALIVE_TEST_ICMP;
615-
else if (strcmp (item, "TCP-ACK Service") == 0
616-
|| strcmp (item, "TCP-ACK Service Ping") == 0)
623+
else if (strcasecmp (item, "TCP-ACK Service") == 0
624+
|| strcasecmp (item, "TCP-ACK Service Ping") == 0)
617625
alive_test_bitfield |= ALIVE_TEST_TCP_ACK_SERVICE;
618-
else if (strcmp (item, "TCP-SYN Service") == 0
619-
|| strcmp (item, "TCP-SYN Service Ping") == 0)
626+
else if (strcasecmp (item, "TCP-SYN Service") == 0
627+
|| strcasecmp (item, "TCP-SYN Service Ping") == 0)
620628
alive_test_bitfield |= ALIVE_TEST_TCP_SYN_SERVICE;
621629
else
622630
{
@@ -661,6 +669,11 @@ alive_test_from_string (const char* alive_tests)
661669
alive_test = ALIVE_TEST_ICMP;
662670
else if (strcmp (alive_tests, "Consider Alive") == 0)
663671
alive_test = ALIVE_TEST_CONSIDER_ALIVE;
672+
#if ENABLE_OPENVASD
673+
else if (strcasecmp (alive_tests, "host_discovery_ipv6") == 0
674+
|| strcasecmp (alive_tests, "Host Discovery IPv6") == 0)
675+
alive_test = ALIVE_TEST_HOST_DISCOVERY_IPV6;
676+
#endif
664677
else
665678
return -1;
666679
return alive_test;

0 commit comments

Comments
 (0)