1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
$opts = array(
'ssl' => array (
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true,
'verify_depth' => 0,
),
'http'=>array(
'follow_location' => false,
'method'=>'${ request if not data else 'POST' }',
'timeout'=>${ connect_timeout },
'ignore_errors' => true,
% if header or cookie or user_agent or data:
'header' => array(
% endif
% for h in header:
% if not (data and (h.title().startswith('Content-Length: '))) and not (user_agent and h.title().startswith('User-Agent: ')):
"${h}",
% endif
% endfor
% if cookie:
"Cookie: ${ cookie }",
% endif
% if user_agent:
"User-Agent: ${ user_agent }",
% endif
% if header or cookie or user_agent or data:
),
% endif
% if data:
'content' => "${ ''.join(data) }",
% endif
)
);
$ctx=stream_context_create($opts);
% if current_vector == 'file_get_contents':
$r = file_get_contents("${url}", false, $ctx);
% elif current_vector == 'fopen_stream_get_contents':
$s = fopen("${url}", 'r', false, $ctx);
$r = '';
if($s) {
$r = stream_get_contents($s);
fclose($s);
}
% elif current_vector == 'fopen_fread':
$h = fopen("${url}", 'r', false, $ctx);
$r = '';
if($h) {
while (!feof($h)) {
$r .= fread($h, 8192);
}
fclose($h);
}
% endif
foreach($http_response_header as $v) {
print("$v\r\n");
}
print("\r\n". $r);
|