dsniff  2.4b2
About: A collection of tools for network auditing
  Fossies Dox: dsniff-2.4b2.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

filesnarf.c File Reference
#include "config.h"
#include <sys/types.h>
#include <rpc/rpc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <regex.h>
#include <err.h>
#include <libnet.h>
#include <nids.h>
#include <pcap.h>
#include "decode.h"
#include "pcaputil.h"
#include "nfs_prot.h"
#include "rpc.h"
#include "version.h"
Include dependency graph for filesnarf.c:

Go to the source code of this file.

Data Structures

struct  myreadargs
 
struct  fh_map
 

Macros

#define FH_MAP_SIZE   128
 

Functions

static void usage (void)
 
bool_t xdr_u_int64_t (XDR *xdrs, u_int64_t *nump)
 
bool_t xdr_int64_t (XDR *xdrs, int64_t *nump)
 
static void fh_map_init (void)
 
static void fh_map_add (char *filename, u_char *fh, int len)
 
static char * fh_map_find (u_char *fh, int len)
 
static int regex_match (char *string)
 
static void nfs_save (struct tuple4 *addr, struct myreadargs *ma, u_char *buf, int len)
 
static void nfs2_call (u_int32_t xid, u_int32_t proc, u_char *buf, int len)
 
static void nfs2_reply (struct xid_map *xm, struct tuple4 *addr, u_char *buf, int len)
 
static void nfs3_call (u_int32_t xid, u_int32_t proc, u_char *buf, int len)
 
static void nfs3_reply (struct xid_map *xm, struct tuple4 *addr, u_char *buf, int len)
 
static void decode_nfs (struct tuple4 *addr, u_char *buf, int len)
 
static void decode_udp_nfs (struct libnet_ipv4_hdr *ip)
 
static int decode_tcp_nfs_half (struct tuple4 *addr, struct half_stream *hs)
 
static void decode_tcp_nfs (struct tcp_stream *ts, void **darth)
 
static void null_syslog (int type, int errnum, struct ip *iph, void *data)
 
int main (int argc, char *argv[])
 

Variables

struct fh_map fh_maps [128]
 
int fh_map_next = 0
 
int fh_map_hint = 0
 
int Opt_invert = 0
 
regex_t * pregex = NULL
 

Macro Definition Documentation

◆ FH_MAP_SIZE

#define FH_MAP_SIZE   128

Definition at line 42 of file filesnarf.c.

Function Documentation

◆ decode_nfs()

static void decode_nfs ( struct tuple4 *  addr,
u_char *  buf,
int  len 
)
static

◆ decode_tcp_nfs()

static void decode_tcp_nfs ( struct tcp_stream *  ts,
void **  darth 
)
static

Definition at line 420 of file filesnarf.c.

References decode_tcp_nfs_half().

Referenced by main().

◆ decode_tcp_nfs_half()

static int decode_tcp_nfs_half ( struct tuple4 *  addr,
struct half_stream *  hs 
)
static

Definition at line 389 of file filesnarf.c.

References buf, decode_nfs(), FRAGLEN, LASTFRAG, buf::offset, and pntohl.

Referenced by decode_tcp_nfs().

◆ decode_udp_nfs()

static void decode_udp_nfs ( struct libnet_ipv4_hdr *  ip)
static

Definition at line 356 of file filesnarf.c.

References buf, and decode_nfs().

Referenced by main().

◆ fh_map_add()

static void fh_map_add ( char *  filename,
u_char *  fh,
int  len 
)
static

Definition at line 89 of file filesnarf.c.

References err(), fh_map::fh, fh_map_next, FH_MAP_SIZE, fh_maps, and fh_map::filename.

Referenced by nfs2_reply(), and nfs3_reply().

◆ fh_map_find()

static char* fh_map_find ( u_char *  fh,
int  len 
)
static

Definition at line 105 of file filesnarf.c.

References fh_map::fh, fh_map_hint, FH_MAP_SIZE, fh_maps, fh_map::filename, and memcmp().

Referenced by nfs2_call(), and nfs3_call().

◆ fh_map_init()

static void fh_map_init ( void  )
static

Definition at line 83 of file filesnarf.c.

References fh_maps.

Referenced by main().

◆ main()

int main ( int  argc,
char *  argv[] 
)

◆ nfs2_call()

static void nfs2_call ( u_int32_t  xid,
u_int32_t  proc,
u_char *  buf,
int  len 
)
static

Definition at line 149 of file filesnarf.c.

References fh_map_find(), myreadargs::filename, myreadargs::offset, regex_match(), and xid_map_enter().

Referenced by decode_nfs().

◆ nfs2_reply()

static void nfs2_reply ( struct xid_map xm,
struct tuple4 *  addr,
u_char *  buf,
int  len 
)
static

Definition at line 196 of file filesnarf.c.

References xid_map::data, fh_map_add(), nfs_save(), and xid_map::proc.

Referenced by decode_nfs().

◆ nfs3_call()

static void nfs3_call ( u_int32_t  xid,
u_int32_t  proc,
u_char *  buf,
int  len 
)
static

Definition at line 234 of file filesnarf.c.

References fh_map_find(), myreadargs::filename, myreadargs::offset, regex_match(), and xid_map_enter().

Referenced by decode_nfs().

◆ nfs3_reply()

static void nfs3_reply ( struct xid_map xm,
struct tuple4 *  addr,
u_char *  buf,
int  len 
)
static

Definition at line 281 of file filesnarf.c.

References xid_map::data, fh_map_add(), nfs_save(), and xid_map::proc.

Referenced by decode_nfs().

◆ nfs_save()

static void nfs_save ( struct tuple4 *  addr,
struct myreadargs ma,
u_char *  buf,
int  len 
)
static

Definition at line 132 of file filesnarf.c.

References myreadargs::filename, myreadargs::offset, and warnx().

Referenced by nfs2_reply(), and nfs3_reply().

◆ null_syslog()

static void null_syslog ( int  type,
int  errnum,
struct ip *  iph,
void *  data 
)
static

Definition at line 456 of file filesnarf.c.

Referenced by main().

◆ regex_match()

static int regex_match ( char *  string)
static

Definition at line 125 of file filesnarf.c.

References Opt_invert, and pregex.

Referenced by nfs2_call(), and nfs3_call().

◆ usage()

static void usage ( void  )
static

Definition at line 51 of file filesnarf.c.

References VERSION.

Referenced by main().

◆ xdr_int64_t()

bool_t xdr_int64_t ( XDR *  xdrs,
int64_t *  nump 
)

Definition at line 77 of file filesnarf.c.

References xdr_u_int64_t().

◆ xdr_u_int64_t()

bool_t xdr_u_int64_t ( XDR *  xdrs,
u_int64_t *  nump 
)

Definition at line 60 of file filesnarf.c.

Referenced by xdr_int64_t().

Variable Documentation

◆ fh_map_hint

int fh_map_hint = 0

Definition at line 46 of file filesnarf.c.

Referenced by fh_map_find().

◆ fh_map_next

int fh_map_next = 0

Definition at line 45 of file filesnarf.c.

Referenced by fh_map_add().

◆ fh_maps

struct fh_map fh_maps[128]

Definition at line 44 of file filesnarf.c.

Referenced by fh_map_add(), fh_map_find(), and fh_map_init().

◆ Opt_invert

int Opt_invert = 0

Definition at line 47 of file filesnarf.c.

Referenced by main(), and regex_match().

◆ pregex

regex_t* pregex = NULL

Definition at line 48 of file filesnarf.c.

Referenced by main(), and regex_match().