-
Notifications
You must be signed in to change notification settings - Fork 14k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Alias functionality (or generic: extensibility) for meterpreter shells. #5808
Comments
@henryk. I wrote the original alias plugin so I'll take a look. I'm currently at DefCon/BlackHat so don't expect any real feedback (from me at least) until next week. I'm glad someone other than me uses it tho! |
Hi @henryk, The one thing I can comment on here is the suggestion for If an existing session has, say, the So in short, the Does that make sense? Cheers! |
@henryk one of the original reasons I made it into a console plugin was it's experimental & add-on nature at the time. It's definitely worth revisiting now. other devs (@hmoore-r7, @wvu-r7, @todb-r7, @firefart, @zeroSteiner, @jlee-r7 et. al.) thoughts on moving alias functionality to lib/rex/ui/text/dispatcher_shell.rb? A quick investigation makes me think there are no technical barriers to doing so, however you guys may have objections/concerns. And, AFAIK, there's no good way to share functionality between msfconsole and the meterpreter console, tho I could definitely be wrong. |
anyone? Bueller? |
@kernelsmith How would saved aliases apply? There is no equivalent of the "save" command for the meterpreter shell. |
aliases aren't really saved in the way that datastore options are saved when you hit save. I actually tried to add that one time, hit some snag, got distracted and never went back to it. Currently the only way to save aliases is in msfconsole.rc or similar. |
for example, this is my stock msfconsole.rc: https://github.com/kernelsmith/env-customization/blob/master/msf/msfconsole.rc which I add to pretty much every metasploit install/dev environment that I have |
Would having the same alias for both msfconsole and meterpreter sessions make sense? If not, implementing these in the Rex code may not make sense. |
@hmoore-r7 In general, the same alias definition will not work in msfconsole and meterpreter, but doesn't need to be. The way I understand it, these are two separate objects, representing different classes, but derived from the same base class (where the alias code would go). That is, the alias definitions are instance variables and not shared between msfconsole and meterpreter. The alias definition syntax and associated code however could be shared without problem. Like @kernelsmith said, the way to have the same aliases in all msfconsole sessions is with an rc file, and a similar thing can be done for meterpreter sessions with |
And I could have sworn that at one point there was a meterpreter.rc that would always get run on a new meterpreter session like msfconsole.rc does on console startup, but I must have dreamed that, tho it can still be accomplished w/AutoRunScript as @henryk points out |
FYI, I removed the meterpreter label and added msfconsole as it doesn't really affect meterpreter directly. |
Go for it! |
@kernelsmith I'm thisclose to adding the |
I like the option of moving it into The |
I forgot about this baby. @zeroSteiner yeah, not having it as an extension would reduce complexity. Tho, an ext would be client side only, but I don't remember if you can indicate that in the extension interface. I would have guessed you could. If it's in a lib, does Rex make sense? I dunno if Rex was ever unentangled, or is it still a hodgepodge and not really Ruby EXtensions. I'm assuming it was not unentangled so Rex is the only common lib location this thing could realistically reside. |
Rex FTW! I take it Rex still hasn't been refactored to pull out non- "Ruby extension" code? Otherwise I would say console code probably shouldn't be in there. Thanks for weighing in @zeroSteiner . Taking design decisions from a Python guy just seems wrong ;) |
Yeah I'm pretty sure the state of Rex is still the same. Also wow... 😆 |
In the current situation there are at least two distinct shells in metasploit: The metasploit shell and the meterpreter shell. The metasploit shell can load framework plugins (with
load
), the meterpreter shell can't. Well …My end wish would be to have an alias command in both types of shells, but I'm completely unclear on how to achieve that and am looking for some guidance. These are the ways I could come up with:
help
.As a proof of concept and for internal use I have built a variant of method 3. The problem with the current meterpreter shell
load
command is that it will first try to load a dll into the target meterpreter before extending the shell. (Bonus: Discovering the code for this is somewhat hard, since the dlls for the existing meterpreter extensions are not in the metasploit git checkout.) My code is at https://github.com/henryk/metasploit-framework/compare/custom-commands but I have deliberately not opened a pull request. As is this code can't and shouldn't go upstream.What I've done is:
-c
to the meterpreterload
command that will skip loading the meterpreter extension dll (and just load the associated command dispatcher), andWith these changes, it's possible to issue
load -c alias
in a meterpreter shell and behave as expected.Cons: a) The separate
-c
option is very clumsy. b) Code duplication between AliasCommandDispatcher and my Alias extension.Obviously I'd like this to be done right™, before proposing to pull something upstream.
The text was updated successfully, but these errors were encountered: