URI ヘルパー
HttpClient 周辺の URI 処理と表示用ヘルパーです。
target_uri / normalize_uri
Section titled “target_uri / normalize_uri”register_options( [ OptString.new('TARGETURI', [true, 'Base path', '/app/']) ])
base = target_uri.path# => "/app/"
uri = normalize_uri(base, 'admin', 'upload.php')# => "/app/admin/upload.php"normalize_uri の規則です。
- 先頭は
/になる。 - 二重スラッシュを潰す。
- 末尾スラッシュは呼び出し側の意図に従う。
send_request_cgi( 'method' => 'GET', 'uri' => normalize_uri(target_uri.path, 'index.php'))full_uri / path_from_uri
Section titled “full_uri / path_from_uri”print_status("Target URL: #{full_uri}")# http://10.10.11.123/app/
path = path_from_uri('https://example.htb/a/b')# "/a/b"request_url / download
Section titled “request_url / download”res = request_url('http://example.htb/file.txt')data = download('http://example.htb/file.bin')絶対 URL から一時的に取りに行く用途です。通常のモジュール通信は send_request_cgi + normalize_uri が基本です。
peer / rhost / rport / vhost
Section titled “peer / rhost / rport / vhost”print_status("#{peer} requesting...")# 10.10.11.123:80
fail_with(Failure::Unreachable, "#{peer} - no response") if res.nil?| メソッド | 内容 |
|---|---|
rhost | 対象 IP / host |
rport | 対象ポート |
peer | host:port 表示 |
vhost | Host ヘッダに使う値 |
ssl / ssl? | TLS の有無 |
encode
Section titled “encode”Rex::Text.uri_encode(cmd, 'hex-all')vars_get / vars_post は default で encode_params: true によりエンコードされます。意図的に生で送りたいときだけ 'encode_params' => false を付けます。

