PHP uses curl to forge IP and source instances in detail, Curl Forge _php Tutorial

Source: Internet
Author: User

PHP uses curl to forge IP and source instances in detail, Curl Forge


This example describes how PHP uses curl to forge IP and source. Share to everyone for your reference. The specific analysis is as follows:

Fake IP source for PHP is a very simple thing, we just take advantage of PHP's curl can realize the function of fake IP source, IP address you can write casually.

The index.php instance code is as follows:
Copy the Code code 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/"); Antecedents
curl_setopt ($ch, Curlopt_header, 1);
$out = curl_exec ($ch);
Curl_close ($ch);
The curl.php code is as follows:
Copy the Code code 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"];
Request curl.php with index.php, output result:

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

Forgery success, this is not to collect friends to provide a good solution for IP, of course, anti-brush friends should also pay attention to.

Add:

The Curl function library in PHP (Client URL library function) is as follows:

curl_close-closing a Curl session

curl_copy_handle-Copy all the contents and parameters of a Curl connection resource

curl_errno-returns a numeric number that contains the current session error information

curl_error-returns a string containing the current session error message

Curl_exec-performing a Curl session

Curl_getinfo-gets the information for a Curl connection resource handle

curl_init-initialization of a curl session

curl_multi_add_handle-Adding a separate curl handle resource to a curl batch session

curl_multi_close-closing a batch handle resource

curl_multi_exec-parsing a Curl batch handle

curl_multi_getcontent-returns the text stream of the obtained output

Curl_multi_info_read-Gets the related transfer information for the currently resolved curl

curl_multi_init-initializing a curl batch handle resource

curl_multi_remove_handle-removing a handle resource from the Curl batch handle resource

Curl_multi_select-get all the sockets associated with the CURL extension, which can and be "selected"

curl_setopt_array-set session parameters as an array for a curl

curl_setopt-setting session parameters for a curl

curl_version-getting the version information about Curl

The Curl_init () function Initializes a curl session, and the only parameter to the Curl_init () function is optional, representing a URL address.

The function of the curl_exec () function is to perform a curl session, and the only argument is the handle returned by the Curl_init () function.

The function of the Curl_close () function is to close a curl session, and the only argument is the handle returned by the Curl_init () function.

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/943414.html www.bkjia.com true http://www.bkjia.com/PHPjc/943414.html techarticle PHP uses curl to forge IP and source instances in detail, curl forgery This article describes the way PHP uses curl to forge IP and source. Share to everyone for your reference. The specific analysis is as follows: Forgery ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.