How to use curl in PHP to forge IP

Source: Internet
Author: User
Tags how to use curl http post
This article mainly introduces the use of curl in PHP to forge IP in a simple way, the author also mentioned some of the related defects, the need for friends can refer to the following

About Curl:
Curl is a file transfer tool that works with URL syntax in the command line mode. It supports many protocols: FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE, and LDAP. Curl also supports HTTPS authentication, HTTP POST method, HTTP put method, FTP upload, HTTP upload, proxy server, cookies, username/password Authentication, download file breakpoint continuation and so on, the function is very powerful.
Features that are commonly used in PHP:
1. Realize remote acquisition and acquisition of content
2, the implementation of PHP Web version of the FTP upload download
3. Realize the simulation landing
4. Interface docking (API), data transmission, etc.
5. Realization of analog cookies, etc.

PHP uses the Curl feature
PHP does not support the Curl feature by default and requires this feature to be turned on in php.ini

; extension= php_curl.dll//first remove the preceding; semicolon, and restart Apache/iis

Using Curl to forge IP

I found the IP copy into the txt file, then sed and awk dealt with it and shared my awk processing script:

#!/bin/awk-f      #运行前   BEGIN {     FS = "";     Count = 0;   }      #运行中   {     Iparr[count + +] = $;   }      #运行后   END {     printf ("<?php\n");     printf ("$iparr = array (\ n");     for (i = 0; i < count; i + +) {       printf ("'%s ' = '%s ', \ n", Iparr[i], iparr[i]);     }     printf ("); \ n");   }

Curl uses

<?php   require_once dirname (__file__). "/iplib.php";      $req _url = "test.com";      foreach ($iparr as $forward = + $cip) {          $ch = Curl_init ();          curl_setopt ($ch, Curlopt_url, $req _url);     curl_setopt ($ch, Curlopt_httpheader, Array (         "x-forwarded-for: $forward",         "Client-ip: $cip"     ));     curl_setopt ($ch, Curlopt_referer, ' http://blog.csdn.net/');     curl_setopt ($ch, Curlopt_header, 1);          Curl_exec ($ch);          Curl_close ($ch);   }

Defects
Many server-side generally use $_server[' remote_addr ' to get the real IP of the client, this is the address that has been decided on the transport layer, can not be modified by curl, well, it seems that I did not help friends do this thing, but still record

The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!

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.