URI Helpers
URI handling and display helpers around HttpClient.
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 follows these rules:
- The path starts with
/. - Duplicate slashes are collapsed.
- The caller’s intent determines whether the path ends with a slash.
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')Use these methods to fetch temporarily from an absolute URL. For normal module requests, use send_request_cgi with 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?| Method | Description |
|---|---|
rhost | Target IP address or host |
rport | Target port |
peer | Display as host:port |
vhost | Value for the Host header |
ssl / ssl? | Whether TLS is in use |
encode
Section titled “encode”Rex::Text.uri_encode(cmd, 'hex-all')vars_get and vars_post encode parameters by default through encode_params: true. Add 'encode_params' => false only when you intentionally need to send raw values.

