Skip to content

Commit 54bec33

Browse files
author
RageLtMan
committed
Fix overlap of shell built-in commands with host's
When a shell session is established against a system which offers limited shells, its very common to run into something like "help" being a native command in the target. MSF now intercepts those as built-ins and presents the MSF shell help instead of letting the user see the relevant output from the target. Implement a fix by allowing the user to prepend built-ins with '.' to pass-through execution of the intended command (such as '.help' being executed as 'help') to the target. Testing: Local testing with racadm SSH shell - works as intended
1 parent cb68297 commit 54bec33

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/msf/base/sessions/command_shell.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,13 @@ def run_single(cmd)
621621
end
622622

623623
# Built-in command
624-
if commands.key?(method)
625-
return run_builtin_cmd(method, arguments)
624+
if commands.key?(method) or ( not method.nil? and method[0] == '.' and commands.key?(method[1..-1]))
625+
# Handle overlapping built-ins with actual shell commands by prepending '.'
626+
if method[0] == '.' and commands.key?(method[1..-1])
627+
return shell_write(cmd[1..-1] + command_termination)
628+
else
629+
return run_builtin_cmd(method, arguments)
630+
end
626631
end
627632

628633
# User input is not a built-in command, write to socket directly

0 commit comments

Comments
 (0)