当前位置: 首页>>代码示例>>Python>>正文


Python pcapy.open_live方法代码示例

本文整理汇总了Python中pcapy.open_live方法的典型用法代码示例。如果您正苦于以下问题:Python pcapy.open_live方法的具体用法?Python pcapy.open_live怎么用?Python pcapy.open_live使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pcapy的用法示例。


在下文中一共展示了pcapy.open_live方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getInterface

# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import open_live [as 别名]
def getInterface():
    # Grab a list of interfaces that pcap is able to listen on.
    # The current user will be able to listen from all returned interfaces,
    # using open_live to open them.
    ifs = findalldevs()

    # No interfaces available, abort.
    if 0 == len(ifs):
        print "You don't have enough permissions to open any interface on this system."
        sys.exit(1)

    # Only one interface available, use it.
    elif 1 == len(ifs):
        print 'Only one interface present, defaulting to it.'
        return ifs[0]

    # Ask the user to choose an interface from the list.
    count = 0
    for iface in ifs:
        print '%i - %s' % (count, iface)
        count += 1
    idx = int(raw_input('Please select an interface: '))

    return ifs[idx] 
开发者ID:knightmare2600,项目名称:d4rkc0de,代码行数:26,代码来源:sniff.py

示例2: main

# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import open_live [as 别名]
def main(filter):
    dev = getInterface()

    # Open interface for catpuring.
    p = open_live(dev, 1500, 0, 100)

    # Set the BPF filter. See tcpdump(3).
    p.setfilter(filter)

    print "Listening on %s: net=%s, mask=%s, linktype=%d" % (dev, p.getnet(), p.getmask(), p.datalink())

    # Start sniffing thread and finish main thread.
    DecoderThread(p).start()

# Process command-line arguments. Take everything as a BPF filter to pass
# onto pcap. Default to the empty filter (match all). 
开发者ID:knightmare2600,项目名称:d4rkc0de,代码行数:18,代码来源:sniff.py

示例3: getInterface

# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import open_live [as 别名]
def getInterface():
    # Grab a list of interfaces that pcap is able to listen on.
    # The current user will be able to listen from all returned interfaces,
    # using open_live to open them.
    ifs = findalldevs()

    # No interfaces available, abort.
    if 0 == len(ifs):
        print("You don't have enough permissions to open any interface on this system.")
        sys.exit(1)

    # Only one interface available, use it.
    elif 1 == len(ifs):
        print('Only one interface present, defaulting to it.')
        return ifs[0]

    # Ask the user to choose an interface from the list.
    count = 0
    for iface in ifs:
        print('%i - %s' % (count, iface))
        count += 1
    idx = int(input('Please select an interface: '))

    return ifs[idx] 
开发者ID:Coalfire-Research,项目名称:Slackor,代码行数:26,代码来源:sniff.py

示例4: main

# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import open_live [as 别名]
def main(filter):
    dev = getInterface()

    # Open interface for catpuring.
    p = open_live(dev, 1500, 0, 100)

    # Set the BPF filter. See tcpdump(3).
    p.setfilter(filter)

    print("Listening on %s: net=%s, mask=%s, linktype=%d" % (dev, p.getnet(), p.getmask(), p.datalink()))

    # Start sniffing thread and finish main thread.
    DecoderThread(p).start()

# Process command-line arguments. Take everything as a BPF filter to pass
# onto pcap. Default to the empty filter (match all). 
开发者ID:Coalfire-Research,项目名称:Slackor,代码行数:18,代码来源:sniff.py

示例5: __init__

# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import open_live [as 别名]
def __init__(self, target, ports):
        pcap_dev = lookupdev()
        self.p = open_live(pcap_dev, 600, 0, 3000)
        
        self.__source = self.p.getlocalip()
        self.__target = target
        
        self.p.setfilter("src host %s and dst host %s" % (target, self.__source), 1, 0xFFFFFF00)
        self.p.setmintocopy(10)
        self.decoder = EthDecoder()
        
        self.tests_sent = []
        self.outstanding_count = 0
        self.results = {}
        self.current_id = 12345

        self.__ports = ports 
开发者ID:Coalfire-Research,项目名称:Slackor,代码行数:19,代码来源:os_ident.py

示例6: start

# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import open_live [as 别名]
def start(self):
        self.p = open_live(self.interface, 1600, 0, 100)
##         self.p.setnonblock(1)
        if self.filter:
            self.p.setfilter(self.filter)

        # Query the type of the link and instantiate a decoder accordingly.
        datalink = self.p.datalink()
        if pcapy.DLT_EN10MB == datalink:
            self.decoder = EthDecoder()
        elif pcapy.DLT_LINUX_SLL == datalink:
            self.decoder = LinuxSLLDecoder()
        else:
            raise Exception("Datalink type not supported: " % datalink)

        self.tk.after(POLL_PERIOD, self.poll)
        self.tk.after(REFRESH_PERIOD, self.timerDraw);
        self.tk.bind('q',self.quit)
        self.tk.mainloop() 
开发者ID:tholum,项目名称:PiBunny,代码行数:21,代码来源:tracer.py

示例7: __init__

# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import open_live [as 别名]
def __init__(self, *args, **kargs):
                    self.pcap = pcap.open_live(*args, **kargs) 
开发者ID:medbenali,项目名称:CyberScan,代码行数:4,代码来源:pcapdnet.py

示例8: init

# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import open_live [as 别名]
def init(self):
        try:
            self.device = pcapy.open_live(pcapy.lookupdev(), 65535, 0, 0)
            self.device.setfilter("tcp port 80")
        except Exception as e:
            print(e)
            return False
            
        return True 
开发者ID:turingsec,项目名称:marsnake,代码行数:11,代码来源:tcp_traffic.py

示例9: init

# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import open_live [as 别名]
def init(self):
        try:
            self.device = pcapy.open_live(pcapy.lookupdev(), 65535, 0, 0)
            self.device.setfilter("udp port 53")
        except Exception as e:
            print(e)
            return False
            
        return True 
开发者ID:turingsec,项目名称:marsnake,代码行数:11,代码来源:udp_traffic.py

示例10: __init__

# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import open_live [as 别名]
def __init__(self, *args, **kargs):
                    self.pcap = pcap.pcapObject()
                    self.pcap.open_live(*args, **kargs) 
开发者ID:theralfbrown,项目名称:smod-1,代码行数:5,代码来源:pcapdnet.py

示例11: initPcap

# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import open_live [as 别名]
def initPcap(self):
       self.pcap = pcapy.open_live(self.interface, 65535, 1, 0)
       try:       self.pcap.setfilter("host %s or ether host %s" % (self.ipAddress, self.macAddress))
       except:    self.pcap.setfilter("host %s or ether host %s" % (self.ipAddress, self.macAddress), 1, 0xFFFFFF00) 
开发者ID:Coalfire-Research,项目名称:Slackor,代码行数:6,代码来源:nmapAnswerMachine.py

示例12: __init__

# 需要导入模块: import pcapy [as 别名]
# 或者: from pcapy import open_live [as 别名]
def __init__(self, iface, filename='test.pcap', pcFilter=None, num_packets=3000):
        # list all the network devices
        # print pcapy.findalldevs()

        max_bytes = 1024
        promiscuous = False
        read_timeout = 100  # in milliseconds
        pc = pcapy.open_live(iface, max_bytes, promiscuous, read_timeout)
        if pcFilter: pc.setfilter(pcFilter)
        self.dumper = pc.dump_open(filename)
        pc.loop(num_packets, self.recv_pkts)  # capture packets

    # callback for received packets 
开发者ID:AllGloryToTheHypnotoad,项目名称:netscan2,代码行数:15,代码来源:lib.py


注:本文中的pcapy.open_live方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。