コンテンツにスキップ

Msf::Exploit::Remote::SSH は Net::SSH 接続の共通設定を提供します。実装は lib/msf/core/exploit/remote/ssh.rb です。オプションは Msf::Exploit::Remote::SSH::Options 経由で入ります。

include Msf::Exploit::Remote::SSH
# または Options だけ
include Msf::Exploit::Remote::SSH::Options
def ssh_client_defaults
# non_interactive, verify_host_key: :never, proxy factory など
end
factory = ssh_socket_factory

接続例のイメージです。

opts = ssh_client_defaults.merge(
auth_methods: ['password', 'keyboard-interactive'],
port: datastore['RPORT'],
password: pass
)
ssh = Net::SSH.start(ip, user, opts)
ssh.exec!('id')

AuthBrute + Scanner + SSH Options。成功を create_credential_and_login し、必要ならセッションを作る。

実在例: modules/auxiliary/scanner/ssh/ssh_login.rb

認証後に exec! で CmdStager 断片やペイロードを流す。

実在例: modules/exploits/multi/ssh/sshexec.rb(execute_command が ssh_socket.exec!)

target によっては generic/ssh/interact のようなペイロード / セッションで対話チャネルを取ります。運用手順は SSH / WinRM ログイン も参照してください。

オプション意味
RPORT通常 22
SSH_TIMEOUT / SSH_DEBUG / SSH_IDENTOptions mixin 側(名称は版で変化し得る)
KEY_PATH / PRIVATE_KEY公開鍵認証(モジュールによる)

show options / show advanced で実際の名前を確認します。