Softpanorama
(slightly skeptical) Open Source Software Educational Society

May the source be with you, but remember the KISS principle ;-)

Google   


Working with Solaris RPC Services

News

Summary  OSI Protocol Layers Recommended Books Recommended Links Lecture Notes Unix System Calls
Security Issues   MSBlaster Worm Microsoft RPC   Humor Etc

Lecture Notes

Summary

There are two ways of starting  RPC services: at boot time via RC files or on demand.

At boot time RPC services vai /etc/rc2.d/s71rpc startup script that initializes the rpcbind service After the system starts up, the rpcbind daemon starts listening at port 111. The rpcbind process associates RPC program numbers with port numbers above 32768. The port number used by the rpcbind daemon is listed in the /etc/inet/services file. To view the port number and protocol, perform the command:

grep rpcbind /etc/services

sunrpc 111/udp rpcbind
sunrpc 111/tcp rpcbind

For a client to make request to the server the rpcbind service must be running on the server system. When an RPC service starts at boot, it communicates port and RPC number to the rpcbind process:   If the RPC service has registered its current port number with the rpcbind daemon during startup, the current port number of the RPC service is returned to the client.

Some rpcbind services start only on demand. They are listed in inetd.conf  file and are controlled by inetd daemon.

The rpcinfo command is used to list and delete RPC services. Two corresponding options are -p and -d:

Introduction

Sun Microsystems's invented RPC in mid 80th. The original version of RPC was defined in RFC 1050. RPC is a powerful technique for constructing distributed, client-server based applications. It is based on extending the notion of conventional, or local procedure calling, so that the called procedure need not exist in the same address space as the calling procedure.

RPC opened new possibilities in network programming making possible such protocols as NFS, NIS, rsh, etc. Network File System (NFS) is a network file sharing system application that is a good example of how RPC can be used. Version 2 of RPC is defined in RFC 1057 and RFC 1831.

RPC services are not typically assigned to well-known ports. Rather than tying applications to particular ports, RPC provides a port mapping service whereby RPC assigns port numbers above 1024 to applications that are written to request RPC for ports. The lookup services that can be used for this include PORTMAPPER (PMAP) and RPCBIND and are described in RFC 1833. Portmapper has a fixed port (either UDP or TCP) number 111 to which an application (RPC service) makes a call to gain a port number to use. This lookup service program must be started first and remain operational throughout the runtime of the application.

The list of RPC services includes:

While originated in Sun RPC spread first to other Unixes and then to other OSes like Windows becoming pretty much a cross-platform protocol. Even command line utilities are often replicated. For example, Windows has rpcinfo utilities that operates pretty much like its Unix counterpart. To ensure cross-platform compatibility RPC data now are encoded using eXternal Data Representation (XDR), which defines how integers, floating point numbers and strings are represented(RFC 1832). This Presentation Layer protocol enables different computers with different operating systems to interact seamlessly. There is no formal message header or protocol system for XDR. XDR uses an 8-bit byte, with the lower bytes being the most significant. The RFC defines that all integer data types are converted to 4-byte integers, (there is also available an extended 64-bit integer format). IEEE 32-bit formats are used for floating-point numbers, where the mantissa is the lower 23 bits, the exponent takes 8 bits, and the sign of the number is 1 bit. Where data takes less than 4 bytes for any type, padding is added to ensure 4-byte lengths

Starting RPC Services at Boot Time

RPC services started at boot time with startup scripts run on available ports above 32768. The rpcbind process associates RPC program numbers with port numbers.

The rpcbind service must be running on the server system for you to make RPC requests to the server. When an RPC service starts at boot, it communicates the following information to the rpcbind process:

If a client wants to make an RPC call to a given program number, it must first contact the rpcbind service on the server machine to obtain the port address before it can send the RPC requests. If the RPC service has registered its current port number with the rpcbind daemon during startup, the current port number of the RPC service is returned to the
client.

In Solaris the /etc/rc2.d/s71rpc startup script initializes the rpcbind service. The port number used by the rpcbind daemon is listed in the /etc/inet/services file. After the system starts up, the rpcbind daemon starts listening at port 111. To view the port number and protocol, grep the  /etc/inet/services for string "rpcbind":

# grep rpcbind /etc/services

sunrpc 111/udp rpcbind
sunrpc 111/tcp rpcbind

 

Starting RPC Services on Demand

Some rpcbind services start only on demand. The port numbers are registered with the rpcbind process during boot.  When a client application requests a service, the rpcbind process returns the port number of the service to the client machine. The client machine generates a new request using the port number that it just received for the requested service.

RPC services on demand, such as the sprayd service, are implemented as follows:

  1. The rpcbind daemon is started on all systems by a startup script. The sprayd service is listed in both the /etc/rpc and /etc/inetd.conf files and, therefore, registers its current port assignment and program number with the rpcbind process during boot.
  2. A user on host alpha issues a spray command to host beta. The spray request is initially addressed to port 111 and contains the program number of the sprayd service.
  3. The rpcbind daemon on the host beta (server) reads the program number and determines that the request is for the sprayd service. The rpcbind daemon returns the current port number of the sprayd service to the host alpha ( client). 
  4. The host alpha (client) sends a second request to the port number of the sprayd service on the host beta (server). The inetd daemon receives the request.
  5. The inetd daemon consults entries in the /etc/inetd.conf file to find a matching entry for the service request. The inetd daemon starts the sprayd service.
  6. This rpc.sprayd daemon takes over the spray session’s communication.

Using the rpcinfo Command

The rpcinfo command makes an RPC call to an RPC server, and reports what it finds. Two frequently used options to the rpcinfo command are -p and -d.

Registration of RPC services. RPC services need to be registered. You can list services and unregister any services with rpcinfo. Note – Using the command rpcinfo -p host command returns information about registered RPC services on the specified host.


Notes:
  • Those pages are written by people for whom English is not a native language. Some amount of grammar and spelling errors should be expected.
  • This is a Spartan WHYFF (We Help You For Free) site. It cannot replace the best teachers and the best books.
  • The site contain some obsolete pages as it develops like a living tree... Some links on older pages are broken. Please try to use Google, Open directory, etc. to find a replacement link (see HOWTO search the WEB for details). We would appreciate if you can mail us a correct link.

Search Amazon by keywords:

Google   
Open directory

Research Index

 

Recommended Links

Remote Procedure Calls (RPC) by Dave Marshall (1/5/1999)

Tutorial on RPCs

A Tutorial on Sockets and RPCs

Remote Procedure Call -- Carnegue-Mellon

docs.sun.com Introduction to the Solaris Development Environment

docs.sun.com NIS+ and DNS Setup and Configuration Guide

Solaris - Tuning Your TCP-IP Stack

TCP-wrapped rpcbind for Solaris

Client Server Computing - Unix Sockets and RPC

http://csrc.ncsl.nist.gov/publications/nistpubs/800-7/node184.html

http://www.netsys.com/sunmgr/1997-12/msg00124.html

http://www.rrzn.uni-hannover.de/ZentralSys/Vektor/manual/manlib/C/nuae/nuae18/nuae0298.htm

Denial of Service in Applications Using RPC over Named Pipes

Security Issues

See also MSBlaster Worm -- the most high profile exploitation of RPC vulnerabilities in MS Windows.

DRAFT - Sun Remote Procedure Call

There are several problems with RPC itself, some more security related than others. The portmapper itself can be persuaded to "forward" requests to services which may then be fooled into thinking that they come from the local machine. The standard portmappers provide very little in the way of access control or logging. Wietse Venema has a version of the portmapper which does provide these extra services. [Solaris 10 implements this wrapper -NNB].

The more common problems are with the RPC services themselves. They are typically appallingly badly written from the security perspective and are a common source of network weaknesses..,

RPC Interface Buffer Overflow (7.17.03)

Microsoft has published an advisory regarding buffer overflow vulnerability present in the windows RPC Service. The RPC service provides remote procedure calls between objects executing on two remote machines running the Windows operating system.

SCOPE

An attacker can exploit this vulnerability by crafting a specifically malformed RPC packet and sending it to a vulnerable server. The attacker will need access to the vulnerable server RPC interface that is located at port 135.

A malicious attacker may use this vulnerability to execute code of his choice on the victim machine. Since the RPC service executes with SYSTEM privileges an attacker executing code as the result of this attack can fully compromise the vulnerable server

VERSIONS AFFECTED
Windows NT 4.0 - All service packs
Windows 2000 - All service packs

Apply the MS03-039 patch (includes MS03-026  patch) Please refer to:

2. Block port 135 when RPC service is not required

Symantec Security Response - W32.Blaster.Worm

See also MSBlaster Worm

W32.Blaster.Worm is a worm that exploits the DCOM RPC vulnerability (first described in Microsoft Security Bulletin MS03-026)(users are recommended to patch this vulnerability by applying Microsoft Security Bulletin MS03-039) using TCP port 135. The worm targets only Windows 2000 and Windows XP machines. While Windows NT and Windows 2003 Server machines are vulnerable to the aforementioned exploit (if not properly patched), the worm is not coded to replicate to those systems. This worm attempts to download the msblast.exe file to the %WinDir%\system32 directory and then execute it. W32.Blaster.Worm does not have a mass-mailing functionality.
 


Copyright © 1996-2007 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. Submit comments This document is an industrial compilation designed and created exclusively for educational use and is placed under the copyright of the Open Content License(OPL). Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

Standard disclaimer: The statements, views and opinions presented on this web page are those of the author and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.

Last modified: February 28, 2008