为什么代码中我们只想要"返回r [Ether] .src"时,循环语句是"for s,r in responses"而不是"for r in responses"?

2024-05-12 11:23:33 发布

您现在位置:Python中文网/ 问答频道 /正文

还有,为什么我们有“responses,unanswered=”而不是“responses=”in“responses,unanswered=srp(以太(dst=“ff:ff:ff:ff:ff”)/ARP(pdst=ip\u地址),timeout=2,retry=10)”响应和未响应都是什么

    from scapy.all import *
    import sys
    import threading

    interface = "eth0"
    target_ip = "172.16.155.137"
    gateway_ip = "172.16.155.2"
    packet_count = 100000
    poisoning = True

    def restore_target(gateway_ip, gateway_mac, target_ip, target_mac):

        print "[*] Restoring target..."
        send(ARP(op=2, psrc=gateway_ip, pdst=target_ip, hwdst="ff:ff:ff:ff:ff:ff", hwsrc=gateway_mac), count=5)
        send(ARP(op=2, psrc=target_ip, pdst=gateway_ip, hwdst="ff:ff:ff:ff:ff:ff",
             hwsrc=target_mac), count=5)

    def get_mac(ip_address):
        responses,unanswered = srp(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(pdst=ip_address),timeout=2,retry=10)

        # return the MAC address from a response
        for s, r in responses:
            return r[Ether].src

       return None


Tags: inimportiptargetreturnaddressmaccount