Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

下载内核漏洞cve-2020-14386 显示/tmp是一个文件夹 #28

Closed
duowen1 opened this issue May 11, 2021 · 1 comment
Closed

下载内核漏洞cve-2020-14386 显示/tmp是一个文件夹 #28

duowen1 opened this issue May 11, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@duowen1
Copy link
Contributor

duowen1 commented May 11, 2021

执行命令sudo ./metarget cnv install cve-2020-14386,python异常输出如下:

Traceback (most recent call last):
  File "./metarget", line 231, in <module>
    main()
  File "./metarget", line 224, in main
    args.func(args)
  File "/home/user/Desktop/metarget/cmds/cnv.py", line 136, in install
    gadgets=vuln['dependencies'], verbose=args.verbose):
  File "/home/user/Desktop/metarget/core/env_managers/kernel_installer.py", line 54, in install_by_version
    version, verbose=verbose)
  File "/home/user/Desktop/metarget/core/env_managers/kernel_installer.py", line 86, in _install_by_version_with_download
    cls.download_file(deb, config.kernel_packages_dir)
  File "/home/user/Desktop/metarget/core/env_managers/installer.py", line 300, in download_file
    with open(dst, 'wb') as f:
IsADirectoryError: [Errno 21] Is a directory: '/tmp'

原因是字符串dst此时为'/tmp',是一个目录。修改metarget/core/env_managers/installer.py第299行:

原代码

dst=save_path

修改后

dst=save_path+'/'+url.split('/')[-1]
@brant-ruan
Copy link
Member

brant-ruan commented May 11, 2021

执行命令sudo ./metarget cnv install cve-2020-14386,python异常输出如下:

Traceback (most recent call last):
  File "./metarget", line 231, in <module>
    main()
  File "./metarget", line 224, in main
    args.func(args)
  File "/home/user/Desktop/metarget/cmds/cnv.py", line 136, in install
    gadgets=vuln['dependencies'], verbose=args.verbose):
  File "/home/user/Desktop/metarget/core/env_managers/kernel_installer.py", line 54, in install_by_version
    version, verbose=verbose)
  File "/home/user/Desktop/metarget/core/env_managers/kernel_installer.py", line 86, in _install_by_version_with_download
    cls.download_file(deb, config.kernel_packages_dir)
  File "/home/user/Desktop/metarget/core/env_managers/installer.py", line 300, in download_file
    with open(dst, 'wb') as f:
IsADirectoryError: [Errno 21] Is a directory: '/tmp'

原因是字符串dst此时为'/tmp',是一个目录。修改metarget/core/env_managers/installer.py第299行:

原代码

dst=save_path

修改后

dst=save_path+'/'+url.split('/')[-1]

感谢指出,这里确实是一个bug,但是需要将path在外层拼接,一方面是除了kernel外还有其他(如kata-containers)的installer也用到了download_file,另外save_path本身的参数语义就应该指的是文件路径。

@brant-ruan brant-ruan added the bug Something isn't working label May 11, 2021
brant-ruan added a commit that referenced this issue May 11, 2021
deliver file path in kernel_installer; fix #28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants