diff options
author | David Timber <mieabby@gmail.com> | 2021-08-17 12:07:24 +1000 |
---|---|---|
committer | David Timber <mieabby@gmail.com> | 2021-08-17 12:07:24 +1000 |
commit | af9f23da9f3ce89353cf06878bf8ab49b405e331 (patch) | |
tree | f49c0aaa74ee09ca11c03f0aead5010d41eb18f6 /src/proone-bne.c | |
parent | a161674bcee21384a73834e3ca16ad3bf1c70cf3 (diff) |
Impl full IPv6 support ...
* Use different strategy for discovering IPv6 hosts on the network
* Multicast IPv6 packet with bogus destination options to get ICMPv6
responses(type 4, code 2)
* Send SYN packets to the hosts responds to the packet to confirm that
they have target ports open
* Add full scope_id support
* Fix potential infinite loop when receiving raw packets
Diffstat (limited to 'src/proone-bne.c')
-rw-r--r-- | src/proone-bne.c | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/src/proone-bne.c b/src/proone-bne.c index 89a5d7f..359b634 100644 --- a/src/proone-bne.c +++ b/src/proone-bne.c @@ -10,6 +10,7 @@ #include <fcntl.h> #include <sys/stat.h> #include <arpa/inet.h> +#include <net/if.h> #include <mbedtls/entropy.h> @@ -41,6 +42,10 @@ struct { struct { struct { + char *addr; + uint32_t scope_id; + } arg; + struct { uint8_t *m; size_t l; prne_cred_dict_t ctx; @@ -102,6 +107,8 @@ static void init_g (void) { } static void free_g (void) { + prne_free(prog_g.arg.addr); + prog_g.arg.addr = NULL; prne_free_llist(&prog_g.wkr_list); mbedtls_ctr_drbg_free(&prog_g.ssl.ctr_drbg); mbedtls_entropy_free(&prog_g.ssl.entropy); @@ -143,6 +150,31 @@ static void load_str (char **dst, const char *str) { } } +static bool load_addr (const char *addr) { + char *p; + + prog_g.arg.addr = prne_redup_str(prog_g.arg.addr, addr); + prne_assert(prog_g.arg.addr != NULL); + + p = strrchr(prog_g.arg.addr, '%'); + if (p != NULL) { + *p = 0; + p += 1; + prog_g.arg.scope_id = if_nametoindex(p); + + if (prog_g.arg.scope_id == 0 && + 1 != sscanf(p, "%"SCNu32, &prog_g.arg.scope_id)) + { + return false; + } + } + else { + prog_g.arg.scope_id = 0; + } + + return true; +} + static int parse_args (const int argc, char *const*args) { static const struct option lopts[] = { { "cdict", required_argument, 0, 0 }, @@ -216,10 +248,16 @@ static int parse_args (const int argc, char *const*args) { for (size_t i = 0; i < prog_conf.targets.cnt; i += 1, optind += 1) { prne_ip_addr_t *p = prog_conf.targets.arr + i; - if (inet_pton(AF_INET6, args[optind], p->addr)) { + if (!load_addr(args[optind])) { + fprintf(stderr, "%s: invalid scope id\n", args[optind]); + return 2; + } + + if (inet_pton(AF_INET6, prog_g.arg.addr, p->addr)) { p->ver = PRNE_IPV_6; + p->scope_id = prog_g.arg.scope_id; } - else if (inet_pton(AF_INET, args[optind], p->addr)) { + else if (inet_pton(AF_INET, prog_g.arg.addr, p->addr)) { p->ver = PRNE_IPV_4; } else { |