如何开始编写 Metasploit modules/exploits?
How to get started writing Metasploit modules/exploits?
我想为 Metasploit 框架贡献代码,但我还不知道他们的格式指南和代码要求。开始编写自己的 Metasploit 模块的贡献指南是什么?
如果你关注这个link:
您不仅会找到有关设置 metasploit 模块的有用参考,还会找到整个 wiki(在撰写本文时)有 106 页关于 metasploit 开发和使用的内容。
现在,我说 reference 而不是 tutorial 因为制作 metasploit 模块 10% 的样板代码需要查找,90% good-old-ruby 与 metasploit 无关。
以这个简单的模板模块为例:
require 'msf/core'
class MetasploitModule < Msf::Auxiliary
include Msf::Auxiliary::Scanner
def initialize(info = {})
super(update_info(info,
'Name' => 'Module name',
'Description' => %q{
Say something that the user might want to know.
},
'Author' => [ 'Name' ],
'License' => MSF_LICENSE
))
end
def run
# use `print_status` to print to the metasploit console, instead of `puts`
end
end
逐行浏览:
require 'msf/core'
首先我们需要 metasploit 文件以便我们可以使用它们。
class MetasploitModule < Msf::Auxiliary
然后我们定义一个新的class继承自metasploit辅助class.
include Msf::Auxiliary::Scanner
这里我们包含了 metasploit 扫描器,所以我们可以在我们的代码中使用它。您可以在此处包含任何 metasploit 的模块,以便在您自己的模块中使用它们;但是,您可能找不到这些模块的教程。您需要阅读文档以了解如何使用它们。
def initialize(info = {})
super(update_info(info,
'Name' => 'Module name',
'Description' => %q{
Say something that the user might want to know.
},
'Author' => [ 'Name' ],
'License' => MSF_LICENSE
))
end
这个初始化方法基本上是样板代码,它告诉 metasploit 关于您的模块的信息,以便它可以在 metasploit 控制台内向用户显示这些信息。
def run
# use `print_status` to print to the metasploit console, instead of `puts`
end
这就是您的代码所在的位置!这也是 metasploit 结束和 good-old-ruby 开始的地方。如果您正在制作一个 HTTP 服务器来回显恶意负载,请使用一个 http 服务器 gem 并编写您的逻辑。您可以在此处使用 metasploit 模块,但您可以像使用任何其他 ruby gem 或库一样使用它们(并学习如何使用它们):查找文档和 API参考。
end
就是这样!最终,您会发现是什么让 IT 安全成为如此困难的领域。没有任何教程可以教您如何破解,也没有可以帮助您创建漏洞的框架。 Metasploit 更像是一个用于整理漏洞利用集合的工具,编写您自己的模块只是将您的漏洞利用“插入”到 metasploit 中,以便其他人可以轻松使用它。漏洞本身只是一些 ruby 代码,使用基本网络库来做一些巧妙的事情。
创建一个全新且有用的黑客工具将是一件大事,一些付费安全专业人员只是梦想实现。我建议你选择一个已经存在的黑客工具(密码破解器、网络扫描器、网络爬虫等),研究该工具的目的和功能,熟悉使用它,并着手创建你自己的版本。然后,一旦你让它做你想做的事,拿你的代码并将它包装在一个 metasploit 模板中,这样它就可以从 metasploit 访问。
如果遇到困难,可以带着更具体的问题返回 Whosebug(例如“如何扫描 IP 上的开放端口?”或“如何访问 metasploit 模块内的选项? "),我们很乐意为您提供帮助!
干杯,祝你好运!
我想为 Metasploit 框架贡献代码,但我还不知道他们的格式指南和代码要求。开始编写自己的 Metasploit 模块的贡献指南是什么?
如果你关注这个link:
您不仅会找到有关设置 metasploit 模块的有用参考,还会找到整个 wiki(在撰写本文时)有 106 页关于 metasploit 开发和使用的内容。
现在,我说 reference 而不是 tutorial 因为制作 metasploit 模块 10% 的样板代码需要查找,90% good-old-ruby 与 metasploit 无关。
以这个简单的模板模块为例:
require 'msf/core'
class MetasploitModule < Msf::Auxiliary
include Msf::Auxiliary::Scanner
def initialize(info = {})
super(update_info(info,
'Name' => 'Module name',
'Description' => %q{
Say something that the user might want to know.
},
'Author' => [ 'Name' ],
'License' => MSF_LICENSE
))
end
def run
# use `print_status` to print to the metasploit console, instead of `puts`
end
end
逐行浏览:
require 'msf/core'
首先我们需要 metasploit 文件以便我们可以使用它们。
class MetasploitModule < Msf::Auxiliary
然后我们定义一个新的class继承自metasploit辅助class.
include Msf::Auxiliary::Scanner
这里我们包含了 metasploit 扫描器,所以我们可以在我们的代码中使用它。您可以在此处包含任何 metasploit 的模块,以便在您自己的模块中使用它们;但是,您可能找不到这些模块的教程。您需要阅读文档以了解如何使用它们。
def initialize(info = {})
super(update_info(info,
'Name' => 'Module name',
'Description' => %q{
Say something that the user might want to know.
},
'Author' => [ 'Name' ],
'License' => MSF_LICENSE
))
end
这个初始化方法基本上是样板代码,它告诉 metasploit 关于您的模块的信息,以便它可以在 metasploit 控制台内向用户显示这些信息。
def run
# use `print_status` to print to the metasploit console, instead of `puts`
end
这就是您的代码所在的位置!这也是 metasploit 结束和 good-old-ruby 开始的地方。如果您正在制作一个 HTTP 服务器来回显恶意负载,请使用一个 http 服务器 gem 并编写您的逻辑。您可以在此处使用 metasploit 模块,但您可以像使用任何其他 ruby gem 或库一样使用它们(并学习如何使用它们):查找文档和 API参考。
end
就是这样!最终,您会发现是什么让 IT 安全成为如此困难的领域。没有任何教程可以教您如何破解,也没有可以帮助您创建漏洞的框架。 Metasploit 更像是一个用于整理漏洞利用集合的工具,编写您自己的模块只是将您的漏洞利用“插入”到 metasploit 中,以便其他人可以轻松使用它。漏洞本身只是一些 ruby 代码,使用基本网络库来做一些巧妙的事情。
创建一个全新且有用的黑客工具将是一件大事,一些付费安全专业人员只是梦想实现。我建议你选择一个已经存在的黑客工具(密码破解器、网络扫描器、网络爬虫等),研究该工具的目的和功能,熟悉使用它,并着手创建你自己的版本。然后,一旦你让它做你想做的事,拿你的代码并将它包装在一个 metasploit 模板中,这样它就可以从 metasploit 访问。
如果遇到困难,可以带着更具体的问题返回 Whosebug(例如“如何扫描 IP 上的开放端口?”或“如何访问 metasploit 模块内的选项? "),我们很乐意为您提供帮助!
干杯,祝你好运!