CULR代理IP的实现,坐等神人!【急】
PHP CURL IP代理
打印$_SERVER['REMOTE_ADDR'];获取到真实IP$_SERVER['HTTP_X_FORWARDED_FOR'];获取到代理IP
实现用代理访问网址返回网页内容
$ip = rand(1,255).'.'.rand(1,255).'.'.rand(1,255).'.'.rand(1,255);
$headerArr[] = 'X-FORWARDED-FOR' .':' . $ip;
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, "http://ip138.com");
curl_setopt ($ch, CURLOPT_HTTPHEADER , $headerArr );
$re=curl_exec($ch);
var_dump($re);
这是我写的代码,没什么用。
$_SERVER['REMOTE_ADDR'];打印出我真实的IP
$_SERVER['HTTP_X_FORWARDED_FOR'];打印出来的是我虚拟的IP
能让程序返回内容中的IP显示为代理IP即可
回复讨论(解决方案)
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
//第一、伪造来源HTTP_REFERER
$ch = curl_init(); //初始化
curl_setopt($ch, CURLOPT_URL, http://www.example.com/); //你要访问的页面
curl_setopt($ch, CURLOPT_REFERER, http://www.example.com/); //伪造来源HTTP_REFERER
curl_setopt($chtml,CURLOPT_RETURNTRANSFER,1); //是否显示内容
curl_exec($ch); //执行
curl_close($ch); //返回关闭
//第二、用代理
curl_setopt($ch,CURLOPT_PROXY,"http://www.domain.com");
//第三、伪造ip
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:8.8.8.8', 'CLIENT-IP:8.8.8.8')); //构造IP
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
这个怎么用?$proxy是什么意思?给它赋什么值?IP吗?用不用加端口号?
具体要怎么写啊?
define ( 'IS_PROXY', true );
$ip = rand(1,255).'.'.rand(1,255).'.'.rand(1,255).'.'.rand(1,255);
$headerArr[] = 'X-FORWARDED-FOR' .':' . $ip;
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, "http://www.liansuo.com/chaxun.php");
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt ($ch, CURLOPT_HTTPHEADER , $headerArr ); //构造IP
$re=curl_exec($ch);
var_dump($re);
本人小白,麻烦大神们给写明白点行吗?
虽然我是小白,但我不是纯白好么。。
各位大神麻烦测试了后再盖楼,我昨天已经试一天了,百度复制过来没意思。
打印$_SERVER['REMOTE_ADDR'];获取到真实IP
$_SERVER['HTTP_X_FORWARDED_FOR'];获取到代理IP
我要伪装的是打印$_SERVER['REMOTE_ADDR']所获得的IP
效果是程序访问http://ip138.com/时IP显示的是伪装的IP才行。
也接近纯白了
REMOTE_ADDR 是访问网站的那台机器的ip 假设为 P
HTTP_X_FORWARDED_FOR 是 P向网站发出的ip信息,用REMOTE_ADDR获得向 P发出请求的机器的ip
如果你的本机为 P,可以伪造HTTP_X_FORWARDED_FOR,但不能伪造REMOTE_ADDR
如果你是通过代理 P访问网站,则网站收到REMOTE_ADDR为 P的ip,但HTTP_X_FORWARDED_FOR你则无法伪造,因为是 P发出的,不受你控制
$_SERVER['REMOTE_ADDR'] 来源的IP,如果是经代理访问的,就是代理的ip
$_SERVER['HTTP_X_FORWARDED_FOR'] 访问代理的机器的ip
我是想$_SERVER['REMOTE_ADDR']打印出来的IP是我设置的代理的IP,能实现吗?求方法
我是想$_SERVER['REMOTE_ADDR']打印出来的IP是我设置的代理的IP,能实现吗?求方法
见#1 或 #2,设置 CURLOPT_PROXY

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Alipay PHP...

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.
