rapid7/metasploit-framework — pull request #3954 by wchen-r7 (2014-10-06 19:05:30+00:00)
Title: Fix #3822 - Support file:// syntax for check()

This patch addresses two things:

* It fixes #3822 - Basically supporting the ```file://``` syntax.
* Input validation for RHOST and RHOSTS

## Requirements for verifying this patch

- [ ] A Windows XP SP3 machine without patches.
- [ ] Load msfconsole with the patch
- [ ] Generate an IP file like the following:

```
echo 192.168.1.79 > /tmp/ip.txt
echo 192.168.1.80 >> /tmp/ip.txt
echo 192.168.1.81 >> /tmp/ip.txt
```

Make sure one of the IPs is the vulnerable machine. In my case, 192.168.1.80 is my vulnerable box. You should change the IPs.

## Verification steps

**Scenario 1: Use an ip list (file)**

- [ ] Do ```use exploits/windows/smb/ms08_067_netapi```
- [ ] Make sure the datastore options RHOST or RHOSTS aren't set. If they're set, you should use the unset command like this: ```unset RHOSTS```
- [ ] Do ```check file://tmp/ip.txt```
- [ ] You should see that check is scanning an IP range based on ip.txt

**Scenario 2: Supply a valid IP range as an argument**

- [ ] Do ```use exploits/windows/smb/ms08_067_netapi```
- [ ] Make sure the datastore options RHOST or RHOSTS aren't set. If they're set, you should use the unset command like this: ```unset RHOSTS```
- [ ] Do ```check [IP RANGE]```. Obviously you will have to change the IP range.
- [ ] You should see that check is scanning the above IP range

**Scenario 3: Supply RHOSTS as a datastore option**

- [ ] Do ```use exploits/windows/smb/ms08_067_netapi```
- [ ] Do ```set RHOSTS [IP RANGE]```
- [ ] Do ```check```
- [ ] You should see that check is scanning your IP range

**Scenario 3: Try to scan a single host (that's vulnerable) from an argument**

- [ ] Do ```use exploits/windows/smb/ms08_067_netapi```
- [ ] Make sure the datastore options RHOST or RHOSTS aren't set. If they're set, you should use the unset command like this: ```unset RHOSTS```
- [ ] Do ```check [IP]```
- [ ] The check should flag your vulnerable host as vulnerable.

**Scenario 4: Try to scan a single host (that's vulnerable) from a datastore option**

- [ ] Do ```use exploits/windows/smb/ms08_067_netapi```
- [ ] Do ```set RHOST [IP]```
- [ ] Do ```check```
- [ ] You should see that check is scanning your IP

**Scenario 5: Supply a bad IP as an argument```

- [ ] Do ```use exploits/windows/smb/ms08_067_netapi```
- [ ] Do ```set RHOST BADIP```
- [ ] Do ```check```
- [ ] You should see an error: "Check failed: The following options failed to validate: RHOST."