HttpClient
Msf::Exploit::Remote::HttpClient は HTTP(S) クライアント機能の中心です。実装は lib/msf/core/exploit/remote/http_client.rb です。
include
Section titled “include”include Msf::Exploit::Remote::HttpClient自動で入る主なオプションです。
| オプション | 意味 |
|---|---|
RHOST / RPORT | 接続先 |
VHOST | Host ヘッダ / 仮想ホスト |
SSL | TLS の有無 |
Proxies | プロキシ |
UserAgent | User-Agent |
HttpUsername / HttpPassword | クライアント認証用 |
HttpClientTimeout | タイムアウト |
HttpTrace | 生リクエスト/レスポンス表示 |
DOMAIN | NTLM / Kerberos 用 |
HTTP::* | evasion 系 |
主要 API
Section titled “主要 API”| メソッド | 用途 |
|---|---|
send_request_cgi(opts, timeout=20, disconnect=true) | CGI 互換リクエスト |
send_request_raw(opts, timeout=20, disconnect=false) | 生 / 仕様外リクエスト |
send_request_cgi!(opts, timeout=20, redirect_depth=1) | リダイレクト追従 |
basic_auth(user, pass) | Basic 用 Authorization 値 |
normalize_uri(*parts) | パス結合 |
target_uri | TARGETURI の URI オブジェクト |
full_uri | 絶対 URL 文字列 |
connect / disconnect | 接続の明示管理 |
rhost / rport / peer / vhost / ssl | 接続情報ヘルパー |
http_fingerprint | Server / 指紋 |
def check res = send_request_cgi( 'method' => 'GET', 'uri' => normalize_uri(target_uri.path, 'index.php') ) return CheckCode::Unknown('no response') if res.nil? return CheckCode::Appears if res.body.include?('ExampleApp') CheckCode::Safeend# 接続を再利用したいときconnectres1 = send_request_cgi('uri' => '/', 'method' => 'GET')res2 = send_request_cgi('uri' => '/admin', 'method' => 'GET')disconnect# デバッグ# set HttpTrace true# set HttpTraceHeadersOnly true| パターン | やり方 |
|---|---|
| 単発 GET | send_request_cgi('method'=>'GET', 'uri'=>...) |
| フォームログイン継続 | keep_cookies: true のあと通常リクエスト |
| Basic | 'authorization' => basic_auth(u, p) |
| JSON API | 'ctype'=>'application/json', 'data'=>hash.to_json |
| multipart アップロード | vars_form_data または Rex::MIME::Message |
| リダイレクト追従 | send_request_cgi! |
| 仕様外 HTTP | send_request_raw |
| 接続再利用 | connect → 複数リクエスト → disconnect |
| 指紋 | http_fingerprint / HttpFingerprint 定数 |
リクエスト opts の全パターンは send_request_cgi を参照してください。URI ヘルパーは URI ヘルパー です。

