rapid7/metasploit-framework — pull request #3381 by todb-r7 (2014-05-22 15:49:42+00:00)
Title: Support RHOSTS for msfcli (C)heck mode

One of my favorite users, @sho-luv, noticed that RHOSTS doesn't work when you want to run a (C)heck from msfcli.

I've addressed this by simply stomping on the RHOSTS field and iterating over the given RHOSTS option. Since msfcli is a oneshot, we don't need to worry about preserving RHOST after the run on the module.

## Verification

Run the following commands, using your own preferred IP addresses.

- [ ] `./msfcli exploit/windows/smb/ms08_067_netapi RHOST=10.1.1.1 RHOSTS=192.168.145.60,191,137 C` - demonstrates concatination of RHOST and RHOSTS, and the nmap-style comma-seperated last octets.
- [ ] `./msfcli exploit/windows/smb/ms08_067_netapi RHOST=10.1.1.1 RHOSTS=192.168.145.60/30 C` - demos CIDR notation
- [ ] `./msfcli exploit/windows/smb/ms08_067_netapi RHOSTS=192.168.145.60,137 C` - demos that RHOST is not necessary to set (since we're doing it internally)
- [ ] `./msfcli exploit/windows/smb/ms08_067_netapi RHOSTS=192.168.145.59-61 C` - demos hyphen ranges.

## Expected Results:

````
[ruby-1.9.3-p484@metasploit-framework] (multicheck-msfcli-compat)
todb@mazikeen:~/git/rapid7/metasploit-framework
$ ./msfcli exploit/windows/smb/ms08_067_netapi RHOST=10.1.1.1 RHOSTS=192.168.145.60,191,137 C
[*] Initializing modules...
[*] Checking 10.1.1.1, 192.168.145.60,191,137
[*] 10.1.1.1:445 - Cannot reliably check exploitability.
[+] 192.168.145.60:445 - The target is vulnerable.
[*] 192.168.145.137:445 - The target is not exploitable.
[*] 192.168.145.191:445 - The target is not exploitable.

[ruby-1.9.3-p484@metasploit-framework] (multicheck-msfcli-compat)
todb@mazikeen:~/git/rapid7/metasploit-framework
$ ./msfcli exploit/windows/smb/ms08_067_netapi RHOST=10.1.1.1 RHOSTS=192.168.145.60/30 C
[*] Initializing modules...
[*] Checking 10.1.1.1, 192.168.145.60/30
[*] 10.1.1.1:445 - Cannot reliably check exploitability.
[+] 192.168.145.60:445 - The target is vulnerable.
[*] 192.168.145.61:445 - Cannot reliably check exploitability.
[*] 192.168.145.62:445 - Cannot reliably check exploitability.
[*] 192.168.145.63:445 - Cannot reliably check exploitability.

[ruby-1.9.3-p484@metasploit-framework] (multicheck-msfcli-compat)
todb@mazikeen:~/git/rapid7/metasploit-framework
$ ./msfcli exploit/windows/smb/ms08_067_netapi RHOSTS=192.168.145.60,137 C
[*] Initializing modules...
[*] Checking 192.168.145.60,137
[+] 192.168.145.60:445 - The target is vulnerable.
[*] 192.168.145.137:445 - The target is not exploitable.

[ruby-1.9.3-p484@metasploit-framework] (multicheck-msfcli-compat)
todb@mazikeen:~/git/rapid7/metasploit-framework
$ ./msfcli exploit/windows/smb/ms08_067_netapi RHOSTS=192.168.145.59-61 C
[*] Initializing modules...
[*] Checking 192.168.145.59-61
[*] 192.168.145.59:445 - Cannot reliably check exploitability.
[+] 192.168.145.60:445 - The target is vulnerable.
[*] 192.168.145.61:445 - Cannot reliably check exploitability.

[ruby-1.9.3-p484@metasploit-framework] (multicheck-msfcli-compat)
todb@mazikeen:~/git/rapid7/metasploit-framework
$
````

## Caveats

the `file:/path/to/file` format is not supported in this mode -- but it's not supported in the usual `msfconsole` implementation either. So... not a new bug, no missing functionality.