Home > Backend Development > PHP Tutorial > PHP中使用curl伪造IP的简单方法_PHP

PHP中使用curl伪造IP的简单方法_PHP

WBOY
Release: 2016-05-30 08:47:16
Original
774 people have browsed it

curl简介:
curl是一个利用URL语法在命令行方式下工作的文件传输工具。它支持很多协议:FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE 以及 LDAP。curl同样支持HTTPS认证,HTTP POST方法, HTTP PUT方法, FTP上传, HTTP上传, 代理服务器, cookies, 用户名/密码认证, 下载文件断点续传等等,功能十分强大。
PHP中常用curl实现的功能:
   1、实现远程获取和采集内容
   2、实现PHP 网页版的FTP上传下载
   3、实现模拟登陆
   4、实现接口对接(API),数据传输等
   5、实现模拟Cookie等

   PHP使用CURL功能
默认情况下PHP是不支持CURL功能的,需要在PHP.ini中开启该功能

; extension= php_curl.dll//首先去除前面的;分号,并重启Apache/IIS 
Copy after login

使用curl伪造IP


我找到的IP拷贝到txt文件里,然后sed和awk处理了一下,分享一下我的awk处理脚本:

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

CURL使用

<&#63;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); 
  } 
Copy after login


缺陷
很多服务器端一般都采用了$_SERVER['REMOTE_ADDR']来获取客户端的真实ip,这是在传输层就已经决定的地址,无法通过CURL进行修改,好吧,貌似我也没帮朋友做成功这件事情,不过还是记录一下

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template