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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add module favorites/bookmarks functionality for msfconsole #5107

Closed
reider-roque opened this issue Apr 9, 2015 · 10 comments
Closed

Add module favorites/bookmarks functionality for msfconsole #5107

reider-roque opened this issue Apr 9, 2015 · 10 comments

Comments

@reider-roque
Copy link

Feature request.

The amount of available modules is enormous. And sometimes it is difficult to recall the module path I'm looking for (search to the rescue). It'll be nice to have some kind of persistent [across msfconsole restarts] favorites/bookmarks mechanism that could be used for the purpose.

Platform/Version information:

root@kali:/tmp# lsb_release -d
Description:    Kali GNU/Linux 1.1.0
root@kali:/tmp# uname -a
Linux kali 3.18.0-kali3-amd64 #1 SMP Debian 3.18.6-1~kali2 (2015-03-02) x86_64 GNU/Linux
root@kali:/tmp# apt-cache show metasploit-framework | grep Version
Version: 4.11.1-2015040202-1kali1
@wvu
Copy link
Contributor

wvu commented Apr 14, 2015

A text file?

@kernelsmith
Copy link
Contributor

You can already basically do this with aliases. I have a standing alias for the psexec module for instance

In msfconsole:

msf > load alias
msf > alias -h # for help
msf > alias -f psexec use exploit/windows/smb/psexec
msf > alias # will list your active aliases

The path on that psexec might be wrong, just going from memory.
They won't be persistent By default as the save command doesn't include them. I did start adding it at one point but ran into some kind of problem which derailed me and I never got back to it. However, I make them persistent via msfconsole.rc

Create a file at ~/.msf4/msfconsole.rc and populate it with the output from the list of active aliases from above. I also recommend putting a -f in each of them because the alias plugin will check the validity of each alias, and not all commands are in scope during msfconsole start up, the -f will override the check and alias it anyways. So msfconsole.rc might look like:

load alias
alias -f psexec use exploit/windows/smb/psexec
alias -f so show options
Etc
Etc

~/.msf4/msfconsole.rc Is loaded by msfconsole automatically upon startup

@reider-roque
Copy link
Author

alias might actually be a good option for the purpose, thanks for the tip.

@wvu
Copy link
Contributor

wvu commented Apr 15, 2015

@kernelsmith wrote alias. ;)

@reider-roque
Copy link
Author

One thing to note in @kernelsmith's scheme is that ~/.msf4/msfconsole.rc is not loaded automatically if you provide msfconsole with another resource file using -r flag. Though you can always add
alias msfconsole='msfconsole -r ~/.msf4/msfconsole.rc'
to your ~/.bashrc, or even designate a separate file for aliases:
alias msfconsole='msfconsole -r ~/.msf4/msfconsole-aliases.rc'

@kernelsmith
Copy link
Contributor

Yeah, I used to chain resource files together but now I just start msfconsole and then load other rc's with the resource command if need be. Or add 'resource other.rc' to the bottom of msfconsole.rc

@kernelsmith
Copy link
Contributor

@reider-roque, if you start using aliases, I think there will now be two of us ;). I use them all the time, but I'm pretty sure no one else does LOL.

BTW, do you feel this is a good enough solution or do you want to keep the issue open? We could discuss a change that might have an aliases.rc always run, if present, even if -r is specified. It's exceedingly unlikely that doing so would cause any trouble for the specified additional resource file

@reider-roque
Copy link
Author

@kernelsmith, I think it would be awesome if you could add persistency to the plugin. I mean saving and keeping aliases across msfconsole restarts.

Here is a scheme I have in mind:

  • Keep a separate resource file for aliases -- ~/.msf4/aliases.rc
  • Add a -p (persistence) flag to alias command that would dump all currently held in memory aliases to ~/.msf4/aliases.rc (overwriting it) in the alias short_cmd long_cmd format
  • Add a -r (reload) flag to alias command that would run resource ~/.msf4/aliases.rc in msfconsole effectively loading in all aliases present in the file. The corner case here is when alias from the aliases.rc is already present in memory. To take care of this case you can:
    • Either befriend -r and -f flags (I like this for conciseness)
    • Or add -R (forceful reload) flag that will transform every alias short_cmd long_cmd to alias -f short_cmd long_cmd before running it
  • Every time load alias is called execute -r (reload) function to load all persistent aliases from the file

Of course proposed flag names can be named something else. E.g. -p (persistence) can instead be named -w (write to the file) or -s (save); and -R may be named --force-reload for extra precaution.

I'm sorry I can't help with adding this functionality. I was staring at the alias.rb code for a while, but alas Ruby is not a good fried of mine yet.

@kernelsmith
Copy link
Contributor

Thanks, I will investigate adding this functionality. Yeah, alias.rb is one of the more complicated plugins you'll see because it makes heavy use of metaprogramming to cleanly "inject" and remove methods to handle aliases that you create so aliases are handled as 1st-class commands that don't work differently than built in commands. It's actually probably the one piece of code of which I'm most proud :)

@h00die
Copy link
Contributor

h00die commented Sep 12, 2023

I believe #14201 fixed this by adding the favorite command

@h00die h00die closed this as completed Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants