【发布时间】:2012-01-27 09:54:40
【问题描述】:
在学校,网站上有块。我打算撤销它。即使我不这样做,我也喜欢这个主意。所以:我有一个 php 页面(source.php)来获取任何站点的源代码(没有跨站点 ajax)。
<?php
echo file_get_contents(urldecode($_GET["url"]));
?>
<script>
if(document.getElementsByTagName("base")[0])
document.getElementsByTagName("base")[0].href="<?php echo $_GET["url"] ?>";
else
document.head.appendChild(document.createElement("base").href="<?php
echo $_GET["url"] ?>");
</script>
简单。这是 index.html
<html><head><title>Unblocker</title></head><body>
<div width="100%" height="10%">
<form onsubmit="return go()">
<input id="url" value="http://www.google.com/">
<input type="submit" value="Go">
</form>
</div>
<div width="100%" height="90%">
<iframe src="http://www.google.com/" width="100%" height="100%" id="frame">
</iframe>
</div></body></html>
现在是 javascript(要插入到 head 标签中)
function go(){
url=document.getElementById("url").value;
frame=document.getElementById("frame");
//do some url validations, not posting cause doesn't matter
if(url.isValid)//example
frame.contentWindow.location=location.protocol+"//"+location.hostname+"/
source.php?url="+url;
return false;//to prevent page reload
}
有几件事:首先,这是否合法,尽管我的意图是好的,但仍获取整个源代码并显示它们?另外,它会起作用吗,还是有什么明显的东西可以让它变得更好?我知道服务器端不能被过滤(假设这个站点没有被屏蔽!)。我知道它非常有限,但我也许可以扩展它以允许点击链接和所有内容。
【问题讨论】:
-
为什么不直接使用代理服务来查看网站?
-
这是您需要使用编码实现的吗?你能不能只使用公共代理服务器并配置你的浏览器来使用它? publicproxyservers.com
-
您真的很在意合法性,因为您声明您的全部目的是为了规避某人的规则?
-
下载页面源是真的非法的,连我的浏览器都没有……等等……
-
如果 TOR 合法,请查看 TOR 浏览器捆绑包是否可以在您的网络中运行。把它放在闪存驱动器上。 torproject.org/download/download.html.en
标签: javascript php iframe proxy