Demo entry 6350551

111

   

Submitted by anonymous on Mar 13, 2017 at 02:51
Language: PHP. Code size: 660 Bytes.

/**
程序使用fsockopen函数从用户指定的URL处获取数据,同上例,传入的参数是从外界获取的且不经检查,同样存在安全隐患
**/
$host=$_GET['host'];
$port=$_GET['port']?intval($_GET['port']):80;
$link=$_GET['link'];
function GetFile($host,$port,$link) 
{ 
  $fp = fsockopen($host, $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; 
  } 
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).