Home Backend Development PHP Tutorial php set random ip access

php set random ip access

Oct 15, 2019 pm 02:29 PM
curl ip

php set random ip access

When we request a site, the http header will carry some IP information. By forging this information, we can form the effect of different IP access requests.

Header header CLIENT-IP and X-FORWARDED-FOR are set to the IP we want to forge, and the server will get the IP we specified. ip.

Recommended learning: PHP video tutorial

##X-Forwarded-For is an extension header. The HTTP/1.1 (RFC 2616) protocol does not define it. It was first introduced by Squid, a caching proxy software, to represent the real IP of the HTTP requester. Now it has become a de facto standard and is used by major HTTP proxies, Forwarding services such as load balancing are widely used and are written into the RFC 7239 (Forwarded HTTP Extension) standard.

In the case of normal TCP/IP two-party communication, the source IP cannot be forged, that is, It is said that in the TCP/IP protocol, the source IP of the data packet can be forged, but this will make the sent data packet never return, making normal communication impossible. This is just like when we write a letter to the other party, if we write the wrong sender's address, and the recipient replies according to the sender's address on the envelope, the original sender will not be able to receive the reply.

Some DDoS attacks, such as SYN flood, take advantage of this flaw in TCP/ip to implement the attack.

The following describes how PHP constructs random access.

<?php
function curl($url,$ifpost = 0, $datafields = &#39;&#39;, $cookiefile = &#39;&#39;, $v = false){
$ip_long = array(
            array(&#39;607649792&#39;, &#39;608174079&#39;), //36.56.0.0-36.63.255.255
            array(&#39;1038614528&#39;, &#39;1039007743&#39;), //61.232.0.0-61.237.255.255
            array(&#39;1783627776&#39;, &#39;1784676351&#39;), //106.80.0.0-106.95.255.255
            array(&#39;2035023872&#39;, &#39;2035154943&#39;), //121.76.0.0-121.77.255.255
            array(&#39;2078801920&#39;, &#39;2079064063&#39;), //123.232.0.0-123.235.255.255
            array(&#39;-1950089216&#39;, &#39;-1948778497&#39;), //139.196.0.0-139.215.255.255
            array(&#39;-1425539072&#39;, &#39;-1425014785&#39;), //171.8.0.0-171.15.255.255
            array(&#39;-1236271104&#39;, &#39;-1235419137&#39;), //182.80.0.0-182.92.255.255
            array(&#39;-770113536&#39;, &#39;-768606209&#39;), //210.25.0.0-210.47.255.255
            array(&#39;-569376768&#39;, &#39;-564133889&#39;), //222.16.0.0-222.95.255.255
    );
    $rand_key = mt_rand(0, 9);
    $ip= long2ip(mt_rand($ip_long[$rand_key][0], $ip_long[$rand_key][1]));
$header = array("Connection: Keep-Alive","Accept: text/html, application/xhtml+xml, */*", "Pragma: no-cache", "Accept-Language: zh-Hans-CN,zh-Hans;q=0.8,en-US;q=0.5,en;q=0.3","User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)",&#39;CLIENT-IP:&#39;.$ip,&#39;X-FORWARDED-FOR:&#39;.$ip); 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_HEADER, $v); 
curl_setopt($ch, CURLOPT_HTTPHEADER, $header); 
$ifpost && curl_setopt($ch, CURLOPT_POST, $ifpost); 
$ifpost && curl_setopt($ch, CURLOPT_POSTFIELDS, $datafields); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
$cookiefile && curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile); 
$cookiefile && curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile); 
curl_setopt($ch,CURLOPT_TIMEOUT,30); //允许执行的最长秒数
$ok = curl_exec($ch); 
curl_close($ch); 
unset($ch);
return $ok;
}
print_r(curl("URL"));
?>
Copy after login

The above is the detailed content of php set random ip access. 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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

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,

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

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).

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 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.

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

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

See all articles