PHP uses curl to implement the method of spoofed IP source _php skill

Source: Internet
Author: User
Tags curl

The example of this article describes the way in which PHP uses Curl to implement spoofed IP sources. Can be achieved to forge IP sources, counterfeit domain names, counterfeit user information, to share for everyone's reference. The implementation methods are as follows:

Define spoofed user browser information http_user_agent

Copy Code code as follows:
$binfo =array (' mozilla/4.0 compatible; MSIE 8.0; Windows NT 5.1; trident/4.0. NET CLR 2.0.50727; infopath.2; asktbptv/5.17.0.25589; Alexa Toolbar) ', ' mozilla/5.0 (Windows NT 5.1; rv:22.0) gecko/20100101 firefox/22.0 ', ' mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; trident/4.0;. net4.0c; Alexa Toolbar) ', ' mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ', $_server[' http_user_agent ']);
123.125.68.*
125.90.88.*

Define spoofed IP source segment, here I'm looking for the IP address of Baidu
Copy Code code as follows:
$cip = ' 123.125.68. ' Mt_rand (0,254);
$XIP = ' 125.90.88. ' Mt_rand (0,254);
$header = Array (
' Client-ip: '. $cip,
' X-forwarded-for: '. $XIP,
);

Using curl to start sending bogus information to the server
Copy Code code as follows:
function Getimgs ($url, $userinfo, $header)
{
$ch = Curl_init ();
$timeout = 5;
curl_setopt ($ch, Curlopt_url, "$url");
curl_setopt ($ch, Curlopt_httpheader, $header);
curl_setopt ($ch, Curlopt_referer, "http://www.baidu.com/");
curl_setopt ($ch, Curlopt_returntransfer, 1);
curl_setopt ($ch, Curlopt_useragent, "$userinfo");
curl_setopt ($ch, Curlopt_connecttimeout, $timeout);
$contents = curl_exec ($ch);
Curl_close ($ch);
return $contents;
}

Get the data and we'll save it.
Copy Code code as follows:
function Saveimgs ($handle)
{
$fp = fopen (' a.jpg ', "w");
Fwrite ($fp, $handle);
Unset ($FP);
Unset ($handle);
}

Testing spoofed IP instances
Copy Code code as follows:
$url = ' yun_qi_img/logo.gif ';
$u = $binfo [Mt_rand (0,3)];
Saveimgs (Getimgs ($url, $u, $header));

So in your current directory to save the success of a file A.jpg file, I can now see the server log is not our customized user information?

192.168.1.108--[22/jul/2013:10:29:37 +0800] "get/test.php http/1.1 1244"-"" mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; trident/4.0. NET CLR 2.0.50727; infopath.2; asktbptv/5.17.0.25589; Alexa Toolbar) "
192.168.1.108--[22/jul/2013:10:29:37 +0800] "get/http/1.1" 40538 "http://www.baidu.com/" "mozilla/4.0 (Compatible ; MSIE 8.0; Windows NT 5.1; trident/4.0;. net4.0c; Alexa Toolbar) "
192.168.1.108--[22/jul/2013:10:29:37 +0800] "get/test.php http/1.1 1244"-"" mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; trident/4.0. NET CLR 2.0.50727; infopath.2; asktbptv/5.17.0.25589; Alexa Toolbar) "
192.168.1.108--[22/jul/2013:10:29:37 +0800] "get/http/1.1" 40538 "http://www.baidu.com/" "mozilla/5.0" (Windows NT 5.1; rv:22.0) gecko/20100101 firefox/22.0 "

See it, exactly, ah, just the IP address I did not test out, this use of PHP to obtain an IP address will show me fake IP address.

I hope this article will help you with your PHP program design.

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.