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 option for running cmd_execute in a subshell #15540

Merged
merged 1 commit into from
Aug 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Console::CommandDispatcher::Stdapi::Sys
"-d" => [ true, "The 'dummy' executable to launch when using -m." ],
"-t" => [ false, "Execute process with currently impersonated thread token"],
"-k" => [ false, "Execute process on the meterpreters current desktop" ],
"-z" => [ false, "Execute process in a subshell" ],
"-s" => [ true, "Execute process in a given session as the session user" ])

#
Expand Down Expand Up @@ -201,6 +202,7 @@ def cmd_execute(*args)
cmd_args = nil
cmd_exec = nil
use_thread_token = false
subshell = false

@@execute_opts.parse(args) { |opt, idx, val|
case opt
Expand Down Expand Up @@ -228,6 +230,8 @@ def cmd_execute(*args)
use_thread_token = true
when "-s"
session = val.to_i
when "-z"
subshell = true
end
}

Expand All @@ -244,6 +248,7 @@ def cmd_execute(*args)
'Session' => session,
'Hidden' => hidden,
'InMemory' => (from_mem) ? dummy_exec : nil,
'Subshell' => subshell,
'UseThreadToken' => use_thread_token)

print_line("Process #{p.pid} created.")
Expand Down Expand Up @@ -405,7 +410,7 @@ def pty_shell(sh_path)
cmd.prepend('env TERM=xterm HISTFILE= ')

print_status(cmd)
cmd_execute('-f', cmd, '-c', '-i')
cmd_execute('-f', cmd, '-c', '-i', '-z')

true
end
Expand Down