OpenVAS Scanner
7.0.1~git
|
Port scanner Synscan. More...
#include "../misc/bpf_share.h"
#include "../misc/network.h"
#include "../misc/pcap_openvas.h"
#include "../misc/plugutils.h"
#include "nasl_lex_ctxt.h"
#include <arpa/inet.h>
#include <gvm/base/logging.h>
#include <gvm/base/prefs.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
Go to the source code of this file.
Data Structures | |
struct | pseudohdr |
struct | list |
Macros | |
#define | _BSD_SOURCE 1 |
#define | _DEFAULT_SOURCE 1 |
#define | NUM_RETRIES 2 |
#define | G_LOG_DOMAIN "lib nasl" |
GLib logging domain. More... | |
Functions | |
static int | in_cksum (u_short *p, int n) |
unsigned long | maketime () |
struct timeval | timeval (unsigned long val) |
unsigned long | compute_rtt (unsigned long then) |
int | packetdead (unsigned long then) |
int | rawsocket (int family) |
Opens and returns a raw socket. More... | |
int | openbpf (struct in_addr dst, struct in_addr *src, int magic) |
Opens a packet filter, grabs packets from dst to port magic . More... | |
int | v6_openbpf (struct in6_addr *dst, struct in6_addr *src, int magic) |
struct list * | get_packet (struct list *l, unsigned short dport) |
struct list * | add_packet (struct list *l, unsigned short dport, unsigned long ack) |
If no packet with dport is in list, prepends a "packet" to the. More... | |
struct list * | rm_packet (struct list *l, unsigned short dport) |
struct list * | rm_dead_packets (struct list *l, int *retry) |
struct tcphdr * | extracttcp (char *pkt, unsigned int len) |
struct tcphdr * | v6_extracttcp (char *pkt) |
unsigned long | extractack (char *pkt, int len, int family) |
unsigned short | extractsport (char *pkt, int len, int family) |
int | issynack (char *pkt, int len, int family) |
char * | mktcp (struct in_addr src, int sport, struct in_addr dst, int dport, unsigned long th_ack, unsigned char flag) |
char * | mktcpv6 (int sport, int dport, unsigned long th_ack, unsigned char flag) |
struct list * | sendpacket (int soc, int bpf, int skip, struct in_addr dst, struct in_addr src, int dport, int magic, struct list *packets, unsigned long *rtt, int sniff, struct script_infos *env) |
struct list * | v6_sendpacket (int soc, int bpf, int skip, struct in6_addr *dst, int dport, int magic, struct list *packets, unsigned long *rtt, int sniff, struct script_infos *env) |
int | scan (struct script_infos *env, char *portrange, struct in6_addr *dst6, unsigned long rtt) |
tree_cell * | plugin_run_synscan (lex_ctxt *lexic) |
Port scanner Synscan.
Definition in file nasl_builtin_synscan.c.
#define _BSD_SOURCE 1 |
Definition at line 25 of file nasl_builtin_synscan.c.
#define _DEFAULT_SOURCE 1 |
Definition at line 27 of file nasl_builtin_synscan.c.
#define G_LOG_DOMAIN "lib nasl" |
GLib logging domain.
Definition at line 54 of file nasl_builtin_synscan.c.
#define NUM_RETRIES 2 |
Definition at line 48 of file nasl_builtin_synscan.c.
Referenced by rm_dead_packets().
If no packet with dport
is in list, prepends a "packet" to the.
list l
.
Definition at line 290 of file nasl_builtin_synscan.c.
References list::dport, get_packet(), list::next, list::prev, list::retries, and list::when.
Referenced by sendpacket(), and v6_sendpacket().
unsigned long compute_rtt | ( | unsigned long | then | ) |
Definition at line 132 of file nasl_builtin_synscan.c.
References maketime().
Referenced by sendpacket().
unsigned long extractack | ( | char * | pkt, |
int | len, | ||
int | family | ||
) |
Definition at line 401 of file nasl_builtin_synscan.c.
References extracttcp(), and v6_extracttcp().
Referenced by sendpacket().
unsigned short extractsport | ( | char * | pkt, |
int | len, | ||
int | family | ||
) |
Definition at line 418 of file nasl_builtin_synscan.c.
References extracttcp(), and v6_extracttcp().
Referenced by sendpacket(), and v6_sendpacket().
struct tcphdr* extracttcp | ( | char * | pkt, |
unsigned int | len | ||
) |
Definition at line 379 of file nasl_builtin_synscan.c.
Referenced by extractack(), extractsport(), and issynack().
dport
, NULL if no such list item could be found. Definition at line 273 of file nasl_builtin_synscan.c.
References list::dport, and list::next.
Referenced by add_packet(), and rm_packet().
|
static |
Definition at line 67 of file nasl_builtin_synscan.c.
Referenced by mktcp().
int issynack | ( | char * | pkt, |
int | len, | ||
int | family | ||
) |
Definition at line 434 of file nasl_builtin_synscan.c.
References extracttcp(), and v6_extracttcp().
Referenced by sendpacket(), and v6_sendpacket().
unsigned long maketime | ( | ) |
Definition at line 92 of file nasl_builtin_synscan.c.
References timeval().
Referenced by compute_rtt(), packetdead(), sendpacket(), and v6_sendpacket().
char* mktcp | ( | struct in_addr | src, |
int | sport, | ||
struct in_addr | dst, | ||
int | dport, | ||
unsigned long | th_ack, | ||
unsigned char | flag | ||
) |
Definition at line 450 of file nasl_builtin_synscan.c.
References pseudohdr::daddr, in_cksum(), pseudohdr::length, pseudohdr::protocol, pseudohdr::saddr, and pseudohdr::tcpheader.
Referenced by sendpacket().
char* mktcpv6 | ( | int | sport, |
int | dport, | ||
unsigned long | th_ack, | ||
unsigned char | flag | ||
) |
Definition at line 499 of file nasl_builtin_synscan.c.
Referenced by v6_sendpacket().
int openbpf | ( | struct in_addr | dst, |
struct in_addr * | src, | ||
int | magic | ||
) |
Opens a packet filter, grabs packets from dst
to port magic
.
[out] | src | in_addr of source. |
[in] | dst | Destination. |
[in] | magic | Destination port on src to listen to. |
dst
to port magic
. Definition at line 227 of file nasl_builtin_synscan.c.
References bpf_open_live(), and routethrough().
Referenced by scan().
int packetdead | ( | unsigned long | then | ) |
Definition at line 153 of file nasl_builtin_synscan.c.
References maketime().
Referenced by rm_dead_packets().
Definition at line 782 of file nasl_builtin_synscan.c.
References ARG_INT, islocalhost(), plug_get_host_ip(), plug_set_key(), scan(), and struct_lex_ctxt::script_infos.
int rawsocket | ( | int | family | ) |
Opens and returns a raw socket.
Definition at line 172 of file nasl_builtin_synscan.c.
Referenced by scan().
Definition at line 338 of file nasl_builtin_synscan.c.
References list::dport, list::next, NUM_RETRIES, packetdead(), list::prev, list::retries, and list::when.
Referenced by scan().
Definition at line 318 of file nasl_builtin_synscan.c.
References list::dport, get_packet(), list::next, and list::prev.
Referenced by sendpacket(), and v6_sendpacket().
int scan | ( | struct script_infos * | env, |
char * | portrange, | ||
struct in6_addr * | dst6, | ||
unsigned long | rtt | ||
) |
This will send packets to ports not in ports list, will it?
Definition at line 680 of file nasl_builtin_synscan.c.
References ARG_INT, bpf_close(), bpf_datalink(), get_datalink_size(), getpts(), openbpf(), plug_set_key(), rawsocket(), rm_dead_packets(), sendpacket(), v6_openbpf(), and v6_sendpacket().
Referenced by plugin_run_synscan().
struct list* sendpacket | ( | int | soc, |
int | bpf, | ||
int | skip, | ||
struct in_addr | dst, | ||
struct in_addr | src, | ||
int | dport, | ||
int | magic, | ||
struct list * | packets, | ||
unsigned long * | rtt, | ||
int | sniff, | ||
struct script_infos * | env | ||
) |
sniff | If != 0, "sniff" (listen to incoming packages), else just add packet. |
Definition at line 524 of file nasl_builtin_synscan.c.
References add_packet(), bpf_close(), bpf_next_tv(), compute_rtt(), list::dport, extractack(), extractsport(), issynack(), maketime(), mktcp(), rm_packet(), scanner_add_port(), and timeval().
Referenced by scan().
struct timeval timeval | ( | unsigned long | val | ) |
Definition at line 105 of file nasl_builtin_synscan.c.
References val.
Referenced by attack_network(), attack_start(), banner_grab(), bpf_next(), bpf_next_tv(), calculate_eta(), capture_next_packet(), capture_next_v6_packet(), do_reseed_ntlmssp(), maketime(), nasl_gettimeofday(), nasl_open_privileged_socket(), nasl_pcap_next(), nasl_recv(), nasl_send_capture(), nasl_tcp_ping(), nasl_tcp_v6_ping(), nsend(), open_socket(), open_SSL_connection(), plugin_do_run(), plugins_reload_from_dir(), read_stream_connection_unbuffered(), sendpacket(), update_running_processes(), v6_sendpacket(), wait_before_next_probe(), and write_stream_connection4().
struct tcphdr* v6_extracttcp | ( | char * | pkt | ) |
Definition at line 393 of file nasl_builtin_synscan.c.
Referenced by extractack(), extractsport(), and issynack().
int v6_openbpf | ( | struct in6_addr * | dst, |
struct in6_addr * | src, | ||
int | magic | ||
) |
Definition at line 241 of file nasl_builtin_synscan.c.
References bpf_open_live(), hostname, and v6_routethrough().
Referenced by scan().
struct list* v6_sendpacket | ( | int | soc, |
int | bpf, | ||
int | skip, | ||
struct in6_addr * | dst, | ||
int | dport, | ||
int | magic, | ||
struct list * | packets, | ||
unsigned long * | rtt, | ||
int | sniff, | ||
struct script_infos * | env | ||
) |
Definition at line 606 of file nasl_builtin_synscan.c.
References add_packet(), bpf_close(), bpf_next(), list::dport, extractsport(), issynack(), maketime(), mktcpv6(), rm_packet(), scanner_add_port(), and timeval().
Referenced by scan().