我正在尝试使用 pynids 库解析多个 pcap 文件,但只能解析第一个文件。我看到nids_unregister_tcp
libnids中有一个函数,有帮助吗?不过,我在 pynids 中找不到该功能。
import nids
def handle_tcp_stream(tcp):
print "In handle_tcp_stream"
def extract(pcap_file):
nids.param("tcp_workarounds", 1)
nids.param("pcap_filter", "tcp") # bpf restrict to TCP only, note
nids.param("scan_num_hosts", 0) # disable portscan detection
nids.chksum_ctl([('0.0.0.0/0', False)]) # disable checksumming
nids.param("filename", pcap_file)
nids.init()
nids.register_tcp(handle_tcp_stream)
try:
nids.run()
except Exception, e:
print "Exception ", pcap_file + " ", e
def main():
extract("a.pcap")
print "Done"
extract("a.pcap")
if __name__ == "__main__":
main()
这是输出:
In handle_tcp_stream
In handle_tcp_stream
In handle_tcp_stream
In handle_tcp_stream
Done