Map Meterpreter command IDs to their names when raising a RequestError #14562
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Back when we release version 6, we changed Meterpreter commands to use numeric IDs instead of string values. Since then, when a
RequestError
is raised for whatever reason we get the numeric command ID instead of the name which means the user needs to look it up themselves to get some context as to what command failed.This PR updates the
RequestError
to map the numeric command ID back to its string representation by looking up the extension module, then enumerating theCOMMAND_ID_*
constants to find the correct value. The result is nicer error messages that can help the user quickly identify the problem.Examples
The following two cases show the before and after. In this case, an error is raised while running the
post/linux/gather/gnome_keyring_dump
module because the target system doesn't have the necessarylibgnome-keyring.so.0
library. This causes thestdapi_railgun_api
command (ID: 1028) to fail. Notice the number in the first example, and the string in the second.Before
After
Verification
You'll need to trigger some kind of an exception to see the new details.
msfconsole
libgnome-keyring.so.0
post/linux/gather/gnome_keyring_dump
module and see the error message without the command ID