SSH
Msf::Exploit::Remote::SSH は Net::SSH 接続の共通設定を提供します。実装は lib/msf/core/exploit/remote/ssh.rb です。オプションは Msf::Exploit::Remote::SSH::Options 経由で入ります。
include
Section titled “include”include Msf::Exploit::Remote::SSH# または Options だけinclude Msf::Exploit::Remote::SSH::Options主要ヘルパー
Section titled “主要ヘルパー”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')ログイン scanner(auxiliary)
Section titled “ログイン scanner(auxiliary)”AuthBrute + Scanner + SSH Options。成功を create_credential_and_login し、必要ならセッションを作る。
実在例: modules/auxiliary/scanner/ssh/ssh_login.rb
コマンド実行 exploit
Section titled “コマンド実行 exploit”認証後に exec! で CmdStager 断片やペイロードを流す。
実在例: modules/exploits/multi/ssh/sshexec.rb(execute_command が ssh_socket.exec!)
interact セッション
Section titled “interact セッション”target によっては generic/ssh/interact のようなペイロード / セッションで対話チャネルを取ります。運用手順は SSH / WinRM ログイン も参照してください。
オプション例
Section titled “オプション例”| オプション | 意味 |
|---|---|
RPORT | 通常 22 |
SSH_TIMEOUT / SSH_DEBUG / SSH_IDENT | Options mixin 側(名称は版で変化し得る) |
KEY_PATH / PRIVATE_KEY | 公開鍵認証(モジュールによる) |
show options / show advanced で実際の名前を確認します。

