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


Python sendrecv.sniff方法代码示例

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


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

示例1: run

# 需要导入模块: from scapy import sendrecv [as 别名]
# 或者: from scapy.sendrecv import sniff [as 别名]
def run(self):
        self._thread_started.set()
        try:
            def prn(msg):
                if not self.exiting:
                    self.callback(msg)

            while 1:
                try:
                    sniff(store=False, timeout=1, count=1,
                          stop_filter=lambda x: self.exiting,
                          prn=prn, opened_socket=self.socket)
                except ValueError as ex:
                    if not self.exiting:
                        raise ex
                if self.exiting:
                    return
        except Exception as ex:
            self.exception = ex 
开发者ID:secdev,项目名称:scapy,代码行数:21,代码来源:isotp.py

示例2: sniff_answer

# 需要导入模块: from scapy import sendrecv [as 别名]
# 或者: from scapy.sendrecv import sniff [as 别名]
def sniff_answer(self):
        self.sniff_finished.clear()
        response = sniff(iface=self.nic, filter="ether dst host %s" % self.sniff_mac_address, timeout=self.timeout)
        self.result = []
        for i in range(len(response)):
            pkt = response[i]
            if pkt[Ether].dst == self.sniff_mac_address:
                Device_Name = ''
                Device_Type = ''
                MAC_Address = pkt[Ether].src
                IP_Address = ''
                Netmask = ''
                GateWay = ''
                if pkt.haslayer(PNDCPIdentDeviceNameOfStationResponseBlock):
                    Device_Name = pkt[PNDCPIdentDeviceNameOfStationResponseBlock].NameOfStation
                if pkt.haslayer(PNDCPIdentDeviceManufacturerSpecificResponseBlock):
                    Device_Type = pkt[PNDCPIdentDeviceManufacturerSpecificResponseBlock].DeviceVendorValue
                if pkt.haslayer(PNDCPIdentIPParameterResponseBlock):
                    IP_Address = pkt[PNDCPIdentIPParameterResponseBlock].IPaddress
                    Netmask = pkt[PNDCPIdentIPParameterResponseBlock].Subnetmask
                    GateWay = pkt[PNDCPIdentIPParameterResponseBlock].StandardGateway
                self.result.append([Device_Name, Device_Type, MAC_Address, IP_Address, Netmask, GateWay])
        self.sniff_finished.set() 
开发者ID:dark-lbp,项目名称:isf,代码行数:25,代码来源:profinet_set_ip.py

示例3: sniff

# 需要导入模块: from scapy import sendrecv [as 别名]
# 或者: from scapy.sendrecv import sniff [as 别名]
def sniff(self, q):
        """Target function for Queue (multithreading)"""
        sniff(iface = self.m, prn = lambda x: q.put(x), store = 0) 
开发者ID:ICSec,项目名称:airpwn-ng,代码行数:5,代码来源:sniffer.py

示例4: __call__

# 需要导入模块: from scapy import sendrecv [as 别名]
# 或者: from scapy.sendrecv import sniff [as 别名]
def __call__(self, *args, **kargs):
        optsend, optsniff = self.parse_all_options(2, kargs)
        self.optsend = self.defoptsend.copy()
        self.optsend.update(optsend)
        self.optsniff = self.defoptsniff.copy()
        self.optsniff.update(optsniff)

        try:
            self.sniff()
        except KeyboardInterrupt:
            print("Interrupted by user") 
开发者ID:secdev,项目名称:scapy,代码行数:13,代码来源:ansmachine.py

示例5: sniff

# 需要导入模块: from scapy import sendrecv [as 别名]
# 或者: from scapy.sendrecv import sniff [as 别名]
def sniff(self):
        sniff(**self.optsniff) 
开发者ID:secdev,项目名称:scapy,代码行数:4,代码来源:ansmachine.py

示例6: sniff

# 需要导入模块: from scapy import sendrecv [as 别名]
# 或者: from scapy.sendrecv import sniff [as 别名]
def sniff(self, *args, **kargs):
        from scapy import sendrecv
        return sendrecv.sniff(opened_socket=self, *args, **kargs) 
开发者ID:secdev,项目名称:scapy,代码行数:5,代码来源:supersocket.py

示例7: sniff

# 需要导入模块: from scapy import sendrecv [as 别名]
# 或者: from scapy.sendrecv import sniff [as 别名]
def sniff(self):
        sniff(iface=self.iffrom, **self.optsniff) 
开发者ID:secdev,项目名称:scapy,代码行数:4,代码来源:dot11.py

示例8: scan

# 需要导入模块: from scapy import sendrecv [as 别名]
# 或者: from scapy.sendrecv import sniff [as 别名]
def scan(sock, scan_range=range(0x800), noise_ids=None, sniff_time=0.1,
         extended_can_id=False, verbose=False):
    """Scan and return dictionary of detections

    Args:
            sock: socket for can interface
            scan_range: hexadecimal range of IDs to scan.
                        Default is 0x0 - 0x7ff
            noise_ids: list of packet IDs which will not be considered when
                       received during scan
            sniff_time: time the scan waits for isotp flow control responses
                        after sending a first frame
            extended_can_id: Send extended can frames
            verbose: displays information during scan

    ISOTP-Scan - NO extended IDs
    found_packets = Dictionary with Send-to-ID as
    key and a tuple (received packet, Recv_ID)
    """
    return_values = dict()
    for value in scan_range:
        sock.sniff(prn=lambda pkt: get_isotp_fc(value, return_values,
                                                noise_ids, False, pkt,
                                                verbose),
                   timeout=sniff_time,
                   started_callback=lambda: sock.send(
                       get_isotp_packet(value, False, extended_can_id)))

    cleaned_ret_val = dict()

    for tested_id in return_values.keys():
        for value in range(max(0, tested_id - 2), tested_id + 2, 1):
            sock.sniff(prn=lambda pkt: get_isotp_fc(value, cleaned_ret_val,
                                                    noise_ids, False, pkt,
                                                    verbose),
                       timeout=sniff_time * 10,
                       started_callback=lambda: sock.send(
                       get_isotp_packet(value, False, extended_can_id)))

    return cleaned_ret_val 
开发者ID:secdev,项目名称:scapy,代码行数:42,代码来源:isotp.py

示例9: __init__

# 需要导入模块: from scapy import sendrecv [as 别名]
# 或者: from scapy.sendrecv import sniff [as 别名]
def __init__(self,
      iface="eth0",
      writes_only=False,
      debug=False):
    """
      if client_port is 0 we sniff all clients
      if zookeeper_port is changed later on you must call update_filter()
    """
    self.iface = iface
    self.writes_only = writes_only
    self.debug = debug
    self.client_port = 0
    self.track_replies = False
    self.max_queued_requests = 10000
    self.zookeeper_port = DEFAULT_PORT
    self.excluded_opcodes = set()
    self.is_loopback = iface in ["lo", "lo0"]
    self.read_timeout_ms = 0
    self.dump_bad_packet = False
    self.sampling = 1.0  # percentage of packets to inspect [0, 1]

    # These are set after initialization, and require `update_filter` to be called
    self.included_ips = []
    self.excluded_ips = []

    self.update_filter()
    self.exclude_pings() 
开发者ID:twitter,项目名称:zktraffic,代码行数:29,代码来源:sniffer.py

示例10: run

# 需要导入模块: from scapy import sendrecv [as 别名]
# 或者: from scapy.sendrecv import sniff [as 别名]
def run(self):
    try:
      log.info("Setting filter: %s", self.config.filter)
      if self.config.iface == "any":  # pragma: no cover
        sniff(
          filter=self.config.filter,
          store=0,
          prn=self.handle_packet,
          stop_filter=self.wants_stop
        )
      else:
        sniff(
          filter=self.config.filter,
          store=0,
          prn=self.handle_packet,
          iface=self.config.iface,
          stop_filter=self.wants_stop
        )
    except socket.error as ex:
      if self._error_to_stderr:
        sys.stderr.write("Error: %s, device: %s\n" % (ex, self.config.iface))
      else:
        log.error("Error: %s, device: %s", ex, self.config.iface)
    finally:
      log.info("The sniff loop exited")
      os.kill(os.getpid(), signal.SIGINT) 
开发者ID:twitter,项目名称:zktraffic,代码行数:28,代码来源:sniffer.py

示例11: capture

# 需要导入模块: from scapy import sendrecv [as 别名]
# 或者: from scapy.sendrecv import sniff [as 别名]
def capture(userfilter="", pcapname=".tmp.pcap", func=None, count=0, time=None):
    """This function is a wrapper function above the sniff scapy function. The
    result is a list of templates. The specification on filtering options can
    be found at: https://goo.gl/kVAmHQ

    Parameters
    ----------
    userfilter : :obj:`str`
        Filters to capture packets.
    pcapname : :obj:`str`
        Path where the pcap will be written.
    func : :obj:`function`
        Function to be called when a packet arrive, the packet will be passed
        as parameter.
    count : int
        Number of packets to capture.
    time : int
        Stop sniffing after a given time.

    Returns
    -------
    :obj:`TList`
        List of templates

    """
    if func:
        plist = sniff(filter=userfilter, prn=func, count=count,
                      timeout=time)
    else:
        plist = sniff(filter=userfilter, count=count, timeout=time)
    # Save the list of packages to disk for later readin with pyshark
    if len(plist) > 0:
        wrpcap(join(POLYM_PATH, pcapname), plist)
        tgen = TGenerator(join(POLYM_PATH, pcapname), scapy_pkts=plist)
        # Returns a list of templates
        return TList(tgen, len(plist), namesgen(plist))
    return None 
开发者ID:shramos,项目名称:polymorph,代码行数:39,代码来源:utils.py

示例12: run

# 需要导入模块: from scapy import sendrecv [as 别名]
# 或者: from scapy.sendrecv import sniff [as 别名]
def run(self):
		try:
			pkts = sniff(iface=self.iface, prn=self.ssid_shift)
		except Exception:
			pass 
开发者ID:hash3liZer,项目名称:WiFiBroot,代码行数:7,代码来源:shifter.py

示例13: sniff_answer

# 需要导入模块: from scapy import sendrecv [as 别名]
# 或者: from scapy.sendrecv import sniff [as 别名]
def sniff_answer(self):
        self.sniff_finished.clear()
        response = sniff(iface=self.nic, filter="ether dst host %s" % self.sniff_mac_address, timeout=self.timeout)
        self.result = []
        for i in range(len(response)):
            pkt = response[i]
            if pkt.haslayer(ENIPHeader):
                product_name = ''
                device_type = ''
                vendor = ''
                revision = ''
                serial_number = ''
                ip_address = ''
                if pkt.haslayer(ListIdentityResponse):
                    product_name = pkt[ListIdentityResponse].ProductName
                    device_type = pkt[ListIdentityResponse].DeviceType
                    if device_type in DEVICE_TYPES.keys():
                        device_type = DEVICE_TYPES[device_type]
                    ip_address = pkt[SocketAddress].SinAddress
                    vendor = pkt[ListIdentityResponse].VendorID
                    if vendor in VENDOR_IDS.keys():
                        vendor = VENDOR_IDS[vendor]
                    revision = pkt[ListIdentityResponse].Revision
                    revision = struct.pack("!H", revision)
                    revision = "{0:d}.{1:d}".format(ord(revision[0]), ord(revision[1]))
                    serial_number = pkt[ListIdentityResponse].SerialNumber
                    serial_number = struct.pack("!I", serial_number).encode('hex')
                self.result.append([product_name, device_type, vendor, revision, serial_number, ip_address])
        self.sniff_finished.set() 
开发者ID:dark-lbp,项目名称:isf,代码行数:31,代码来源:enip_scan.py

示例14: discover_local_device

# 需要导入模块: from scapy import sendrecv [as 别名]
# 或者: from scapy.sendrecv import sniff [as 别名]
def discover_local_device(self):
        self.sniff_mac_address = get_if_hwaddr(self.nic)
        p = threading.Thread(target=self.sniff_answer)
        p.setDaemon(True)
        p.start()
        # wait sniff start
        time.sleep(0.2)
        packet = Ether(src=self.sniff_mac_address, dst="ff:ff:ff:ff:ff:ff")/IP(src=get_if_addr(self.nic), dst="255.255.255.255")/UDP(sport=44818, dport=44818)/ENIPHeader(Command=0x0063)
        sendp(packet, iface=self.nic)
        self.sniff_finished.wait(self.timeout + 1) 
开发者ID:dark-lbp,项目名称:isf,代码行数:12,代码来源:enip_scan.py

示例15: sniff

# 需要导入模块: from scapy import sendrecv [as 别名]
# 或者: from scapy.sendrecv import sniff [as 别名]
def sniff(self, *args, **kargs):
        return sendrecv.sniff(opened_socket=self, *args, **kargs) 
开发者ID:entynetproject,项目名称:arissploit,代码行数:4,代码来源:supersocket.py


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