⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libnids.3.mdoc

📁 基于TCP/IP协议的网络入侵检测系统是在Linux平台下
💻 MDOC
字号:
.\" libnids manpage by Dug Song <dugsong@monkey.org>.Dd Dec 21, 1999.Dt PCAP 3.Os.Sh NAME.Nm libnids.Nd network intrusion detection system E-box library.Sh SYNOPSIS.Fd #include <nids.h>.Pp.Dv extern struct nids_prm nids_params;.Lp.Dv extern char *nids_warnings[];.Lp.Dv extern char nids_errbuf[];.Ft int.Fn nids_init "void".Ft void.Fn nids_register_ip_frag "void (*ip_frag_func)(struct ip *pkt)".Ft void.Fn nids_register_ip "void (*ip_func)(struct ip *pkt)".Ft void.Fn nids_register_udp "void (*udp_func)(struct tuple4 *addr, u_char *data, int len, struct ip *pkt))".Ft void.Fn nids_register_tcp "void (*tcp_func)(struct tcp_stream *ts, void **param)".Ft void.Fn nids_killtcp "struct tcp_stream *ts".Ft void.Fn nids_discard "struct tcp_stream *ts".Ft void.Fn nids_run "void".Ft int.Fn nids_next "void".Ft int.Fn nids_getfd "void".Sh DESCRIPTION.Nmprovides the functionality of a network intrusion detection system(NIDS) E-box component. It currently performs.Lp.Bl -enum -offset indent -compact.ItIP defragmentation.ItTCP stream reassembly.ItTCP port scan detection.El.Lp.Nmperforms TCP/IP reassembly in exactly the same way as Linux2.0.36 kernels, and correctly handles all of the attacks implementedin.Xr fragrouter 8(plus many other attacks as well)..Sh ROUTINES.Fn nids_initinitializes the application for sniffing, based on the values set in theglobal variable.Va nids_params ,declared as follows:.Bd -literalstruct nids_prm {	int	n_tcp_streams;	int	n_hosts;	char	*device;	int	sk_buff_size;	int	dev_addon;	void	(*syslog)(int type, int err, struct ip *iph, void *data);	int	syslog_level;	int	scan_num_hosts;	int	scan_num_ports;	int	scan_delay;	void	(*no_mem)(void);	int	(*ip_filter)(struct ip *iph);	char	*pcap_filter;} nids_params;.Ed.PpThe members of this structure are:.Bl -tag -width scan_num_hosts.It Fa n_tcp_streamsSize of the hash table used for storing TCP connection information (a maximum of 3/4 *.Fa n_tcp_streamsTCP connections will be followed simultaneously). Default value: 1024.It Fa n_hostsSize of the hash table used for storing IP defragmentationinformation. Default value: 256.It Fa deviceInterface to monitor. Default value:.Dv NULL(in which case an appropriate device is determined automatically). If  thisvariable is assigned value .Nm all, libnids will attempt to capture packets on all interfaces (which works on Linux only).It Fa sk_buff_sizeSize of .Fa struct sk_buff(used for queuing packets), which should be set to match the value onthe hosts being monitored. Default value: 168.It Fa dev_addonNumber of bytes in.Fa struct sk_buffreserved for link-layer information. Default value: -1 (in which casean appropriate offset if determined automatically based on link-layertype).It Fa syslogSyslog callback function, used to report unusual conditions, such asport scan attempts, invalid TCP header flags, etc. Default value:.Fa nids_syslog (which logs messages via.Xr syslog 3without regard for message rate per second or free disk space).It Fa syslog_levelLog level used by.Fa nids_syslogfor reporting events via.Xr syslog 3 .Default value:.Dv LOG_ALERT.It Fa scan_num_hostsSize of hash table used for storing portscan information (the maximumnumber portscans that will be detected simultaneously). If set to 0,portscan detection will be disabled. Default value: 256.It Fa scan_num_portsMinimum number of ports that must be scanned from the same sourcehost before it is identifed as a portscan. Default value: 10.It Fa scan_delayMaximum delay (in milliseconds) between connections to differentports for them to be identified as part of a portscan. Default value:3000.It Fa no_memOut-of-memory callback function, used to terminate the calling processgracefully..It Fa ip_filterIP filtering callback function, used to selectively discardIP packets, inspected after reassembly. If the function returns a non-zero value, the packet is processed;otherwise, it is discarded. Default value:.Fn nids_ip_filter (which always returns 1).It Fa pcap_filter.Xr pcap 3filter string applied to the link-layer (raw, unassembled) packets..Sy Note:filters like ``tcp dst port 23'' will NOT correctly handleappropriately fragmented traffic, e.g. 8-byte IP fragments. Defaultvalue:.Dv NULL.lt Fa promiscIf non-zero, libnids will set the interface(s) it listens on to promiscuous mode. Default value: 1.It Fa one_loop_lessdisabled by defaultl see comments in API.html file.El.PpReturns 1 on success, 0 on failure (in which case.Va nids_errbufcontains an appropriate error message)..Pp.Fn nids_register_ip_fragregisters a user-defined callback function to process all incoming IPpackets (including IP fragments, packets with invalid checksums, etc.)..Pp.Fn nids_register_ipregisters a user-defined callback function to process IP packetsvalidated and reassembled by.Nm libnids ..Pp.Fn nids_register_udpregisters a user-defined callback function to process UDP packetsvalidated and reassembled by.Nm libnids ..Pp.Fn nids_register_tcpregisters a user-defined callback function to process TCP streamsvalidated and reassembled by.Nm libnids .The .Va tcp_streamstructure is defined as follows:.Bd -literalstruct tcp_stream {	struct tuple4 {		u_short source;		u_short	dest;		u_int	saddr;		u_int	daddr;	} addr;	char			nids_state;	struct half_stream {		char	state;		char	collect;		char	collect_urg;		char	*data;		u_char	urgdata;		int	count;		int	offset;		int	count_new;		char	count_new_urg;		...	} client;	struct half_stream	server;	...};.Ed.PpThe members of the.Va tuple4structure identify a unique TCP connection:.Bl -tag -width source_,_dest.It Fa source , destClient and server port numbers.It Fa saddr , daddrClient and server IP addresses.El.PpThe members of the.Va half_streamstructure describe each half of a TCP connection (client and server):.Bl -tag -width count_new_urg.It Fa stateSocket state (e.g..Dv TCP_ESTABLISHED)..It Fa collectA boolean which specifies whether to collect data for this half of theconnection in the.Va databuffer..It Fa collect_urgA boolean which specifies whether to collect urgent data pointed to bythe TCP urgent pointer for this half of the connection in the.Va urgdatabuffer..It Fa dataBuffer for normal data..It Fa urgdataOne-byte buffer for urgent data..It Fa countThe number of bytes appended to.Va datasince the creation of the connection..It Fa offsetThe current offset from the first byte stored in the.Va databuffer, identifying the start of newly received data..It Fa count_newThe number of bytes appended to.Va datasince the last invocation of the TCP callback function (if 0, no newdata arrived)..It Fa count_new_urgThe number of bytes appended to.Va urgdatasince the last invocation of the TCP callback function (if 0, no newurgent data arrived)..El.PpThe.Va nids_statefield provides information about the state of the TCP connection, tobe used by the TCP callback function:.Bl -tag -width NIDS_TIMEOUT.It Dv NIDS_JUST_ESTConnection just established. Connection parameters in the.Va addrstructure are available for inspection. If the connection isinteresting, the TCP callback function may specify which data itwishes to receive in the future by setting non-zero values for the.Va collector.Va collect_urgvariables in the appropriate .Va clientor.Va server half_streamstructure members..It Dv NIDS_DATANew data has arrived on a connection. The.Va half_streamstructures contain buffers of data..It Dv NIDS_CLOSE , NIDS_RESET , NIDS_TIMEOUTConnection has closed. The TCP callback function should free anyresources it may have allocated for this connection..El.PpThe.Va parampointer may be set to save a pointer to user-definedconnection-specific data to pass to subsequent invocations of the TCPcallback function (ex. the current working directory for an FTPcontrol connection, etc.)..Pp.Fn nids_killtcptears down the specified TCP connection with symmetric.Dv RSTpackets between client and server..Pp.Fn nids_discardmay be called from the TCP callback function to specify the number ofbytes to discard from the beginning of the.Va databuffer (updating the.Va offsetvalue accordingly) after the TCP callback function exists. Otherwise,the new data (totalling .Va count_newbytes) will be discarded by default..Pp.Fn nids_runstarts the packet-driven application, reading packets in an endlessloop, and invoking registered callback functions to handle new data asit arrives. This function does not return..Pp.Fn nids_nextsleeps until a packet arrives, and then processes a single packetbefore returning. This allows the program to perform other tasks evenwhen no packets arrive. Returns 1 on success, 0 on failure (in whichcase.Va nids_errbufcontains an appropriate error message)..Pp.Fn nids_getfdmay be used by an application sleeping in.Xr select 2to snoop for a socket file descriptor present in the read.Dv fd_set .Returns the file descriptor on success, -1 on failure (in which case.Va nids_errbufcontains an appropriate error message)..Sh SEE ALSO.Xr pcap 3 ,.Xr libnet 3 ,.Xr fragrouter 8.Sh AUTHORRafal Wojtczuk <nergal@icm.edu.pl>.PpManpage by Dug Song <dugsong@monkey.org>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -