libnids study

首先是main()函数,格式是:

int main ()

{

if (!nids_init ())

{

fprintf(stderr,"%s/n",nids_errbuf);

exit(1);

}

nids_register_tcp (tcp_callback);//registration of callback functions

nids_run ();

// not reached in normal situation

return 0;

}

nids_init()初始话抓包的应用程序,基于全局变量nids_params,格式如下:

struct nids_prm {
    int    n_tcp_streams;//
Size of the hash table used for storing TCP connection information, defult 1024
    int    n_hosts;          // Size of the hash table used for storing IP defragmentation information. Default value: 256
    char    *device;/* Interface to monitor. Default value: NULL (in which case an appropriate device is determined automatically). If this variable is assigned value all , libnids will attempt to capture packets on all interfaces (which works on Linux only) */
    char    *filename;
//call pcap_open_offline with this variable as the argument
    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;
    int    promisc;
    int    one_loop_less;
    int    pcap_timeout;
    int    multiproc;
    int    queue_limit;
    int    tcp_workarounds;
    pcap_t    *pcap_desc;
} nids_params;


 


sk_buff_size
Size of struct sk_buff (used for queuing packets), which should be set to match the value on the hosts being monitored. Default value: 168
dev_addon
Number of bytes in struct sk_buff reserved for link-layer information. Default value: -1 (in which case an appropriate offset if determined automatically based on link-layer type)
syslog
Syslog callback function, used to report unusual conditions, such as port scan attempts, invalid TCP header flags, etc. Default value: nids_syslog (which logs messages via syslog (3) without regard for message rate per second or free disk space)
syslog_level
Log level used by nids_syslog for reporting events via syslog (3) . Default value: LOG_ALERT
scan_num_hosts
Size of hash table used for storing portscan information (the maximum number portscans that will be detected simultaneously). If set to 0, portscan detection will be disabled. Default value: 256
scan_num_ports
Minimum number of ports that must be scanned from the same source host before it is identifed as a portscan. Default value: 10
scan_delay
Maximum delay (in milliseconds) between connections to different ports for them to be identified as part of a portscan. Default value: 3000
no_mem
Out-of-memory callback function, used to terminate the calling process gracefully.
ip_filter
IP filtering callback function, used to selectively discard IP packets, inspected after reassembly. If the function returns a non-zero value, the packet is processed; otherwise, it is discarded. Default value: nids_ip_filter (which always returns 1)
pcap_filter
pcap (3) filter string applied to the link-layer (raw, unassembled) packets. Note : filters like ''tcp dst port 23'' will NOT correctly handle appropriately fragmented traffic, e.g. 8-byte IP fragments; one should add "or (ip[6:2] & 0x1fff != 0)" at the end of the filter to process reassembled packets. Default value: NULL
promisc
If non-zero, libnids will set the interface (s) it listens on to promiscuous mode. Default value: 1
one_loop_less
Disabled by default; see comments in API.html file
pcap_timeout
Sets the pcap read timeout, which may or may not be supported by your platform. Default value: 1024.
multiproc
If nonzero, creates a separate thread for packets processing. See API.html. Default value: 0.
queue_limit
If multiproc is nonzero, this is the maximum number of packets queued in the thread which reads packets from libpcap. Default value: 20000
tcp_workarounds
Enables extra checks for faulty implementations of TCP such as the ones which allow connections to be closed despite the fact that there should be retransmissions for lost packets first (as stated by RFC 793, section 3.5). If non-zero, libnids will set the NIDS_TIMED_OUT state for savagely closed connections. Default value: 0
pcap_desc
It this variable is set, libnids will call neither pcap_open_live nor pcap_open_offline, but will use a pre-opened PCAP descriptor; use this with nids_pcap_handler() in order to interactively feed packets to libnids. Default value: NULL

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: DPDK(Data Plane Development Kit)是一款开源的快速数据平面开发工具集,主要用于构建高性能的数据包处理应用程序。它提供了一系列用于处理网络数据包的库和驱动程序,使开发者能够在普通服务器上实现类似网络专用设备的性能。DPDK已经被广泛应用于包括流量分析、虚拟网络功能和网络安全等领域。 而Libnids是一个网络实时入侵检测系统(NIDS)中的一个库。它被设计用于对网络流量进行分析和监控,以便及时检测和阻止入侵行为。Libnids可以从网络中捕获数据包,并解析和处理这些数据包,以进行入侵检测和分析。 DPDK和Libnids之间并没有直接的关联,它们属于不同的领域和用途。然而,由于DPDK提供了高性能的数据包处理能力,可以与Libnids等网络安全工具结合使用,用于实时入侵检测系统的构建。通过将DPDK和Libnids相结合,可以实现更高效的网络流量分析和入侵检测,提升网络的安全性和性能。 总而言之,DPDK是一款用于构建高性能数据包处理应用程序的工具集,而Libnids是一个网络实时入侵检测系统中的库。它们可以相互结合使用,实现更高效的网络流量分析和入侵检测。 ### 回答2: DPDK是数据平面开发工具包(Data Plane Development Kit)的缩写,而libnids是DPDK中的一个库。 DPDK是一个开源的软件库,旨在加速数据包处理的速度。它提供了一组用于开发高性能数据平面应用程序的API和工具。使用DPDK,开发人员可以利用硬件加速技术(如网卡的SR-IOV、GPU等)来提高数据平面应用的性能。DPDK还提供了一套完整的网络协议栈,能够高效地处理各种类型的数据包。 而libnids(Network Intrusion Detection System)是DPDK中的一个库,用于在网络中检测并分析潜在的入侵行为。它能够监视网络流量,并利用规则引擎来检测和报告潜在的攻击和异常行为。libnids可以分析各种类型的网络数据包,包括TCP、UDP、ICMP等。它还提供了一些内置的规则库,用于检测已知的攻击模式,同时也支持用户自定义的规则。 使用DPDK的libnids库,开发人员可以方便地构建高性能的网络入侵检测系统。通过与DPDK的其他功能和API结合使用,libnids可以实现对高速网络流量的实时监测和分析,提供快速准确的入侵检测能力。同时,由于DPDK的性能优势,libnids能够处理大规模高负载的网络环境,将安全性和性能发挥到极致。 总而言之,DPDK的libnids库是一个在高性能数据面开发环境下实现网络入侵检测的强大工具。它通过利用DPDK的加速能力和灵活的规则引擎,帮助开发人员构建高效、快速、可定制的网络安全系统。 ### 回答3: DPDK(Data Plane Development Kit)是一个开源的数据平面开发工具包,用于快速、高效地开发高性能的数据平面应用程序。它提供了一套功能丰富的库和驱动程序,专门用于数据包处理和网络协议栈加速。 其中,libnids是DPDK中的一个重要库,全称为"Libraries for Network Intrusion Detection System"。它是一个专门用于网络入侵检测系统的库,提供了一些功能和接口,可以用于实现高性能、实时的网络入侵检测。 libnids库主要提供了以下几个功能: 1. 网络流量重组:libnids能够将经过网络的流量进行重组,将分割的数据包片段重新组合成完整的网络数据包,方便进一步分析和处理。这在网络入侵检测中非常重要,因为入侵行为通常是由多个数据包组成的。 2. 协议解析:libnids支持解析多种网络协议,例如TCP、UDP等。它能够将解析后的协议信息提取出来,为后续的入侵检测算法提供基础数据。 3. 入侵检测模块:libnids提供了一些入侵检测算法,可以通过这些算法来对网络流量进行实时的入侵检测。这些算法基于已知的入侵行为规则或者机器学习等技术,能够高效地检测到潜在的入侵行为。 4. API接口:libnids提供了一套易用的API接口,使得开发者能够方便地在他们自己的应用程序中使用libnids库的功能。这些接口包括初始化、启动、停止等操作,以及一些回调函数,用于处理检测到的入侵行为等。 总的来说,dpdk libnids是DPDK中的一个重要库,主要用于实现高性能的网络入侵检测系统。它提供了网络流量重组、协议解析、入侵检测模块和易用的API接口等功能,可以帮助开发者快速、高效地开发出高性能的网络入侵检测应用程序。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值