rapid7/metasploit-framework — pull request #2153 by wchen-r7 (2013-07-24 19:01:22+00:00)
Title: Speed up testable msfcli

msfcli is designed to load only one module (auxiliary or exploit), so we shouldn't have to load all of them to run this utility. The overall goal of this PR is to narrow down what modules (exploit/aux + payload + encoder + nop) you possibly need in order to shave off loading time. By doing this, on my box this is 5-6 seconds faster than the original one.

I actually tried to avoid making too many changes in the library (such as Module Manager), because we don't have test cases for them, and we can't really afford to risk breaking it. I also developed a test script to actually be able to test msfcli.

To test msfcli, here's how you can do it automatically:

1. Open msfcli with an editor, go to line 341, you should see this line:

con.run_single("exploit")

2. Modify line 341 to the following:

con.run_single("exploit -j")
con.run_single("exit")

3. Run test/tests/msfcli_test.rb. Make sure to supply a valid LHOST. The script should give you a report in the end.