python 设置数据包捕获的监视器接口设置

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 设置数据包捕获的监视器接口设置相关的知识,希望对你有一定的参考价值。

#
# A plugin to setup capture interfaces
# The plugin is off by default. To enable it, add "interfacesetup.enabled=1" to broctl.cfg.
#

import BroControl.plugin

class InterfaceSetupPlugin(BroControl.plugin.Plugin):
    def __init__(self):
        super(InterfaceSetupPlugin, self).__init__(apiversion=1)

    def name(self):
        return "InterfaceSetupPlugin"

    def prefix(self):
        return "interfacesetup"

    def pluginVersion(self):
        return 1

    def init(self):
        if self.getOption("enabled") == "0":
            return False

        return True

    def options(self):
        return [("mtu", "int", "9000", "Interface MTU"),
                ("enabled", "string", "0", "Set to enable plugin")]

    def cmd_start_pre(self, nodes):
        if not nodes:
            return
        
        mtu = self.getOption("mtu")
        self.message("InterfaceSetupPlugin: mtu=%s" % (mtu))

        host_nodes = {}
        for n in nodes:
            if n.interface:
                host_nodes[n.host] = n

        cmds = []
        for n in host_nodes.values():
            cmd = "/sbin/ifconfig %s up mtu %s" % (n.interface, mtu)
            cmds.append((n, cmd))
            cmd = "/sbin/ethtool -K %s gro off lro off rx off tx off gso off" % (n.interface)
            cmds.append((n, cmd))

        self.executeParallel(cmds)

以上是关于python 设置数据包捕获的监视器接口设置的主要内容,如果未能解决你的问题,请参考以下文章

Python手机抓包案例,用Charles捕获春雨医生接口数据

串口数据流抓包监视侦听监控工具捕获PC端软件通讯数据

移动设备httphttps数据包抓取(Fiddler篇)

ubuntu wireshark 无法捕获 dhcp 怎么解决啊?

使用缩放监视器捕获 Python 应用程序

接口工具接口抓包工具之Fiddler