Skip to content

Commit b5f8ae8

Browse files
committed
Fix rapid7#3827, Add support to rename a job
Fix rapid7#3827
1 parent 4097222 commit b5f8ae8

File tree

1 file changed

+75
-40
lines changed
  • lib/msf/ui/console/command_dispatcher

1 file changed

+75
-40
lines changed

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

Lines changed: 75 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -107,47 +107,48 @@ class Core
107107
# Returns the list of commands supported by this command dispatcher
108108
def commands
109109
{
110-
"?" => "Help menu",
111-
"back" => "Move back from the current context",
112-
"banner" => "Display an awesome metasploit banner",
113-
"cd" => "Change the current working directory",
114-
"connect" => "Communicate with a host",
115-
"color" => "Toggle color",
116-
"exit" => "Exit the console",
117-
"edit" => "Edit the current module with $VISUAL or $EDITOR",
118-
"get" => "Gets the value of a context-specific variable",
119-
"getg" => "Gets the value of a global variable",
120-
"go_pro" => "Launch Metasploit web GUI",
121-
"grep" => "Grep the output of another command",
122-
"help" => "Help menu",
123-
"info" => "Displays information about one or more module",
124-
"irb" => "Drop into irb scripting mode",
125-
"jobs" => "Displays and manages jobs",
126-
"kill" => "Kill a job",
127-
"load" => "Load a framework plugin",
128-
"loadpath" => "Searches for and loads modules from a path",
129-
"popm" => "Pops the latest module off the stack and makes it active",
130-
"pushm" => "Pushes the active or list of modules onto the module stack",
131-
"previous" => "Sets the previously loaded module as the current module",
132-
"quit" => "Exit the console",
133-
"resource" => "Run the commands stored in a file",
134-
"makerc" => "Save commands entered since start to a file",
110+
"?" => "Help menu",
111+
"back" => "Move back from the current context",
112+
"banner" => "Display an awesome metasploit banner",
113+
"cd" => "Change the current working directory",
114+
"connect" => "Communicate with a host",
115+
"color" => "Toggle color",
116+
"exit" => "Exit the console",
117+
"edit" => "Edit the current module with $VISUAL or $EDITOR",
118+
"get" => "Gets the value of a context-specific variable",
119+
"getg" => "Gets the value of a global variable",
120+
"go_pro" => "Launch Metasploit web GUI",
121+
"grep" => "Grep the output of another command",
122+
"help" => "Help menu",
123+
"info" => "Displays information about one or more module",
124+
"irb" => "Drop into irb scripting mode",
125+
"jobs" => "Displays and manages jobs",
126+
"rename_job" => "Rename a job",
127+
"kill" => "Kill a job",
128+
"load" => "Load a framework plugin",
129+
"loadpath" => "Searches for and loads modules from a path",
130+
"popm" => "Pops the latest module off the stack and makes it active",
131+
"pushm" => "Pushes the active or list of modules onto the module stack",
132+
"previous" => "Sets the previously loaded module as the current module",
133+
"quit" => "Exit the console",
134+
"resource" => "Run the commands stored in a file",
135+
"makerc" => "Save commands entered since start to a file",
135136
"reload_all" => "Reloads all modules from all defined module paths",
136-
"route" => "Route traffic through a session",
137-
"save" => "Saves the active datastores",
138-
"search" => "Searches module names and descriptions",
139-
"sessions" => "Dump session listings and display information about sessions",
140-
"set" => "Sets a context-specific variable to a value",
141-
"setg" => "Sets a global variable to a value",
142-
"show" => "Displays modules of a given type, or all modules",
143-
"sleep" => "Do nothing for the specified number of seconds",
144-
"threads" => "View and manipulate background threads",
145-
"unload" => "Unload a framework plugin",
146-
"unset" => "Unsets one or more context-specific variables",
147-
"unsetg" => "Unsets one or more global variables",
148-
"use" => "Selects a module by name",
149-
"version" => "Show the framework and console library version numbers",
150-
"spool" => "Write console output into a file as well the screen"
137+
"route" => "Route traffic through a session",
138+
"save" => "Saves the active datastores",
139+
"search" => "Searches module names and descriptions",
140+
"sessions" => "Dump session listings and display information about sessions",
141+
"set" => "Sets a context-specific variable to a value",
142+
"setg" => "Sets a global variable to a value",
143+
"show" => "Displays modules of a given type, or all modules",
144+
"sleep" => "Do nothing for the specified number of seconds",
145+
"threads" => "View and manipulate background threads",
146+
"unload" => "Unload a framework plugin",
147+
"unset" => "Unsets one or more context-specific variables",
148+
"unsetg" => "Unsets one or more global variables",
149+
"use" => "Selects a module by name",
150+
"version" => "Show the framework and console library version numbers",
151+
"spool" => "Write console output into a file as well the screen"
151152
}
152153
end
153154

@@ -780,6 +781,40 @@ def cmd_irb(*args)
780781
end
781782
end
782783

784+
785+
def cmd_rename_job_help
786+
print_line "Usage: rename_job [ID] [Name]"
787+
print_line
788+
print_line "Example: rename_job 0 \"meterpreter HTTPS special\""
789+
print_line
790+
print_line "Rename a job that's currently acitve."
791+
print_line "You may use the jobs command to see what jobs are available."
792+
print_line
793+
end
794+
795+
def cmd_rename_job(*args)
796+
if args.include?('-h') || args.length != 2 || args[0] !~ /^\d+$/
797+
cmd_rename_job_help
798+
return false
799+
end
800+
801+
job_id = args[0].to_s
802+
job_name = args[1].to_s
803+
804+
unless framework.jobs[job_id]
805+
print_error("Job #{job_id} does not exist.")
806+
return false
807+
end
808+
809+
# This is not respecting the Protected access control, but this seems to be the only way
810+
# to rename a job. If you know a more appropriate way, patches accepted.
811+
framework.jobs[job_id].send(:name=, job_name)
812+
print_status("Job #{job_id} updated")
813+
814+
true
815+
end
816+
817+
783818
def cmd_jobs_help
784819
print_line "Usage: jobs [options]"
785820
print_line

0 commit comments

Comments
 (0)