Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cut unknown command handling time in half #13041

Merged

Conversation

@adfoster-r7
Copy link
Contributor

adfoster-r7 commented Mar 6, 2020

When entering invalid commands to the metasploit console, it can take ~2 seconds to finally output the message:

[-] Unknown command: foo.

It seems like the majority of this time is spent checking to see if the invalid command is a module name. On closer inspection, it seemed like this check is being ran twice. This PR reduces the double lookup.

It's a separate effort to investigate why creating a missing module is so slow 馃暤

Edit: It seems like the full second is spent calling off to the recalculate method within the module manager's create(name, aliased_as: nil) method. This seems to get recalculated on every missing command call:

Msf::PayloadSet recalculate time = 0.960764s

Before

When putting a timer around the unknown_command method:

Time: 2.104432

After

Time: 0.905397

Verification

List the steps needed to make sure this thing works

  • Start msfconsole
  • Verify valid commands work
  • Verify missing commands work
  • Verify a module name prompts the user to load it
@adfoster-r7 adfoster-r7 changed the title Cut command missing time in half Cut unknown command handling time in half Mar 6, 2020
@wvu-r7 wvu-r7 requested a review from acammack-r7 Mar 6, 2020
@wvu-r7

This comment has been minimized.

Copy link
Member

wvu-r7 commented Mar 6, 2020

@wvu-r7

This comment has been minimized.

Copy link
Member

wvu-r7 commented Mar 6, 2020

And here I thought you were going to rm half the modules.

Copy link
Contributor

acammack-r7 left a comment

Yep, no modules are going to be implicitly named .exe. Good catch!

@wvu-r7
wvu-r7 approved these changes Mar 9, 2020
Copy link
Member

wvu-r7 left a comment

LGTM, btw.

@adamgalway-r7 adamgalway-r7 merged commit 0b271f3 into rapid7:master Mar 10, 2020
3 checks passed
3 checks passed
Metasploit Automation - Sanity Test Execution Successfully completed all tests.
Details
Metasploit Automation - Test Execution Successfully completed all tests.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@adamgalway-r7

This comment has been minimized.

Copy link
Contributor

adamgalway-r7 commented Mar 10, 2020

Release Notes

The Metasploit console now responds twice as fast when an invalid or unknown command is entered. The time was lowered from 2 seconds to 1 second.

@adfoster-r7 adfoster-r7 deleted the adfoster-r7:cut-command-missing-time-in-half branch Mar 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can鈥檛 perform that action at this time.