rapid7/metasploit-framework — pull request #1861 by todb-r7 (2013-05-23 16:57:42+00:00)
Title: Auxiliary modules should implement check

This addresses the bug at:

https://dev.metasploit.com/redmine/issues/7975

which was brought up as part of https://github.com/rapid7/metasploit-framework/pull/1855

## TL;DR:

Instead of exposing `check` and `cmd_check` to Exploit-class modules, add these useful methods to all modules.

## Validation

- [ ] In the Metasploit top-level directory, run `./msfconsole -qLm test/modules -r test/scripts/test-check.rc`
- [ ] Verify the the expected results:

````
$ ./msfconsole -qLm test/modules/ -r test/scripts/test-check.rc
[-] WARNING! The following modules could not be loaded!
[-]	/home/todb/git/rapid7/metasploit-framework/test/modules/post/test/unix.rb: LoadError cannot load such file -- test/lib/module_test
[*] Processing test/scripts/test-check.rc for ERB directives.
resource (test/scripts/test-check.rc)> use auxiliary/test/check
resource (test/scripts/test-check.rc)> set rhost www.metasploit.com
rhost => www.metasploit.com
resource (test/scripts/test-check.rc)> check
[!] Check is successful
[+] The target is vulnerable.
resource (test/scripts/test-check.rc)> use exploit/test/check
resource (test/scripts/test-check.rc)> set rhost www.metasploit.com
rhost => www.metasploit.com
resource (test/scripts/test-check.rc)> check
[!] Check is successful
[+] The target is vulnerable.
msf exploit(check) >

````
- [ ] Verify existing checks function as expected. For this case, I used ol' reliable, ms08_067_netapi, against both vulnerable and invulnerable hosts.

````
msf exploit(ms08_067_netapi) > check

[*] Verifying vulnerable status... (path: 0x0000005a)
[*] System is not vulnerable (status: 0x00000000)
[*] The target is not exploitable.
msf exploit(ms08_067_netapi) > set rhost 192.168.145.60
rhost => 192.168.145.60
msf exploit(ms08_067_netapi) > check

[*] Verifying vulnerable status... (path: 0x0000005a)
[+] The target is vulnerable.
msf exploit(ms08_067_netapi) >
````