Always define the detach and ssl_verify commands in the cmds hash

Defining the commands in the cmds hash is necessary for them to be
filtered and then reported to the user as incompatible when applicable.
This moves their special compatibility checks into the actual command
handler.
This commit is contained in:
Spencer McIntyre 2021-02-11 18:59:25 -05:00 committed by Grant Willcox
parent 8a0a56f584
commit 7c51dd0b68
No known key found for this signature in database
GPG Key ID: D35E05C0F2B81E83
1 changed files with 12 additions and 9 deletions

View File

@ -77,20 +77,14 @@ class Console::CommandDispatcher::Core
'migrate' => 'Migrate the server to another process',
'pivot' => 'Manage pivot listeners',
# transport related commands
'detach' => 'Detach the meterpreter session (for http/https)',
'sleep' => 'Force Meterpreter to go quiet, then re-establish session',
'transport' => 'Manage the transport mechanisms',
'get_timeouts' => 'Get the current session timeout values',
'set_timeouts' => 'Set the current session timeout values',
'ssl_verify' => 'Modify the SSL certificate verification setting'
}
if client.passive_service
cmds['detach'] = 'Detach the meterpreter session (for http/https)'
end
if client.passive_service && client.sock.type? == 'tcp-ssl'
cmds['ssl_verify'] = 'Modify the SSL certificate verification setting'
end
if msf_loaded?
cmds['info'] = 'Displays information about a Post module'
end
@ -516,6 +510,10 @@ class Console::CommandDispatcher::Core
# Disconnects the session
#
def cmd_detach(*args)
unless client.passive_service
print_error('The detach command is not applicable with the current transport')
return
end
client.shutdown_passive_dispatcher
shell.stop
end
@ -726,7 +724,7 @@ class Console::CommandDispatcher::Core
@@ssl_verify_opts = Rex::Parser::Arguments.new(
'-e' => [ false, 'Enable SSL certificate verification' ],
'-d' => [ false, 'Disable SSL certificate verification' ],
'-q' => [ false, 'Query the statis of SSL certificate verification' ],
'-q' => [ false, 'Query the status of SSL certificate verification' ],
'-h' => [ false, 'Help menu' ])
#
@ -749,6 +747,11 @@ class Console::CommandDispatcher::Core
return
end
unless client.passive_service && client.sock.type? == 'tcp-ssl'
print_error('The ssl_verify command is not applicable with the current transport')
return
end
query = false
enable = false
disable = false