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!