當前位置: 首頁>>代碼示例>>Python>>正文


Python all.sendp方法代碼示例

本文整理匯總了Python中scapy.all.sendp方法的典型用法代碼示例。如果您正苦於以下問題:Python all.sendp方法的具體用法?Python all.sendp怎麽用?Python all.sendp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在scapy.all的用法示例。


在下文中一共展示了all.sendp方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run

# 需要導入模塊: from scapy import all [as 別名]
# 或者: from scapy.all import sendp [as 別名]
def run(self):
        """Starts the thread, which is sniffing incoming ARP packets and sends out packets to spoof
        all clients on the network and the gateway. This packets are sent every __SLEEP seconds.

        Note:
            First, a ARP request packet is generated for every possible client of the network.
            This packets are directed at the gateway and update existing entries of the gateway's ARP table.
            So the gateway is not flooded with entries for non-existing clients.

            Second, a GARP broadcast request packet is generated to spoof every client on the network.
        """
        # start sniffing thread
        self.sniffthread.start()

        # generates a packet for each possible client of the network
        # these packets update existing entries in the arp table of the gateway
        # packets = [Ether(dst=self.gate_mac) / ARP(op=1, psrc=str(x), pdst=str(x)) for x in self.ip_range]

        # gratuitous arp to clients
        # updates the gateway entry of the clients arp table
        packets = [Ether(dst=ETHER_BROADCAST) / ARP(op=1, psrc=self.ipv4.gateway, pdst=self.ipv4.gateway, hwdst=ETHER_BROADCAST)]
        while True:
            sendp(packets)
            time.sleep(self.__SLEEP) 
開發者ID:usableprivacy,項目名稱:upribox,代碼行數:26,代碼來源:daemon_app.py

示例2: _arp_scan_thread_helper

# 需要導入模塊: from scapy import all [as 別名]
# 或者: from scapy.all import sendp [as 別名]
def _arp_scan_thread_helper(self):

        fast_scan_start_ts = None

        while True:

            if not self._host_state.is_inspecting():
                time.sleep(1)
                continue

            for ip in utils.get_network_ip_range():

                sleep_time = SLOW_SCAN_SLEEP_TIME

                # Whether we should scan fast or slow
                with self._host_state.lock:
                    fast_arp_scan = self._host_state.fast_arp_scan

                # If fast scan, we do it for at most 5 mins
                if fast_arp_scan:
                    sleep_time = FAST_SCAN_SLEEP_TIME
                    if fast_scan_start_ts is None:
                        fast_scan_start_ts = time.time()
                    else:
                        if time.time() - fast_scan_start_ts > 300:
                            fast_scan_start_ts = None
                            sleep_time = SLOW_SCAN_SLEEP_TIME
                            with self._host_state.lock:
                                self._host_state.fast_arp_scan = False

                time.sleep(sleep_time)

                arp_pkt = sc.Ether(dst="ff:ff:ff:ff:ff:ff") / \
                    sc.ARP(pdst=ip, hwdst="ff:ff:ff:ff:ff:ff")
                sc.sendp(arp_pkt, verbose=0)

                with self._lock:
                    if not self._active:
                        return 
開發者ID:noise-lab,項目名稱:iot-inspector-client,代碼行數:41,代碼來源:arp_scan.py

示例3: _return_to_normal

# 需要導入模塊: from scapy import all [as 別名]
# 或者: from scapy.all import sendp [as 別名]
def _return_to_normal(self):
        """This method is called when the daemon is stopping.
        First, sends a GARP broadcast request to all clients to tell them the real gateway.
        Then an ARP request is sent to every client, so that they answer the real gateway and update its ARP cache.
        """
        # clients gratutious arp
        sendp(
            Ether(dst=ETHER_BROADCAST) / ARP(op=1, psrc=self.ipv4.gateway, pdst=self.ipv4.gateway, hwdst=ETHER_BROADCAST,
                                             hwsrc=self.ipv4.gate_mac))
        # to clients so that they send and arp reply to the gateway
        # sendp(Ether(dst=ETHER_BROADCAST) / ARP(op=1, psrc=self.gateway, pdst=str(self.network), hwsrc=self.gate_mac)) 
開發者ID:usableprivacy,項目名稱:upribox,代碼行數:13,代碼來源:daemon_app.py

示例4: process

# 需要導入模塊: from scapy import all [as 別名]
# 或者: from scapy.all import sendp [as 別名]
def process(self, pkt):
            if all(layer in pkt for layer in (scapy.Ether, scapy.ARP)):
                if pkt[scapy.Ether].src != str(net.ifhwaddr(self.iface)) and pkt[scapy.ARP].op == 1: # who-has
                    resp = scapy.Ether()/scapy.ARP(hwsrc=str(net.ifhwaddr('tap0')), hwdst=pkt.hwsrc, psrc=pkt.pdst, pdst=pkt.psrc, op="is-at")
                    scapy.sendp(resp, iface='tap0')

                    if pkt.pdst not in self.ips:
                        self.ips.add(pkt.pdst)
                        cidr = '{!s}/{:d}'.format(pkt.pdst, 28)
                        logger.info("Attaching new IP address {:s} to {:s}".format(cidr, self.iface))
                        subprocess.run(['ip', 'addr', 'add', cidr, 'dev', self.iface]) 
開發者ID:nategraf,項目名稱:Naumachia,代碼行數:13,代碼來源:scraps.py

示例5: send

# 需要導入模塊: from scapy import all [as 別名]
# 或者: from scapy.all import sendp [as 別名]
def send(data):
    data = base64.b64encode(data)
    app_exfiltrate.log_message(
        'info', "[icmp] Sending {} bytes with ICMP packet".format(len(data)))
    scapy.sendp(scapy.Ether() /
                scapy.IP(dst=config['target']) / scapy.ICMP() / data, verbose=0) 
開發者ID:sensepost,項目名稱:DET,代碼行數:8,代碼來源:icmp.py

示例6: send

# 需要導入模塊: from scapy import all [as 別名]
# 或者: from scapy.all import sendp [as 別名]
def send(self):
        return sendp(self.data, iface=MONITOR_INTERFACE, verbose=False)


# 802.11 frame class with support for adding MSDUs to a single MPDU 
開發者ID:rpp0,項目名稱:aggr-inject,代碼行數:7,代碼來源:packets.py

示例7: rx_from_emulator

# 需要導入模塊: from scapy import all [as 別名]
# 或者: from scapy.all import sendp [as 別名]
def rx_from_emulator(emu_rx_port, interface):
    ''' 
        Receives 0mq messages from emu_rx_port    
        args:
            emu_rx_port:  The port number on which to listen for messages from
                          the emulated software
    '''
    global __run_server
    #global __host_socket
    topic = "Peripheral.EthernetModel.tx_frame"
    context = zmq.Context()
    mq_socket = context.socket(zmq.SUB)
    mq_socket.connect("tcp://localhost:%s" % emu_rx_port)
    mq_socket.setsockopt(zmq.SUBSCRIBE, topic)

    while (__run_server):
        msg = mq_socket.recv_string()
        # print "Got from emulator:", msg
        topic, data = decode_zmq_msg(msg)
        frame = data['frame']
        # if len(frame) < 64:
        #    frame = frame +('\x00' * (64-len(frame)))
        p = scapy.Raw(frame)
        scapy.sendp(p, iface=interface)
        # __host_socket.send(frame)
        print("Sending Frame (%i) on eth: %s" %
              (len(frame), binascii.hexlify(frame))) 
開發者ID:embedded-sec,項目名稱:halucinator,代碼行數:29,代碼來源:host_ethernet.py

示例8: send_msg

# 需要導入模塊: from scapy import all [as 別名]
# 或者: from scapy.all import sendp [as 別名]
def send_msg(self, topic, msg):
        frame = msg['frame']
        p = scapy.Raw(frame)
        scapy.sendp(p, iface=self.interface) 
開發者ID:embedded-sec,項目名稱:halucinator,代碼行數:6,代碼來源:ethernet_virt_hub.py


注:本文中的scapy.all.sendp方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。