Module: Msf::Sessions::UnixEscaping
- Included in:
- CommandShellUnix, CommandShellUnix
- Defined in:
- lib/msf/base/sessions/unix_escaping.rb
Instance Method Summary collapse
-
#escape_arg(arg) ⇒ Object
Escape an individual argument per Unix shell rules.
- #shell_command_token(cmd, timeout = 10) ⇒ Object
-
#to_cmd(cmd_and_args) ⇒ Object
Convert the executable and argument array to a command that can be run in this command shell.
Instance Method Details
#escape_arg(arg) ⇒ Object
Escape an individual argument per Unix shell rules
17 18 19 20 21 22 23 24 25 |
# File 'lib/msf/base/sessions/unix_escaping.rb', line 17 def escape_arg(arg) quote_requiring = ['\\', '`', '(', ')', '<', '>', '&', '|', ' ', '@', '"', '$', ';'] result = CommandShell._glue_cmdline_escape(arg, quote_requiring, "'", "\\'", "'") if result == '' result = "''" end result end |
#shell_command_token(cmd, timeout = 10) ⇒ Object
3 4 5 |
# File 'lib/msf/base/sessions/unix_escaping.rb', line 3 def shell_command_token(cmd,timeout = 10) shell_command_token_unix(cmd,timeout) end |
#to_cmd(cmd_and_args) ⇒ Object
Convert the executable and argument array to a command that can be run in this command shell
9 10 11 12 13 |
# File 'lib/msf/base/sessions/unix_escaping.rb', line 9 def to_cmd(cmd_and_args) escaped = cmd_and_args.map { |arg| escape_arg(arg) } escaped.join(' ') end |