~/service-r-services

R-Services

CPTS Notes2 min read

TL;DR

R-services. A legacy Unix remote-access suite (rlogin, rsh, rexec, rcp) on TCP 512 (rexec), 513 (rlogin), and 514 (rsh). Cleartext, and replaced by SSH. They trust the client, so a misconfigured trust file grants access with no password.

First checks: the three ports open, and a .rhosts or /etc/hosts.equiv trust.

Commands

Command Port Does
rlogin <host> -l <user> 513 Log in to a remote host.
rsh <host> <cmd> 514 Run a command, no login.
rexec 512 Run a command with a username and password.
rwho 513/udp List logged-in users network-wide.
rusers -al <host> — Detailed logged-in users.

Enumeration

Sweep.

sudo nmap -sV -p512,513,514 -oA scans/r-services $TARGET # rexec, rlogin, and rsh ports and versions

List users on the network.

rwho # logged-in users across the network
rusers -al $TARGET # detailed logged-in users on the host

The names are accounts to target.

Common misconfigurations

  • A .rhosts or /etc/hosts.equiv entry trusting a host or user, which skips authentication.
  • The + wildcard in a trust file, which trusts everyone.
  • The services reachable at all, since they are cleartext and obsolete.

Attack playbook

R-services trust the client. Abuse the trust.

  1. Log in on a trust. When .rhosts or hosts.equiv trusts your host or user (or uses +), rlogin logs you in with no password.
    rlogin <host> -l <user> # log in as a trusted user
  2. Name targets. rwho and rusers give logged-in usernames to feed this and other services.
  3. Run commands. A trusted relationship also runs commands with rsh.
    rsh <host> <cmd> # run one command, no login
  4. Reuse credentials. Found passwords may work on rexec.

Practice boxes

R-services are legacy and rare on current boxes.

When you meet R-services, the win is a .rhosts trust that lets you log in without a password.