Skip to content

Commit e5a5d35

Browse files
committed
add 'promptname' that expands the module path a bit more
This allows the user to actually see the module context.
1 parent 55f56a5 commit e5a5d35

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

lib/msf/core/module/full_name.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ def fullname
2424
type + '/' + refname
2525
end
2626

27+
def promptname
28+
elements = refname.split('/')
29+
"#{elements[-2]}/#{elements[-1]}"
30+
end
31+
2732
def shortname
2833
refname.split('/').last
2934
end
@@ -55,9 +60,16 @@ def refname
5560
end
5661

5762
#
58-
# Returns the module's framework short name. This is a
59-
# possibly conflicting name used for things like console
60-
# prompts.
63+
# Returns the module's framework prompt-friendly name.
64+
#
65+
# reverse_tcp
66+
#
67+
def promptname
68+
self.class.promptname
69+
end
70+
71+
#
72+
# Returns the module's framework short name.
6173
#
6274
# reverse_tcp
6375
#

lib/msf/ui/console/command_dispatcher/core.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ def cmd_spool(*args)
11071107
if active_module
11081108
# intentionally += and not << because we don't want to modify
11091109
# datastore or the constant DefaultPrompt
1110-
prompt += " #{active_module.type}(%bld%red#{active_module.shortname}%clr)"
1110+
prompt += " #{active_module.type}(%bld%red#{active_module.promptname}%clr)"
11111111
end
11121112
prompt_char = framework.datastore['PromptChar'] || Msf::Ui::Console::Driver::DefaultPromptChar
11131113
driver.update_prompt("#{prompt} ", prompt_char, true)

lib/msf/ui/console/command_dispatcher/modules.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ def cmd_use(*args)
661661
# Update the command prompt
662662
prompt = framework.datastore['Prompt'] || Msf::Ui::Console::Driver::DefaultPrompt
663663
prompt_char = framework.datastore['PromptChar'] || Msf::Ui::Console::Driver::DefaultPromptChar
664-
driver.update_prompt("#{prompt} #{mod.type}(%bld%red#{mod.shortname}%clr) ", prompt_char, true)
664+
driver.update_prompt("#{prompt} #{mod.type}(%bld%red#{mod.promptname}%clr) ", prompt_char, true)
665665
end
666666

667667
#

0 commit comments

Comments
 (0)