OpenVAS Libraries  8.0.8
Data Structures | Macros | Functions | Variables
ids_send.c File Reference
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include "arglists.h"
#include "bpf_share.h"
#include "ids_send.h"
#include "network.h"
#include "pcap_openvas.h"
#include "plugutils.h"
#include "openvas_logging.h"
#include "support.h"

Data Structures

struct  ip_packet
 
struct  tcp_packet
 
struct  ipv6_header
 
struct  pseudohdr
 
union  sockaddr_u
 

Macros

#define FIX(n)   htons(n)
 
#define UNFIX(n)   ntohs(n)
 
#define TCP_FLAG_RST   0x0004
 
#define TCP_FLAG_ACK   0x0010
 
#define TCP_FLAG_PUSH   0x0008
 

Functions

 if (method &OPENVAS_CNX_IDS_EVASION_SHORT_TTL)
 
 while (n > 1)
 
 if (n==1)
 
 return (answer)
 
bzero & pseudoheader (struct tcp_packet)
 
 bcopy ((char *) tcp,(char *)&pseudoheader.tcpheader, sizeof(struct tcp_packet))
 
 bcopy ((char *)&pseudoheader, tcpsumdata, sizeof(struct pseudohdr))
 
 bcopy ((char *) data, tcpsumdata+sizeof(struct pseudohdr), len)
 
 g_free (tcpsumdata)
 
 if ()
 
 g_free (packet)
 
 close (soc)
 
 memcpy (ip6, old_ip6, sizeof(struct ipv6_header))
 
memcpyip6 (struct in6_addr)
 
 memcpy (tcp, old_tcp, sizeof(struct tcp_packet))
 
 if ((flags &TCP_FLAG_RST)&&(method &OPENVAS_CNX_IDS_EVASION_FAKE_RST))
 
 if (sa->sa_family==AF_INET)
 
memcpydst6 (struct in6_addr)
 
bzero & src6 (src6)
 
 snprintf (filter, sizeof(filter),"tcp and (src host %s and dst host %s and src port %d)", dst_host, src_host, port)
 
 g_free (src_host)
 
 g_free (dst_host)
 
 if (bpf >=0)
 
else return send (fd, buf, n, 0)
 
 if (!dst6)
 
else return open_sock_tcp (args, port, timeout)
 

Variables

 else
 
return ttl
 
int n
 
register long sum = 0
 
u_short odd_byte = 0
 
 answer = (int) ~sum
 
int len
 
char * tcpsumdata
 
struct in_addr source dest
 
struct ip_packetip = (struct ip_packet *) packet
 
struct tcp_packettcp = (struct tcp_packet *) (packet + ip->ip_hl * 4)
 
char * data = (char *) (packet + ip->ip_hl * 4 + tcp->th_off * 4)
 
source s_addr = ip->ip_src.s_addr
 
pseudoheader protocol = IPPROTO_TCP
 
pseudoheader length = htons (sizeof (struct tcp_packet) + len)
 
tcp th_sum
 
 return
 
int packet_len
 
int flags
 
int data_len
 
struct ip_packetold_ip
 
struct tcp_packetold_tcp
 
int tot_len
 
int i
 
int one = 1
 
struct sockaddr_in sockaddr
 
struct ipv6_headerip6 = (struct ipv6_header *) packet
 
struct ipv6_headerold_ip6
 
struct sockaddr_in6 sockaddr6
 
ip6 ip6_ctlun ip6_un1 ip6_un1_flow = old_ip6->ip6_ctlun.ip6_un1.ip6_un1_flow
 
ip6 ip6_ctlun ip6_un1 ip6_un1_plen = data_len
 
ip6 ip6_ctlun ip6_un1 ip6_un1_nxt = old_ip6->ip6_ctlun.ip6_un1.ip6_un1_nxt
 
ip6 ip6_ctlun ip6_un1 ip6_un1_hlim
 
tcp th_flags = flags
 
int int fd
 
void * buf0
 
struct in6_addr dst6 src6
 
struct sockaddr_in * saddr
 
struct sockaddrsa = &(su->sockaddr)
 
union sockaddr_usu = NULL
 
char * iface = v6_routethrough (&dst6, &src6)
 
char filter [255]
 
char * src_host
 
char * dst_host
 
int port = ntohs (sockaddr6.sin6_port)
 
int ret = 0
 
char * buf = (char *) buf0
 
unsigned int sz = sizeof (sockaddr6)
 
int e
 
int bpf = bpf_open_live (iface, filter)
 
char hostname [INET6_ADDRSTRLEN]
 
int family = AF_INET6
 
int struct arglistargs
 
int timeout
 
struct in_addr dst src
 
struct in6_addr * dst6 = NULL
 

Macro Definition Documentation

#define FIX (   n)    htons(n)
Todo:
: It still needs to be taken care BSD_BYTE_ORDERING gets here if defined (e.g. by config.h)
#define TCP_FLAG_ACK   0x0010
#define TCP_FLAG_PUSH   0x0008
#define TCP_FLAG_RST   0x0004
#define UNFIX (   n)    ntohs(n)

Function Documentation

bcopy ( (char *)  tcp,
(char *)&pseudoheader.  tcpheader,
sizeof(struct tcp_packet  
)
bcopy ( (char *)&  pseudoheader,
tcpsumdata  ,
sizeof(struct pseudohdr  
)
bcopy ( (char *)  data,
tcpsumdata sizeofstruct pseudohdr,
len   
)
close ( soc  )
memcpy& dst6 ( struct in6_addr  )
g_free ( tcpsumdata  )
g_free ( packet  )
g_free ( src_host  )
g_free ( dst_host  )
if ( method &  OPENVAS_CNX_IDS_EVASION_SHORT_TTL)
if ( n  = = 1)
if ( )
if ( sa->  sa_family = = AF_INET)
if ( bpf >=  0)
if ( dst6)
memcpy& ip6 ( struct in6_addr  )
memcpy ( ip6  ,
old_ip6  ,
sizeof(struct ipv6_header  
)
memcpy ( tcp  ,
old_tcp  ,
sizeof(struct tcp_packet  
)
else return open_sock_tcp ( args  ,
port  ,
timeout   
)
bzero& pseudoheader ( struct tcp_packet  )
return ( answer  )
else return send ( fd  ,
buf  ,
n  ,
 
)
snprintf ( filter  ,
sizeof(filter ,
"tcp and (src host %s and dst host %s and src port %d)"  ,
dst_host  ,
src_host  ,
port   
)
bzero& src6 ( src6  )
while ( n  ,
 
)

Variable Documentation

answer = (int) ~sum
int struct arglist* args
char* buf = (char *) buf0
void* buf0
char * data = (char *) (packet + ip->ip_hl * 4 + tcp->th_off * 4)
int data_len
struct in_addr source dest
dst6 = NULL
char * dst_host
Initial value:
=
g_strdup (inet_ntop (AF_INET6, &dst6, hostname, sizeof (hostname)))
char hostname[INET6_ADDRSTRLEN]
Definition: ids_send.c:549
struct in6_addr * dst6
Definition: ids_send.c:698
int e
else
Initial value:
{
ttl = 64
return ttl
Definition: ids_send.c:228
int family = AF_INET6
int int fd
char filter
int flags
char hostname
int i
char * iface = v6_routethrough (&dst6, &src6)
struct ip_packet * ip = (struct ip_packet *) packet
memcpy & ip6 = (struct ipv6_header *) packet
ip6 ip6_ctlun ip6_un1 ip6_un1_flow = old_ip6->ip6_ctlun.ip6_un1.ip6_un1_flow
ip6 ip6_ctlun ip6_un1 ip6_un1_hlim
Initial value:
=
which_ttl (method, old_ip6->ip6_ctlun.ip6_un1.ip6_un1_hlim)
union ipv6_header::@2 ip6_ctlun
struct ipv6_header::@2::ip6_hdrctl ip6_un1
struct ipv6_header * old_ip6
Definition: ids_send.c:442
ip6 ip6_ctlun ip6_un1 ip6_un1_nxt = old_ip6->ip6_ctlun.ip6_un1.ip6_un1_nxt
ip6 ip6_ctlun ip6_un1 ip6_un1_plen = data_len
int len
pseudoheader length = htons (sizeof (struct tcp_packet) + len)
int n
u_short odd_byte = 0
struct ip_packet * old_ip
struct ipv6_header * old_ip6
struct tcp_packet * old_tcp
int one = 1
int packet_len
int port = ntohs (sockaddr6.sin6_port)
pseudoheader protocol = IPPROTO_TCP
int ret = 0
return
src s_addr = ip->ip_src.s_addr
sa = &(su->sockaddr)
struct sockaddr_in* saddr
struct sockaddr_in sockaddr
struct sockaddr_in6 sockaddr6
struct in_addr dst src
Initial value:
{
int bpf
int bpf
Definition: ids_send.c:548
struct in6_addr src6
Initial value:
{
struct in_addr dst, src
struct in_addr dst src
Definition: ids_send.c:697
char * src_host
Initial value:
=
g_strdup (inet_ntop (AF_INET6, &src6, hostname, sizeof (hostname)))
struct in6_addr dst6 src6
Definition: ids_send.c:533
char hostname[INET6_ADDRSTRLEN]
Definition: ids_send.c:549
union sockaddr_u* su = NULL
sum = 0
unsigned int sz = sizeof (sockaddr6)
struct tcp_packet * tcp = (struct tcp_packet *) (packet + ip->ip_hl * 4)
char* tcpsumdata
Initial value:
=
(char *) g_malloc0 (sizeof (struct pseudohdr) + (len % 2 ? len + 1 : 0))
int len
Definition: ids_send.c:264
Definition: ids_send.c:130
tcp th_flags = flags
tcp th_sum
Initial value:
=
in_cksum ((unsigned short *) tcpsumdata,
12 + sizeof (struct tcp_packet) + len)
int len
Definition: ids_send.c:264
char * tcpsumdata
Definition: ids_send.c:267
Definition: ids_send.c:82
int timeout
int tot_len
Initial value:
=
sizeof (struct ip_packet) + sizeof (struct tcp_packet) + data_len
int data_len
Definition: ids_send.c:335
Definition: ids_send.c:63
Definition: ids_send.c:82
return ttl