|
OpenVAS Scanner 23.32.3
|
Functions to forge and manipulate datalink layer frames. More...
#include "nasl_frame_forgery.h"#include "../misc/bpf_share.h"#include "../misc/pcap_openvas.h"#include "../misc/plugutils.h"#include "capture_packet.h"#include "nasl_debug.h"#include <errno.h>#include <gvm/base/networking.h>#include <linux/if_packet.h>#include <net/ethernet.h>#include <net/if.h>#include <net/if_arp.h>#include <netinet/ether.h>#include <netinet/if_ether.h>#include <stdint.h>#include <stdio.h>#include <stdlib.h>#include <sys/ioctl.h>#include <unistd.h>
Go to the source code of this file.
Data Structures | |
| struct | pseudo_eth_arp |
| struct | pseudo_frame |
Macros | |
| #define | G_LOG_DOMAIN "lib misc" |
| GLib logging domain. | |
Functions | |
| struct pseudo_eth_arp | __attribute__ ((packed)) |
| static void | dump_frame (const u_char *frame, int frame_sz) |
| Dump a datalink layer frame. | |
| static void | prepare_sockaddr_ll (struct sockaddr_ll *soc_addr_ll, int ifindex, const u_char *ether_dst_addr) |
| Prepare message header to be sent with sendmsg(). | |
| static void | prepare_message (u_char *msg, struct sockaddr_ll *soc_addr_ll, u_char *payload, int payload_sz) |
| Prepare message header to be sent with sendmsg(). | |
| static int | send_frame (const u_char *frame, int frame_sz, int use_pcap, int timeout, char *filter, struct in6_addr *ipaddr, u_char **answer) |
| Send a frame and listen to the answer. | |
| static int | forge_frame (const u_char *ether_src_addr, const u_char *ether_dst_addr, int ether_proto, u_char *payload, int payload_sz, struct pseudo_frame **frame) |
| Forge a datalink layer frame. | |
| tree_cell * | nasl_forge_frame (lex_ctxt *lexic) |
| Forge a datalink layer frame. | |
| tree_cell * | nasl_send_frame (lex_ctxt *lexic) |
| Send a frame and listen to the answer. | |
| tree_cell * | nasl_dump_frame (lex_ctxt *lexic) |
| Dump a datalink layer frame. | |
| static int | get_local_mac_address_from_ip (char *ip_address, u_char *mac) |
| Get the MAC address of host. | |
| tree_cell * | nasl_get_local_mac_address_from_ip (lex_ctxt *lexic) |
| Get the MAC address of host. | |
| tree_cell * | nasl_send_arp_request (lex_ctxt *lexic) |
| Send an arp request to an IP host. | |
Variables | |
| struct arphdr | arp_header |
| u_char | __ar_sha [ETH_ALEN] |
| u_char | __ar_sip [4] |
| u_char | __ar_tha [ETH_ALEN] |
| u_char | __ar_tip [4] |
| u_char | __zero_padding [18] |
| struct ethhdr | framehdr |
| u_char * | payload |
Functions to forge and manipulate datalink layer frames.
Definition in file nasl_frame_forgery.c.
| #define G_LOG_DOMAIN "lib misc" |
GLib logging domain.
Definition at line 38 of file nasl_frame_forgery.c.
| struct pseudo_eth_arp __attribute__ | ( | (packed) | ) |
|
static |
Dump a datalink layer frame.
| frame | The frame to be dumped. |
| frame_sz | The frame's size. |
Definition at line 63 of file nasl_frame_forgery.c.
Referenced by nasl_dump_frame().

|
static |
Forge a datalink layer frame.
| [in] | src_haddr | Source MAC address to use. |
| [in] | dst_haddr | Destination MAC address to use. |
| [in] | ether_proto | Ethernet type integer in hex format. Default 0x0800 (ETHER_P_IP) |
| [in] | payload | Payload to be attached to the frame. E.g a forged tcp datagram, or arp header |
| [out] | frame | the forge frame |
Definition at line 230 of file nasl_frame_forgery.c.
References payload.
Referenced by nasl_forge_frame(), and nasl_send_arp_request().

|
static |
Get the MAC address of host.
| [in] | ip_address | Local IP address |
| [out] | mac | The MAC address |
Definition at line 389 of file nasl_frame_forgery.c.
References get_iface_from_ip(), and mac().
Referenced by nasl_get_local_mac_address_from_ip(), and nasl_send_arp_request().


Dump a datalink layer frame.
@naslparam
| lexic | Lexical context of NASL interpreter. |
Definition at line 363 of file nasl_frame_forgery.c.
References dump_frame(), get_str_var_by_name(), get_var_size_by_name(), and nasl_perror().

Forge a datalink layer frame.
@naslparams
| lexic | Lexical context of NASL interpreter. |
Definition at line 268 of file nasl_frame_forgery.c.
References alloc_typed_cell(), CONST_DATA, forge_frame(), get_int_var_by_name(), get_str_var_by_name(), get_var_size_by_name(), nasl_perror(), payload, TC::size, TC::str_val, and TC::x.

Get the MAC address of host.
@naslparam
ip_address Local IP address
@naslreturn The MAC address of the host. NULL otherwise
| [in] | lexic | Lexical context of NASL interpreter. |
Definition at line 438 of file nasl_frame_forgery.c.
References alloc_typed_cell(), CONST_DATA, get_local_mac_address_from_ip(), get_str_var_by_num(), mac(), TC::size, TC::str_val, and TC::x.

Send an arp request to an IP host.
| [in] | lexic | Lexical context of NASL interpreter. |
Definition at line 471 of file nasl_frame_forgery.c.
References pseudo_eth_arp::__ar_sha, pseudo_eth_arp::__ar_sip, pseudo_eth_arp::__ar_tha, pseudo_eth_arp::__ar_tip, alloc_typed_cell(), pseudo_eth_arp::arp_header, CONST_DATA, daddr, forge_frame(), get_int_var_by_name(), get_local_mac_address_from_ip(), mac(), plug_get_host_ip(), routethrough(), struct_lex_ctxt::script_infos, send_frame(), TC::size, TC::str_val, and TC::x.

Send a frame and listen to the answer.
@naslparams
| lexic | Lexical context of NASL interpreter. |
Definition at line 314 of file nasl_frame_forgery.c.
References alloc_typed_cell(), CONST_DATA, get_int_var_by_name(), get_str_var_by_name(), get_var_size_by_name(), nasl_perror(), plug_get_host_ip(), struct_lex_ctxt::script_infos, send_frame(), TC::size, TC::str_val, and TC::x.

|
static |
Prepare message header to be sent with sendmsg().
| [out] | msg | The packaged messages to be sent |
| [in] | soc_addr_ll | The sockaddr_ll structure for capturing |
| [in] | payload | The payload, a datalink layer frame with payload |
| [in] | payload_sz | The payload size. |
Definition at line 103 of file nasl_frame_forgery.c.
References payload.
Referenced by send_frame().

|
static |
Prepare message header to be sent with sendmsg().
| [out] | soc_addr_ll | The sockaddr_ll structure to be prepared |
| [in] | ifindex | The interface index to be use for capturing. |
| [in] | ether_dst_addr | The dst MAC address. |
Definition at line 85 of file nasl_frame_forgery.c.
Referenced by send_frame().

|
static |
Send a frame and listen to the answer.
| [in] |
The frame to be sent.
| [in] |
The frame's size.
| [in] |
TRUE by default. Otherwise, NASL does not listen for the answers.
| [in] |
BPF filter.
| [in] |
Capture timeout. 5 by default.
| [in] |
Destination address, used for calculating the ethernet index
| [out] |
Sniffed answer.
Definition at line 141 of file nasl_frame_forgery.c.
References bpf_close(), capture_next_frame(), get_iface_index(), init_capture_device(), init_v6_capture_device(), prepare_message(), and prepare_sockaddr_ll().
Referenced by nasl_send_arp_request(), and nasl_send_frame().


| u_char __ar_sha[ETH_ALEN] |
Definition at line 1 of file nasl_frame_forgery.c.
| u_char __ar_sip[4] |
Definition at line 2 of file nasl_frame_forgery.c.
| u_char __ar_tha[ETH_ALEN] |
Definition at line 3 of file nasl_frame_forgery.c.
| u_char __ar_tip[4] |
Definition at line 4 of file nasl_frame_forgery.c.
| u_char __zero_padding[18] |
Definition at line 5 of file nasl_frame_forgery.c.
| struct arphdr arp_header |
Definition at line 0 of file nasl_frame_forgery.c.
| struct ethhdr framehdr |
Definition at line 0 of file nasl_frame_forgery.c.
| u_char* payload |
Definition at line 1 of file nasl_frame_forgery.c.
Referenced by forge_frame(), nasl_forge_frame(), prepare_message(), and run_table_driven_lsc().