MCPcopy
hub / github.com/owtf/owtf / get_modified_shell_cmd

Method get_modified_shell_cmd

owtf/shell/base.py:101–125  ·  view source on GitHub ↗

Returns the modified shell command to run :param command: Command to run :type command: `str` :param plugin_output_dir: Path to the plugin output directory :type plugin_output_dir: `str` :return: Modified command :rtype: `str`

(self, command, plugin_output_dir)

Source from the content-addressed store, hash-verified

99 return multi_replace_dict(text, {" ": "\ ", "(": "\(", ")": "\)"})
100
101 def get_modified_shell_cmd(self, command, plugin_output_dir):
102 """Returns the modified shell command to run
103
104 :param command: Command to run
105 :type command: `str`
106 :param plugin_output_dir: Path to the plugin output directory
107 :type plugin_output_dir: `str`
108 :return: Modified command
109 :rtype: `str`
110 """
111 self.refresh_replacements()
112 new_cmd = "cd {};{}".format(
113 self.escape_shell_path(plugin_output_dir),
114 multi_replace_dict(command, self.dynamic_replacements),
115 )
116 new_cmd = multi_replace_dict(
117 new_cmd,
118 {
119 "@@@USER_AGENT@@@": USER_AGENT,
120 "@@@INBOUND_PROXY_IP@@@": INBOUND_PROXY_IP,
121 "@@@INBOUND_PROXY_PORT@@@": INBOUND_PROXY_PORT,
122 },
123 )
124 self.old_cmds[new_cmd] = command
125 return new_cmd
126
127 def can_run_cmd(self, session, command):
128 """Check if command is already in place to run

Callers 1

RunCommandMethod · 0.80

Calls 4

refresh_replacementsMethod · 0.95
escape_shell_pathMethod · 0.95
multi_replace_dictFunction · 0.90
formatMethod · 0.80

Tested by

no test coverage detected