How to fake IP using curl in PHP

不言
Release: 2023-04-01 09:00:02
Original
1794 people have browsed it

这篇文章主要介绍了PHP中使用curl伪造IP的简单方法,作者也提到了相关的一些缺陷,需要的朋友可以参考下

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(" '%s',\n", iparr[i], iparr[i]); 
    } 
    printf(");\n"); 
  }
Copy after login

CURL使用

 $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进行修改,好吧,貌似我也没帮朋友做成功这件事情,不过还是记录一下

以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注PHP中文网!

相关推荐:

PHP CURL CURLOPT的参数说明

The above is the detailed content of How to fake IP using curl in PHP. For more information, please follow other related articles on the PHP Chinese website!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!