This article mainly introduces the simple method of using curl to forge IP addresses in PHP. The author also mentions some related defects. For more information, see
Curl introduction:
Curl is a file transfer tool that uses the URL syntax to work 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, http put, FTP upload, HTTP upload, proxy server, cookies, user name/password authentication, resumable download of downloaded files, and so on, powerful functions.
Common functions implemented by curl in PHP:
1. remote acquisition and collection of content
2. implement FTP upload and download for PHP web edition
3. implement simulated login
4. interface interconnection (API) and data transmission
5. implement Cookie simulation.
PHP uses the CURL function
By default, PHP does not support the CURL function. you must enable this function in PHP. ini.
; Extension = php_curl.dll // first remove the front; semicolon, and restart Apache/IIS
Use curl to forge an IP address
Copy the IP address I found to the txt file, and sed and awk processed it. I will share my awk processing script:
#! /Bin/awk-f # BEGIN {FS = ""; count = 0 ;}# running {iparr [count ++] = $0 ;} # 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 usage
<?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 servers generally use $ _ SERVER ['remote _ ADDR '] to obtain the client's real ip address, which is determined at the transport layer and cannot be modified through CURL, well, it seems that I have not helped my friends do this thing successfully, but record it.