コンテンツにスキップ

URI ヘルパー

HttpClient 周辺の 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 の規則です。

  1. 先頭は / になる。
  2. 二重スラッシュを潰す。
  3. 末尾スラッシュは呼び出し側の意図に従う。
send_request_cgi(
'method' => 'GET',
'uri' => normalize_uri(target_uri.path, 'index.php')
)
print_status("Target URL: #{full_uri}")
# http://10.10.11.123/app/
path = path_from_uri('https://example.htb/a/b')
# "/a/b"
res = request_url('http://example.htb/file.txt')
data = download('http://example.htb/file.bin')

絶対 URL から一時的に取りに行く用途です。通常のモジュール通信は send_request_cgi + normalize_uri が基本です。

print_status("#{peer} requesting...")
# 10.10.11.123:80
fail_with(Failure::Unreachable, "#{peer} - no response") if res.nil?
メソッド内容
rhost対象 IP / host
rport対象ポート
peerhost:port 表示
vhostHost ヘッダに使う値
ssl / ssl?TLS の有無
Rex::Text.uri_encode(cmd, 'hex-all')

vars_get / vars_post は default で encode_params: true によりエンコードされます。意図的に生で送りたいときだけ 'encode_params' => false を付けます。