奇怪的导航站...

2014-12-27 23:00:34 +08:00
 c4tn

访问:www.win8daohang.com/dd.php?gome=1
比如国美的一个站点,他通过这个访问,如何把referer替换成
www.win8daohang.com

见图:http://static.wooyun.org/upload/image/201412/2014122722554972651.png
正常的访问referer应该来源是
www.win8daohang.com/dd.php?gome=1

他怎么做到的...

3405 次点击
所在节点    PHP
7 条回复
airyland
2014-12-27 23:22:44 +08:00
没什么奇怪的啊。
http://www.win8daohang.com/dd.php?gome=1 做了跳转,先跳到了http://www.win8daohang.com而已。

<html><head><meta http-equiv='pragma' content='no-cache'><meta http-equiv='refresh' content='0; url=/'></head><body></body></html>
c4tn
2014-12-27 23:28:01 +08:00
@airyland 感谢已经发送,我发现了他的行为,
访问www.win8daohang.com/dd.php?gome=1
第一跳
<html><head><meta http-equiv='pragma' content='no-cache'><meta http-equiv='refresh' content='0; url=/'></head><body></body></html>

第二跳
...<html><head><meta http-equiv='pragma' content='no-cache'><meta http-equiv='refresh' content='0; url=http://cps.gome.com.cn/home/JoinUnion?sid=4012&wid=3940&feedback=TL101&to=http://www.gome.com.cn'></head><body></body></html>

这应该是欺骗国美,让一个推广链接,来源是他的首页,

我想知道这个具体是php实现的还是其他rewrite模块,请指教.
aaaa007cn
2014-12-27 23:29:49 +08:00
http://www.win8daohang.com/dd.php?gome=1
写了 session cookie
页面 <meta http-equiv='refresh' content='0; url=/'> 重定向到 http://www.win8daohang.com/
带着这个 cookie 请求 http://www.win8daohang.com/ 会返回 <meta http-equiv='refresh' content='0; url=目标网站'>
c4tn
2014-12-27 23:34:00 +08:00
@aaaa007cn 感谢已经发送,

并没有set cookies 您的说法貌似不成立

GET /dd.php?gome=1 HTTP/1.1
Accept: text/html, application/xhtml+xml, */*
Accept-Language: zh-CN
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko
Accept-Encoding: gzip, deflate
Host: www.win8daohang.com
DNT: 1
Connection: Keep-Alive
Cookie: PHPSESSID=3tmlhbvbe142facffq4ojghor6

HTTP/1.1 200 OK
Date: Sat, 27 Dec 2014 15:26:01 GMT
Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.3.3
P3P: CP=CAO PSA OUR
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 130
Connection: close
Content-Type: text/html
Content-Language: zh-CN

<html><head><meta http-equiv='pragma' content='no-cache'><meta http-equiv='refresh' content='0; url=/'></head><body></body></html>
aaaa007cn
2014-12-27 23:39:16 +08:00
你这个已经有 cookie 了啊
PHPSESSID=3tmlhbvbe142facffq4ojghor6
服务器知道 3tmlhbvbe142facffq4ojghor6 这个 session 刚刚请求了 dd.php?gome=1
在这个 cookie 下次请求 / 时返回一次带跳转的 html
之后这个 cookie 请求 / 就返回正常的首页
c4tn
2014-12-27 23:45:53 +08:00
@aaaa007cn 您能告诉我具体实现细节吗?是php还是webserver本身策略?
aaaa007cn
2014-12-28 00:11:45 +08:00
php 中做的手脚吧
session 看这里 http://php.net/manual/en/book.session.php

我是用 curl 来测的

curl "http://www.win8daohang.com/dd.php?gome=1" -v -c cookie -o daohang1
首次设置 cookie,返回转向 / 的 html

curl "http://www.win8daohang.com/" -v -b cookie -c cookie -o daohang2
返回转向国美的 html

curl "http://www.win8daohang.com/" -v -b cookie -c cookie -o daohang3
返回正常首页

curl "http://www.win8daohang.com/dd.php?gome=1" -v -b cookie -c cookie -o daohang4
返回转向 / 的 html

curl "http://www.win8daohang.com/" -v -b cookie -c cookie -o daohang5
返回转向国美的 html

你会发现只有第一次请求服务器才发送 Set-Cookie: PHPSESSID=xxx; path=/
之后服务器不再发送 Set-Cookie

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/157241

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX