コンテンツにスキップ

リダイレクトと生リクエスト

リダイレクト追従と、send_request_cgi では足りないリクエストです。

res = send_request_cgi!(
{
'method' => 'GET',
'uri' => normalize_uri(target_uri.path, 'old')
},
20, # timeout
3 # redirect_depth
)

30x のとき Location を追います。opts['redirect_uri'] に辿った URI が入ります。

reconfig_redirect_opts! は POST を GET に変え、data / vars_post を空にします。ログイン POST のあとに「POST のまま追いたい」要件には向きません。その場合は自分で Location を読んで次の send_request_cgi を組み立てます。

res = send_request_cgi(...)
if res && res.redirect?
loc = res.redirection
res = send_request_cgi(
'method' => 'GET',
'uri' => loc.path
)
end

仕様を外す、または HTTP 以外に見せかけるときに使います。

send_request_raw({
'method' => 'DESCRIBE',
'proto' => 'RTSP',
'version' => '1.0',
'uri' => '/' + ('../' * 560) + "\xcc\xcc\x90\x90" + '.smi'
})
send_request_raw(
'method' => 'GET',
'uri' => '/index.php',
'headers' => {
'Host' => "x\r\nX-Injected: 1"
}
)

query / フォームの組み立てが要る通常用途は send_request_cgi 側に戻します。

# cgi の第3引数
send_request_cgi({ 'uri' => '/' }, 20, false) # 切断しない
send_request_cgi({ 'uri' => '/next' }, 20, true)

send_request_raw の default disconnect は false です。keep-alive や findsock 系で接続を残したいときに差が出ます。

send_request_cgi(
'method' => 'GET',
'uri' => '/health',
'rhost' => '10.10.11.200',
'rport' => 8080,
'SSL' => false,
'vhost' => 'internal.htb'
)