PHP Curl Spoofing IP and source implementation program _php Tutorial

Source: Internet
Author: User
Forged IP Source for PHP is a very simple thing, we just use PHP curl can be used to achieve fake IP source Oh, IP address you can write freely oh.

Instance

The code is as follows Copy Code

$ch = Curl_init ();
curl_setopt ($ch, Curlopt_url, "http://localhost/2.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.hzhuti.com/"); Antecedents
curl_setopt ($ch, Curlopt_header, 1);
$out = curl_exec ($ch);
Curl_close ($ch);

2.php Code:

copy code

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"];

Request 2.php with 1.php, output result:

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

Forgery success, this is not to collect friends to provide a very good solution for IP!! Of course, the anti-brush friends should also pay attention to

Curl Libraries in PHP (Client URL library function)

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.


http://www.bkjia.com/PHPjc/444658.html www.bkjia.com true http://www.bkjia.com/PHPjc/444658.html techarticle forged IP Source for PHP is a very simple thing, we just use PHP curl can be used to achieve fake IP source Oh, IP address you can write freely oh. The instance code is copied code as follows ...

  • 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.