Home  >  Article  >  Backend Development  >  Detailed explanation of php using CURL to forge IP and source examples, curl forgery_PHP tutorial

Detailed explanation of php using CURL to forge IP and source examples, curl forgery_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:09:40795browse

Detailed explanation of php using CURL to forge IP and source examples, curl forgery

The example in this article describes how PHP uses CURL to forge IP and source. Share it with everyone for your reference. The specific analysis is as follows:

Fake IP source is a very simple thing for PHP. We only need to use PHP's curl to realize the function of forging IP source. You can write the IP address as you like.

index.php example code is as follows:

Copy code The code is as follows:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost/curl.php");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:8.8.8.8', 'CLIENT-IP:8.8.8.8'));//IP
curl_setopt($ch, CURLOPT_REFERER, "http://www.bkjia.com/ "); // Origin
curl_setopt($ch, CURLOPT_HEADER, 1);
$out = curl_exec($ch);
curl_close($ch);

The curl.php code is as follows:
Copy code The code is as follows:
function getClientIp() {
If (!emptyempty($_SERVER["HTTP_CLIENT_IP"]))
$ip = $_SERVER["HTTP_CLIENT_IP"];
​ else if (!emptyempty($_SERVER["HTTP_X_FORWARDED_FOR"]))
          $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
else if (!emptyempty($_SERVER["REMOTE_ADDR"]))
$ip = $_SERVER["REMOTE_ADDR"];
else
          $ip = "err";
Return $ip;
}
echo "IP: " . getClientIp() . "";
echo "referer: " . $_SERVER["HTTP_REFERER"];

Use index.php to request curl.php, output result:

IP:8.8.8.8 referer:http://www.bkjia.com

The forgery is successful. Does this provide a good solution for collecting friends to change IP? Of course, friends who want to prevent being swiped should also pay attention.

Supplement:

The CURL function library (Client URL Library Function) in PHP is as follows:

curl_close — close a curl session

curl_copy_handle — Copy all contents and parameters of a curl connection resource

curl_errno — Returns a numeric number containing error information for the current session

curl_error — Returns a string containing error information for the current session

curl_exec — execute a curl session

curl_getinfo — Get information about a curl connection resource handle

curl_init — initialize a curl session

curl_multi_add_handle — Add individual curl handle resources to a curl batch session

curl_multi_close — close a batch handle resource

curl_multi_exec — parse a curl batch handle

curl_multi_getcontent — Returns the text stream of the obtained output

curl_multi_info_read — Get the relevant transmission information of the currently parsed curl

curl_multi_init — Initialize a curl batch handle resource

curl_multi_remove_handle — remove a handle resource in the curl batch handle resource

curl_multi_select — Get all the sockets associated with the cURL extension, which can then be "selected"

curl_setopt_array — Set session parameters for a curl in the form of an array

curl_setopt — Set session parameters for a curl

curl_version — Get curl-related version information

The curl_init() function is used to initialize a curl session. The only parameter of the curl_init() function is optional and represents a URL address.

The curl_exec() function is used to execute a curl session, and the only parameter is the handle returned by the curl_init() function.

The curl_close() function is used to close a curl session. The only parameter is the handle returned by the curl_init() function.

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/943414.htmlTechArticleDetailed explanation of php using CURL to forge IP and source examples, curl forgery This article tells the example of php using CURL to forge IP and source method. Share it with everyone for your reference. The specific analysis is as follows: Forgery...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn