简体   繁体   English

无法将 Python 脚本(需要 Metasploit)导入到 MetaSploit 模块

[英]Can't import Python script (that requires Metasploit), to MetaSploit modules

I am trying to test a vulnerability on my router using an exploit from exploit_DB.我正在尝试使用来自exploit_DB 的漏洞来测试我的路由器上的漏洞。 The exploit is a Python script that requires Metasploit to run .该漏洞利用是一个需要 Metasploit 运行的 Python 脚本。 Here's a link to the exploit这是漏洞利用的链接

I am using Kali-Linux with Metasploit v4.17.3-dev.我正在使用带有 Metasploit v4.17.3-dev 的 Kali-Linux。

What I have tried is :我尝试过的是:

  • After creating the dir, I have copied the file using cp ~/Desktop/45170.py ~/.msf4/module/exploit/windows/45170.py创建目录后,我使用cp ~/Desktop/45170.py ~/.msf4/module/exploit/windows/45170.py复制了文件

  • in msfconsole reload_all在 msfconsole reload_all

  • the exploit number on Metasploits is still the same 1795 exploits Metasploits 上的漏洞利用数量仍然是1795 exploits

  • then when I tried use /exploits/windows/45170 , I got this error Failed to load the module :/exploits/windows/45170然后当我尝试use /exploits/windows/45170 ,出现此错误Failed to load the module :/exploits/windows/45170

So that didn't work for me but when I try to use a .rb file it works with no problem.所以这对我不起作用,但是当我尝试使用.rb文件时,它没有问题。

I know it's a Ruby based framework but I also know that python support have been added.我知道它是一个基于 Ruby 的框架,但我也知道已经添加了 python 支持。

I have also tried to run it directly from python using /usr/bin/env python3 ~/Desktop/45170.py我还尝试使用/usr/bin/env python3 ~/Desktop/45170.py直接从 python 运行它

But I get this error但我收到这个错误

no module named Metasploit没有名为 Metasploit 的模块

It looks like you haven't installed Metasploit correctly. 看来您没有正确安装Metasploit。 Check the instructions provided for linux and let me know if that fixed your problem. 查看为linux提供的说明并让我知道是否可以解决您的问题。

Also, does running this example work on your Kali machine? 另外,在您的Kali机器上运行此示例是否可行? I guess that writing an external Python module for Metasploit is what you're trying to do? 我想您正在尝试为Metasploit编写外部Python模块? If the example throws an error, please report it back. 如果示例抛出错误,请重新报告。 Otherwise, please post your custom code since it might contain an obvious syntax/spelling error. 否则,请发布您的自定义代码,因为它可能包含明显的语法/拼写错误。

If these things don't solve the problem, check the location of the Python Metasploit library on your system. 如果这些不能解决问题,请检查系统上Python Metasploit库的位置。 Is it in your PYTHONPATH (run echo $PYTHONPATH from the command line)? 它在您的PYTHONPATH吗(从命令行运行echo $PYTHONPATH )? Check this link for more information on the system location of Metasploit. 检查此链接以获取有关Metasploit系统位置的更多信息。

用python3运行它

python3 45170.py ip address 
PYTHONPATH=/usr/share/metasploit-framework/lib/msf/core/modules/external/python python3 /usr/share/exploitdb/exploits/windows/remote/45170.py -h

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM