<?php
header("content-type:text/html;charset=utf-8");
highlight_file(__FILE__);
function GetFile($host, $port, $link)
{
$link = str_replace('..','',$link);
// $link = str_replace('./','',$link);
$link = str_replace('conn','',$link);
//fsockopen() 将返回一个文件句柄,之后可以被其他文件类函数调用
//(例如: fgets() , fgetss() ,
// fwrite() , fclose() 还有 feof() )。如果调用失败,将返回 FALSE 。
$fp = fsockopen($host, intval($port), $errno, $errstr, 30);
if (!$fp) {
echo "$errstr (error number $errno) \n";
} else {
$out = "GET $link HTTP/1.1\r\n";
$out .= "Host: $host\r\n";
$out .= "Connection: Close\r\n\r\n";
$out .= "\r\n";
fwrite($fp, $out);
$contents = '';
while (! feof($fp)) {
$contents .= fgets($fp, 1024);
}
fclose($fp);
return $contents;
}
}
$host = $_GET['host'];
$port = $_GET['port'];
$link = $_GET['link'];
echo GetFile($host, $port, $link);
?>
Warning: fsockopen(): unable to connect to 127.0.0.1:1234 (Connection refused) in /home/wwwroot/www.nanhack.com/payload/ssrf/submit/ssrf2.php on line 12
Connection refused (error number 111)