熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> PHP編程 >> 正文

PHP用CURL偽造IP和來源

2022-06-13   來源: PHP編程 

  php代碼

  $ch = curl_init();

  curl_setopt($ch CURLOPT_URL "

  curl_setopt($ch CURLOPT_HTTPHEADER array(XFORWARDEDFOR: CLIENTIP:)); //構造IP

  curl_setopt($ch CURLOPT_REFERER "構造來路

  curl_setopt($ch CURLOPT_HEADER );

  $out = curl_exec($ch);

  curl_close($ch);

  php代碼如下

  function getClientIp() {

  if (!empty($_SERVER["HTTP_CLIENT_IP"]))

  $ip = $_SERVER["HTTP_CLIENT_IP"];

  else if (!empty($_SERVER["HTTP_X_FORWARDED_FOR"]))

  $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];

  else if (!empty($_SERVER["REMOTE_ADDR"]))

  $ip = $_SERVER["REMOTE_ADDR"];

  else

  $ip = "err";

  return $ip;

  }

  echo "IP: " getClientIp() "";

  echo "referer: " $_SERVER["HTTP_REFERER"];


From:http://tw.wingwit.com/Article/program/PHP/201311/21136.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.