我如何写一个简单的PHP透明代理? [英] How do I write a simple PHP transparent proxy?

查看:230
本文介绍了我如何写一个简单的PHP透明代理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个代理脚本,可以访问隐藏在登录屏幕后面的页面。我不需要代理模拟登录,而是登录页面HTML应该正常显示给用户,所有的cookies和HTTP GET / POST数据通过代理流到服务器,所以登录应该



我不想登录/密码,我只需要访问在登录后生成的页面的HTML源代码。



这里有人知道这可以如何完成吗?



如果没有,我从哪里开始?*(我目前正在使用PHP)*

解决方案

您正在谈论的是访问您需要验证自己的网页。



这里有一些必须




  • 您无法在不验证自己的情况下查看这些网页。

  • 网站(您要查看的HTML代码)仅支持网络登录作为身份验证方法,您将需要通过POST / GET发送(用户名,密码)来模拟登录,因为

  • 如果网站允许您以其他方式(例如LDAP,Kerberos等)验证自己,则您应该这样做



关键点是,你不能获得访问,而不先验证自己。



至于语言,它在PHP中是相当可行的。



我想知道的一件事是,你为什么叫它一个代理?

编辑:



在这种情况下,使用phproxy。它做你想要的,以及许多其他功能。


I need to make a proxy script that can access a page hidden behind a login screen. I do not need the proxy to "simulate" logging in, instead the login page HTML should be displayed to the user normally, and all the cookies and HTTP GET/POST data to flow through the proxy to the server, so the login should be authentic.

I don't want the login/password, I only need access to the HTML source code of the pages generated after logging in.

Does anybody here know how this can be accomplished? Is it easy?

If not, where do I begin?* (I'm currently using PHP)*

解决方案

What you are talking about is accessing pages for which you need to authenticate yourself.

Here are a few things that must be laid down:

  • you can't view those pages without authenticating yourself.
  • if the website (whose HTML code you want to see) only supports web login as an authentication method, you will need to simulate login by sending a (username,password) via POST/GET, as the case may be
  • if the website will let you authenticate yourself in other ways (like LDAP, Kerberos etc), then you should do that

The key point is that you cannot gain access without authenticating yourself first.

As for language, it is pretty doable in PHP. And as the tags on the question suggest, you are using the right tools to do that job already.

One thing I would like to know is, why are you calling it a "proxy"? do you want to serve the content to other users?

EDIT: [update after comment]

In that case, use phproxy. It does what you want, along with a host of other features.

这篇关于我如何写一个简单的PHP透明代理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆