cstriker1407的笔记本

好记性不如铅笔头

安全, 操作系统

某《魔鬼训练营》读书笔记:metasploit自定义模块的编写

!!!笔记仅供学习交流使用,请勿进行其他用途!!!

首先看下已有模块的位置:

root@kali:/usr/share/metasploit-framework/modules# pwd
/usr/share/metasploit-framework/modules
root@kali:/usr/share/metasploit-framework/modules# ls
auxiliary  encoders  exploits  nops  payloads  post

这里我们在auxiliary目录下新建一个文件夹,名称为cstriker1407,里面新建一个rb文件,名称为【 cstriker1407_hello.rb 】,如下:

root@kali:/usr/share/metasploit-framework/modules/auxiliary/cstriker1407# pwd
/usr/share/metasploit-framework/modules/auxiliary/cstriker1407
root@kali:/usr/share/metasploit-framework/modules/auxiliary/cstriker1407# ls
cstriker1407_hello.rb

cstriker1407_hello.rb的内容为:

##
# This module requires Metasploit: http//metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

require 'msf/core'

class Metasploit3 < Msf::Auxiliary
  include Msf::Auxiliary::Report

  def initialize
    super(
      'Name'        => 'cstriker1407 hello module',
      'Description' => 'A demo module to learn metasploit modules.',
      'References'  =>
        [
          [ 'URL', 'http://116.62.110.235/blog' ],
        ],
      'Author'      => [ 'cstriker1407' ],
      'License'     => MSF_LICENSE
    )
  end

  def run
    print_status("Hello Metasploit Modules")
  end
  
end

文件建立好之后,重新启动下Metasploit,然后就可以使用了,如下:

msf > search cstriker1407 #搜索这个模块

Matching Modules
================

   Name                                       Disclosure Date  Rank    Description
   ----                                       ---------------  ----    -----------
   auxiliary/cstriker1407/cstriker1407_hello                   normal  cstriker1407 hello module

msf > use auxiliary/cstriker1407/cstriker1407_hello
msf auxiliary(cstriker1407_hello) > info


       Name: cstriker1407 hello module
     Module: auxiliary/cstriker1407/cstriker1407_hello
    License: Metasploit Framework License (BSD)
       Rank: Normal


Provided by:
  cstriker1407


Description:
  A demo module to learn metasploit modules.


References:
  http://116.62.110.235/blog
  
msf auxiliary(cstriker1407_hello) > show options


Module options (auxiliary/cstriker1407/cstriker1407_hello):


   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------


msf auxiliary(cstriker1407_hello) > exploit


[*] Hello Metasploit Modules #执行了run方法
[*] Auxiliary module execution completed
msf auxiliary(cstriker1407_hello) > 

 

Leave a Reply

2 × 5 =

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

Theme by Anders Norén

苏ICP备16032087号