Home Backend Development PHP Tutorial The function of using curl to forge IP in PHP

The function of using curl to forge IP in PHP

Jun 07, 2018 pm 05:07 PM
curl ip

本篇文章主要介绍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("<?php\n"); 
    printf("$iparr = array(\n"); 
    for (i = 0; i < count; i ++) { 
      printf("&#39;%s&#39; => &#39;%s&#39;,\n", iparr[i], iparr[i]); 
    } 
    printf(");\n"); 
  }
Copy after login

CURL使用

<?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, &#39;http://blog.csdn.net/&#39;); 
    curl_setopt($ch, CURLOPT_HEADER, 1); 
     
    curl_exec($ch); 
     
    curl_close($ch); 
  }
Copy after login


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

总结:以上就是本篇文的全部内容,希望能对大家的学习有所帮助。

相关推荐:

实例详解php中serialize()与unserialize()函数

php的ob缓存机制实现页面静态化的方法详解

实现form自动提交的方法详解

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

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How do websites set black/whitelist IP restrictions and country and city IP access restrictions through nginx? How do websites set black/whitelist IP restrictions and country and city IP access restrictions through nginx? Jun 01, 2023 pm 05:27 PM

1. Black/white list IP restricted access configuration nginx There are several ways to configure black and white lists. Here are only two commonly used methods. 1. The first method: allow, denydeny and allow instructions belong to ngx_http_access_module. nginx loads this module by default, so it can be used directly. This method is the simplest and most direct. The setting is similar to the firewall iptable. How to use: Add directly to the configuration file: #Whitelist settings, followed by allow is accessible IPlocation/{allow123.13.123.12;allow23.53.32.1/100;denyall;}#Blacklist settings,

What does binding ip and mac mean? What does binding ip and mac mean? Mar 09, 2023 pm 04:44 PM

IP and mac binding refers to associating a specific IP address with a specific MAC address, so that only the device using the MAC address can use the IP address for network communication. Binding ip and mac can prevent the IP address of the bound host from being spoofed. Prerequisites: 1. The MAC address is unique and cannot be spoofed; it can only be bound to hosts on the network directly connected to the router (that is, The host's gateway is on the router).

How to realize the mutual conversion between CURL and python requests in python How to realize the mutual conversion between CURL and python requests in python May 03, 2023 pm 12:49 PM

Both curl and Pythonrequests are powerful tools for sending HTTP requests. While curl is a command-line tool that allows you to send requests directly from the terminal, Python's requests library provides a more programmatic way to send requests from Python code. The basic syntax for converting curl to Pythonrequestscurl command is as follows: curl[OPTIONS]URL When converting curl command to Python request, we need to convert the options and URL into Python code. Here is an example curlPOST command: curl-XPOST https://example.com/api

From start to finish: How to use php extension cURL to make HTTP requests From start to finish: How to use php extension cURL to make HTTP requests Jul 29, 2023 pm 05:07 PM

From start to finish: How to use php extension cURL for HTTP requests Introduction: In web development, it is often necessary to communicate with third-party APIs or other remote servers. Using cURL to make HTTP requests is a common and powerful way. This article will introduce how to use PHP to extend cURL to perform HTTP requests, and provide some practical code examples. 1. Preparation First, make sure that php has the cURL extension installed. You can execute php-m|grepcurl on the command line to check

Tutorial on updating curl version under Linux! Tutorial on updating curl version under Linux! Mar 07, 2024 am 08:30 AM

To update the curl version under Linux, you can follow the steps below: Check the current curl version: First, you need to determine the curl version installed in the current system. Open a terminal and execute the following command: curl --version This command will display the current curl version information. Confirm available curl version: Before updating curl, you need to confirm the latest version available. You can visit curl's official website (curl.haxx.se) or related software sources to find the latest version of curl. Download the curl source code: Using curl or a browser, download the source code file for the curl version of your choice (usually .tar.gz or .tar.bz2

PHP8.1 released: Introducing curl for concurrent processing of multiple requests PHP8.1 released: Introducing curl for concurrent processing of multiple requests Jul 08, 2023 pm 09:13 PM

PHP8.1 released: Introducing curl for concurrent processing of multiple requests. Recently, PHP officially released the latest version of PHP8.1, which introduced an important feature: curl for concurrent processing of multiple requests. This new feature provides developers with a more efficient and flexible way to handle multiple HTTP requests, greatly improving performance and user experience. In previous versions, handling multiple requests often required creating multiple curl resources and using loops to send and receive data respectively. Although this method can achieve the purpose

How to set directory whitelist and ip whitelist in nginx How to set directory whitelist and ip whitelist in nginx May 18, 2023 pm 03:52 PM

1. Set the directory whitelist: There is no restriction on the specified request path. If there is no restriction on the request path to the api directory, it can be written as server{location/app{proxy_passhttp://192.168.1.111:8095/app ;limit_connconn20;limit_rate500k;limit_reqzone=fooburst=5nodelay;}location/app/api{proxy_passhttp://192.168.1.111:8095/app/api}}#Because nginx will give priority to accurate matching

How to check IP address on WeChat How to check IP address on WeChat May 31, 2023 am 09:16 AM

How to check the IP address on WeChat: 1. Log in to the computer version of WeChat, right-click the taskbar at the bottom of the screen, and click "Task Manager"; 2. When the task manager pops up, click "Details" in the lower left corner; 3. Task management Enter the "Performance" option of the browser and click "Open Resource Monitor"; 4. Select "Network" and check the WeChat process "Wechat.exe"; 5. Click "TCP Connection" below to monitor the WeChat network IP related situation. Sending a message and getting a reply will reveal the other person's IP address.

See all articles