OpenVAS Scanner 21.4.1
|
NASL IPv6 Packet Forgery functions. More...
#include <arpa/inet.h>
#include <ctype.h>
#include <pcap.h>
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#include <sys/time.h>
#include <unistd.h>
#include "../misc/bpf_share.h"
#include "../misc/pcap_openvas.h"
#include "../misc/plugutils.h"
#include "capture_packet.h"
#include "exec.h"
#include "nasl_debug.h"
#include "nasl_func.h"
#include "nasl_global_ctxt.h"
#include "nasl_lex_ctxt.h"
#include "nasl_packet_forgery_v6.h"
#include "nasl_raw.h"
#include "nasl_socket.h"
#include "nasl_tree.h"
#include "nasl_var.h"
#include <netinet/icmp6.h>
Data Structures | |
struct | v6pseudohdr |
struct | tcp_opt_mss |
struct | tcp_opt_wscale |
struct | tcp_opt_sack_perm |
struct | tcp_opt_tstamp |
struct | tcp_options |
struct | v6pseudo_udp_hdr |
struct | v6pseudo_icmp_hdr |
struct | igmp6_hdr |
Macros | |
#define | FIX(n) htons (n) |
#define | UNFIX(n) ntohs (n) |
#define | rnd_tcp_port() (rand () % 65535 + 1024) |
Functions | |
static int | np_in_cksum (u_short *p, int n) |
tree_cell * | forge_ip_v6_packet (lex_ctxt *lexic) |
Forge an IPv6 packet. More... | |
tree_cell * | get_ip_v6_element (lex_ctxt *lexic) |
Obtain IPv6 header element. More... | |
tree_cell * | set_ip_v6_elements (lex_ctxt *lexic) |
Set IPv6 header element. More... | |
tree_cell * | dump_ip_v6_packet (lex_ctxt *lexic) |
Print IPv6 Header. More... | |
tree_cell * | insert_ip_v6_options (lex_ctxt *lexic) |
Adds an IPv6 option to the datagram. More... | |
struct v6pseudohdr | __attribute__ ((packed)) |
tree_cell * | forge_tcp_v6_packet (lex_ctxt *lexic) |
Forge TCP packet. More... | |
tree_cell * | get_tcp_v6_element (lex_ctxt *lexic) |
Get TCP Header element. More... | |
static void | get_tcp_options (char *options, struct tcp_options *tcp_all_options) |
Extract all TCP option from an IP datagram. More... | |
tree_cell * | get_tcp_v6_option (lex_ctxt *lexic) |
Get a TCP option from an IP datagram if present. Possible options are: TCPOPT_MAXSEG (2), values between 536 and 65535 TCPOPT_WINDOW (3), with values between 0 and 14 TCPOPT_SACK_PERMITTED (4), no value required. TCPOPT_TIMESTAMP (8), 8 bytes value for timestamp and echo timestamp, 4 bytes each one. More... | |
tree_cell * | set_tcp_v6_elements (lex_ctxt *lexic) |
Set TCP Header element. More... | |
tree_cell * | insert_tcp_v6_options (lex_ctxt *lexic) |
Add options to a TCP segment header. Possible options are: TCPOPT_MAXSEG (2), values between 536 and 65535 TCPOPT_WINDOW (3), with values between 0 and 14 TCPOPT_SACK_PERMITTED (4), no value required. TCPOPT_TIMESTAMP (8), 8 bytes value for timestamp and echo timestamp, 4 bytes each one. More... | |
tree_cell * | dump_tcp_v6_packet (lex_ctxt *lexic) |
Dump TCP part of an IPv6 Datagram. More... | |
tree_cell * | forge_udp_v6_packet (lex_ctxt *lexic) |
tree_cell * | get_udp_v6_element (lex_ctxt *lexic) |
tree_cell * | set_udp_v6_elements (lex_ctxt *lexic) |
tree_cell * | dump_udp_v6_packet (lex_ctxt *lexic) |
tree_cell * | forge_icmp_v6_packet (lex_ctxt *lexic) |
tree_cell * | get_icmp_v6_element (lex_ctxt *lexic) |
tree_cell * | dump_icmp_v6_packet (lex_ctxt *lexic) |
Dump the ICMP part of a IP Datagram. More... | |
tree_cell * | forge_igmp_v6_packet (lex_ctxt *lexic) |
tree_cell * | nasl_tcp_v6_ping (lex_ctxt *lexic) |
Performs TCP Connect to test if host is alive. More... | |
tree_cell * | nasl_send_v6packet (lex_ctxt *lexic) |
Send forged IPv6 Packets. More... | |
Variables | |
struct in6_addr | s6addr |
struct in6_addr | d6addr |
u_short | length |
u_char | zero1 |
u_char | zero2 |
u_char | zero3 |
u_char | protocol |
struct tcphdr | tcpheader |
uint8_t | kind |
uint8_t | len |
uint16_t | mss |
uint8_t | wscale |
uint32_t | tstamp |
uint32_t | e_tstamp |
struct tcp_opt_sack_perm | sack_perm |
struct v6pseudo_udp_hdr | __attribute__ |
NASL IPv6 Packet Forgery functions.
Provides IPv6 Packet Forgery functionalities The API set offers forgery for,
#define FIX | ( | n | ) | htons (n) |
#define rnd_tcp_port | ( | ) | (rand () % 65535 + 1024) |
#define UNFIX | ( | n | ) | ntohs (n) |
struct v6pseudohdr __attribute__ | ( | (packed) | ) |
Dump the ICMP part of a IP Datagram.
[in] | lexic | Lexical context of NASL interpreter. |
[in] | ... | IP datagrams to dump the ICMP part from. |
Print IPv6 Header.
[in] | lexic | Lexical context of NASL interpreter. |
[in] | ... | IPv6 datagrams to dump. |
Dump TCP part of an IPv6 Datagram.
[in] | lexic | Lexical context of NASL interpreter. |
[in] | ... | IPv6 datagrams to dump. |
Forge an IPv6 packet.
[in] | lexic | Lexical context of NASL interpreter. |
[in] | data | Data payload |
[in] | ip6_v | Version. 6 by default. |
[in] | ip6_tc | Traffic class. 0 by default. |
[in] | ip6_fl | Flow label. 0 by default. |
[in] | ip6_p | IP protocol. 0 by default. |
[in] | ip6_hlim | Hop limit. Max. 255. 64 by default. |
[in] | ip6_src | Source address. |
[in] | ip6_dst | Destination address. |
Forge TCP packet.
[in] | lexic | Lexical context of NASL interpreter. |
[in] | ip6 | IPv6 packet. |
[in] | data | Data. |
[in] | th_sport | Source port. 0 by default. |
[in] | th_dport | Destination port. 0 by default. |
[in] | th_seq | Sequence number. Random by default. |
[in] | th_ack | Acknowledgement number. 0 by default. |
[in] | th_x2 | 0 by default. |
[in] | th_off | Data offset. 5 by default. |
[in] | th_flags | Flags. 0 by default. |
[in] | th_win | Window. 0 by default. |
[in] | th_sum | Checksum. Is filled in automatically by default |
[in] | th_urp | Urgent pointer. 0 by default. |
Obtain IPv6 header element.
[in] | lexic | Lexical context of NASL interpreter. |
[in] | ipv6 | IPv6 header. TODO: Once versions older than 20.08 are no longer in use the parameter name can be changed to 'ip6'. |
[in] | element | Element to extract from the header. |
|
static |
Extract all TCP option from an IP datagram.
[in] | options | All options present in the TCP segment. |
[out] | tcp_all_options | Container for the options to return. |
Get TCP Header element.
[in] | lexic | Lexical context of NASL interpreter. |
[in] | tcp | IPv6 packet |
[in] | element | Element to extract from the header (see forge_tcp_v6_packet()). |
Get a TCP option from an IP datagram if present. Possible options are: TCPOPT_MAXSEG (2), values between 536 and 65535 TCPOPT_WINDOW (3), with values between 0 and 14 TCPOPT_SACK_PERMITTED (4), no value required. TCPOPT_TIMESTAMP (8), 8 bytes value for timestamp and echo timestamp, 4 bytes each one.
[in] | lexic | Lexical context of NASL interpreter. |
[in] | tcp | The full IP datagram (IP + TCP). |
[in] | option | Option to get. |
Adds an IPv6 option to the datagram.
[in] | lexic | Lexical context of NASL interpreter. |
[in] | ip6 | IPv6 packet. |
[in] | data | Data payload. |
[in] | code | Code of option. |
[in] | length | Length of value. |
[in] | value | Value of the option. |
Add options to a TCP segment header. Possible options are: TCPOPT_MAXSEG (2), values between 536 and 65535 TCPOPT_WINDOW (3), with values between 0 and 14 TCPOPT_SACK_PERMITTED (4), no value required. TCPOPT_TIMESTAMP (8), 8 bytes value for timestamp and echo timestamp, 4 bytes each one.
[in] | lexic | Lexical context of NASL interpreter. |
[in] | tcp | IP datagram. |
[in] | data | (optional) TCP data payload. |
[in] | unnamed | option. |
[in] | Value | for unnamed option if required. |
Send forged IPv6 Packets.
[in] | lexic | Lexical context of NASL interpreter. |
[in] | ... | IPv6 packets to send. |
[in] | length | Length of each packet by default. |
[in] | pcap_active | TRUE by default. Otherwise, NASL does not listen for the answers. |
[in] | pcap_filter | BPF filter. |
[in] | pcap_timeout | Capture timeout. 5 by default. |
[in] | allow_multicast | Default 0. |
Performs TCP Connect to test if host is alive.
[in] | lexic | Lexical context of NASL interpreter. |
[in] | port | Port to ping. Internal list of common ports is used as default. |
|
static |
Set IPv6 header element.
[in] | lexic | Lexical context of NASL interpreter. |
[in] | ip6 | IP v6 header. |
[in] | ip6_plen | Payload length. |
[in] | ip6_hlim | Hop limit. Max. 255 |
[in] | ip6_nxt | Next packet. |
[in] | ip6_src | Source address |
Set TCP Header element.
[in] | lexic | Lexical context of NASL interpreter. |
[in] | tcp | IPv6 packet to modify. |
[in] | data | Data. |
[in] | th_sport | Source port. |
[in] | th_dport | Destination port. |
[in] | th_seq | Sequence number. |
[in] | th_ack | Acknowledgement number. |
[in] | th_x2 | |
[in] | th_off | Data offset. |
[in] | th_flags | Flags. |
[in] | th_win | Window. |
[in] | th_sum | Checksum. |
[in] | th_urp | Urgent pointer. |
[in] | update_ip_len | Flag (TRUE by default). If set, NASL will recompute the size field of the IP datagram. |
struct v6pseudo_udp_hdr __attribute__ |
struct in6_addr d6addr |
uint32_t e_tstamp |
uint8_t kind |
uint8_t len |
u_short length |
struct tcp_opt_mss mss |
u_char protocol |
struct in6_addr s6addr |
struct tcp_opt_sack_perm sack_perm |
struct tcphdr tcpheader |
struct tcp_opt_tstamp tstamp |
struct tcp_opt_wscale wscale |
u_char zero1 |
u_char zero2 |
u_char zero3 |