A simple method for using curl to forge an IP address in PHP

Source: Internet
Author: User
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.

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.