You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/network-services-pentesting/512-pentesting-rexec.md
+55-4Lines changed: 55 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,8 @@ PORT STATE SERVICE
25
25
3. A final NUL-terminated string with the **command** to execute is sent.
26
26
4. The server replies with a single 8-bit status byte (0 = success, `1` = failure) followed by the command output.
27
27
28
+
If the first field is **non-zero**, the server opens a **second TCP connection back to the client** and uses it for stderr. This is useful both for **manual testing** and for **fingerprinting filtering / firewall issues** around the service.
29
+
28
30
That means you can reproduce the exchange with nothing more than `echo -e` and `nc`:
29
31
30
32
```bash
@@ -33,6 +35,15 @@ That means you can reproduce the exchange with nothing more than `echo -e` and `
33
35
34
36
If the credentials are valid you will receive the output of `id` straight back on the same connection.
35
37
38
+
If you want to receive stderr on a dedicated listener, ask the server to connect back to you:
Many common implementations (for example GNU `rexecd`) still enforce **16-byte username/password fields** and return **different diagnostic strings** for invalid usernames vs invalid passwords. That matters during enumeration because some targets leak whether the account exists before you start brute forcing.
46
+
36
47
### Manual usage with the client
37
48
38
49
Many Linux distributions still ship the legacy client inside the **inetutils-rexec** / **rsh-client** package:
`hydra` has a dedicated **rexec** module and remains the fastest offline bruteforcer . `medusa` (`-M REXEC`) and `ncrack` (`rexec` module) can be used in the same way.
67
86
87
+
### Username enumeration through server messages
88
+
89
+
Some `rexecd` implementations expose distinct errors such as **`Login incorrect.`** vs **`Password incorrect.`**. If you see this behavior, validate usernames first and only then brute force passwords:
If the messages differ, build a valid-user list before sending a large password spray.
97
+
98
+
### Check sibling *r*-services
99
+
100
+
`rexec` itself uses **password authentication**, unlike `rsh` / `rlogin` trusted-host logic, but in practice they often arrive from the **same legacy package** (`openbsd-inetd`, `inetutils`, vendor UNIX bundles). If TCP 512 is open, immediately check TCP **513** and **514** as well because `.rhosts` / `/etc/hosts.equiv` abuse may offer easier lateral movement:
* Passwords are often stored in **~/.netrc** on other systems; if you compromise one host you may reuse them for lateral movement.
147
+
* Passwords are often stored in **`~/.netrc`** or legacy automation scripts on other systems; if you compromise one host you may reuse them for lateral movement:
0 commit comments