├── README.md ├── fic.sh ├── r.tocn.conf ├── start.sh └── 添加其他应用的方法.txt /README.md: -------------------------------------------------------------------------------- 1 | # 提醒:本程序没有客服!没有客服!没有客服! 2 | 3 | FakeInChina(假装在中国) 4 | 5 | 6 | 这原本就是一个写来自己用的小程序,并不是什么高深的科研项目,全部程序用Shell 的脚本写成。 7 | 用途:与“由于版权限制,你所在的地区不能播放”告别,目前支持大多数主流的视音频app,包括:youku、iqiyi、qq(音乐、视频)、网易、乐视、CNTV等等,数量太多,不全部列出了。 8 | # 这个功能模块需要使用国内SS服务器 9 | 其实最早让 Hiboy 把ss-server集成到 PADAVAN 基础固件就是为了这一个模块,只是由于前一段时间基本上在国内,也就一直没有时间去调试这个模块,这段时间终于有时间和条件进行调试了。 10 | 模块运行时候,仅对检测服务器进行流量伪装(可能会包括部分网页文字以及图片),视音频码流依然直连线路,因此,对国内的SS服务器流量需求极低,一般普通家庭用的宽带便可以使用,在国内家人或者朋友的路由上运行SS-server,你在国外就可以正常使用。 11 | 毕竟大多数国内宽带IP是动态的,并且很多地区会限制时间自动断线,模块支持多台ss服务器备份,会自动检测可用的SS服务器,自动重连。 12 | 目前这个模块在我自己的路由上跑了将近半年了,前一段时间由于检测地区的网站在国内很难打开,因此升级了一个小版本,顺便开源了。 13 | 14 | 由于各大公司检测IP的方法可能会变,某些规则会出现失效,某些服务商针对不同地区会用不同IP的服务器进行检测(例如youku,美国和德国地区用于地区检测的服务器就不同),所以我仅能保证我所居住的德国地区可以使用正常。 15 | 如果你所用的app出现了地区限制,可以在github 发Issues,但我能处理的只有 ipad、iphone,至于安卓什么的,包括手机、电视盒、智能电视(德国的安卓智能电视很贵,我很穷,买不起),我统统没有,所以无法解决。并且如果是由于地区不同而导致检测服务器不同出现的地区限制,恕我无能为力。 16 | 17 | # 系统原理 18 | 19 | 利用 ipset ,对域名、IP、IP段的流量进行监控,把所有检测IP的请求都通过国内的走,所幸的是大部分视频服务本身的码流服务器都不会检测IP,所以这个程序对流量的要求很低,一般家庭的宽度上行流量都可以支撑。 20 | 21 | 程序会建立 2 个ipset 的表项,你可以在 start.sh 里面找到: 22 | 23 | tocn :对于单个IP 的伪装 24 | 25 | rtocn : 对于IP段的伪装 26 | 27 | 在 start.sh 里面的独立IP设置是已知的无域名IP和无域名IP段,需要独立添加,所以在脚本里面处理了。对于有域名的,则利用 dnsmasq 的ipset 扩展,加入一个 r.tocn.conf 的配置文件,自动添加到 tocn 的ipset 表项里面。 28 | 29 | 原理就这么多了,有兴趣自己看源码。 30 | 31 | # 数据来源 32 | 33 | 大部分需要伪装流量的IP列表和域名来自半年前的 unblockyouku 这个浏览器插件的 proxy 配置文件,我自己也只是添加了少量几个IP和域名,严格来说不超过10个. :D ,目前肯定有些过时,但由于我是一个懒人,我的APP正常的,我就懒得去管了。 -------------------------------------------------------------------------------- /fic.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # FakeInChina(假装在中国) 3 | # 用途:与“由于版权限制,你所在的地区不能播放”告别,目前支持大多数主流的视音频app,包括:youku、iqiyi、qq(音乐、视频)、网易、乐视、CNTV等等,数量太多,不全部列出了。 4 | # 2018-1-11@DE 5 | 6 | # 配置文件包括以下几个: 7 | # /etc/storage/fic/start.sh ,启动脚本 和 用于初始化流量伪装表。 8 | # /etc/storage/fic/r.tocn.conf 这个文件复制到 /etc/storage/dnsmasq/dnsmasq.d/r.tocn.conf ,其中的 ipinfo.io 是用于检测地区的,你也可以在模块运行后浏览器访问 ipinfo.io 看看到底流量伪装是否成功。 9 | # /etc//storage/fic/fic.sh 这个文件用于自动检测 ss 是否正常,自动切换ss 服务器。里面需要设置你自己的ss服务器参数,请保证各台ss-server 的端口、密码、加密方式的一致,我是个懒人,不想处理那么复杂的情况。 10 | 11 | # ↓↓↓↓↓配置你自己的ss服务器参数↓↓↓↓↓ 12 | server1=xxxx1.dynu.com 13 | server2=xxxx2.dynu.com 14 | server3=xxxx3.dynu.com 15 | ss_router_port=1234 #服务器端口 16 | ss_passwd=password #密码 17 | method=chacha20 #加密方式 18 | 19 | 20 | 21 | 22 | index=1 23 | eval server="\$"server${index} 24 | killall ss-redir 25 | logger -t "FIC" "Connecting server: $server..." 26 | ss-redir -s $server -p $ss_router_port -l 1008 -b 0.0.0.0 -k $ss_passwd -m $method -u -f /tmp/tocn_ss.pid 27 | sleep 3 28 | 29 | while true 30 | do 31 | country=`wget -qO- https://api.ip.sb/geoip | sed 's/.*try_code":"\([A-Z]*\).*/\1/g'` 32 | if [ "$country" != "CN" ]; then 33 | logger -t "FIC" "ChinaServer incorrect: $country, try next server: $server." 34 | 35 | let index+=1 36 | eval server="\$"server${index} 37 | if [ -z "$server" ]; then 38 | index=0 39 | logger -t "FIC:" "ChinaServer run over. Sleep 60sec." 40 | sleep 60 41 | else 42 | killall ss-redir 43 | sleep 2 44 | ss-redir -s $server -p $ss_router_port -l 1008 -b 0.0.0.0 -k $ss_passwd -m $method -u -f /tmp/tocn_ss.pid 45 | sleep 3 46 | fi 47 | 48 | else 49 | logger -t "FIC" "Country Check: $country, next checkpoint: 120sec." 50 | sleep 120 #等120秒继续监测地区代码 51 | fi 52 | 53 | done -------------------------------------------------------------------------------- /r.tocn.conf: -------------------------------------------------------------------------------- 1 | ipset=/3g.music.qq.com/tocn 2 | ipset=/a.play.api.3g.youku.com/tocn 3 | ipset=/ac.qq.com/tocn 4 | ipset=/acc.music.qq.com/tocn 5 | ipset=/access.tv.sohu.com/tocn 6 | ipset=/acs.youku.com/tocn 7 | ipset=/aid.video.qq.com/tocn 8 | ipset=/aidbak.video.qq.com/tocn 9 | ipset=/antiserver.kuwo.cn/tocn 10 | ipset=/api.3g.tudou.com/tocn 11 | ipset=/api.3g.youku.com/tocn 12 | ipset=/api.aixifan.com/tocn 13 | ipset=/api.appsdk.soku.com/tocn 14 | ipset=/api.ip.sb/tocn 15 | ipset=/api.itv.letv.com/tocn 16 | ipset=/api.le.com/tocn 17 | ipset=/api.letv.com/tocn 18 | ipset=/api.live.letv.com/tocn 19 | ipset=/api.mob.app.letv.com/tocn 20 | ipset=/api.tv.itc.cn/tocn 21 | ipset=/api.tv.sohu.com/tocn 22 | ipset=/api.unipay.qq.com/tocn 23 | ipset=/api.www.letv.com/tocn 24 | ipset=/api.youku.com/tocn 25 | ipset=/app.bilibili.com/tocn 26 | ipset=/ark.letv.com/tocn 27 | ipset=/bangumi.bilibili.com/tocn 28 | ipset=/c.y.qq.com/tocn 29 | ipset=/cache.m.iqiyi.com/tocn 30 | ipset=/cache.video.iqiyi.com/tocn 31 | ipset=/cache.video.qiyi.com/tocn 32 | ipset=/cache.vip.iqiyi.com/tocn 33 | ipset=/cache.vip.qiyi.com/tocn 34 | ipset=/cctv1.vtime.cntv.cloudcdn.net/tocn 35 | ipset=/cctv13.vtime.cntv.cloudcdn.net/tocn 36 | ipset=/cctv5.vtime.cntv.cloudcdn.net/tocn 37 | ipset=/cctv5plus.vtime.cntv.cloudcdn.net/tocn 38 | ipset=/chrome.2345.com/tocn 39 | ipset=/client.api.ttpod.com/tocn 40 | ipset=/cloud.vip.xunlei.com/tocn 41 | ipset=/cupid.iqiyi.com/tocn 42 | ipset=/data.bilibili.com/tocn 43 | ipset=/data.video.iqiyi.com/tocn 44 | ipset=/data.video.qiyi.com/tocn 45 | ipset=/dispatcher.video.sina.com.cn/tocn 46 | ipset=/dmd-fifa-h5-ikuweb.youku.com/tocn 47 | ipset=/dmd-fifajs-h5-ikuweb.youku.com/tocn 48 | ipset=/douban.fm/tocn 49 | ipset=/dpool.sina.com.cn/tocn 50 | ipset=/dyn.ugc.pps.tv/tocn 51 | ipset=/dynamic.app.m.letv.com/tocn 52 | ipset=/dynamic.cloud.vip.xunlei.com/tocn 53 | ipset=/dynamic.live.app.m.letv.com/tocn 54 | ipset=/dynamic.meizi.app.m.letv.com/tocn 55 | ipset=/dynamic.search.app.m.letv.com/tocn 56 | ipset=/epg.api.pptv.com/tocn 57 | ipset=/geo.js.kankan.com/tocn 58 | ipset=/hot.vrs.letv.com/tocn 59 | ipset=/hot.vrs.sohu.com/tocn 60 | ipset=/i.play.api.3g.youku.com/tocn 61 | ipset=/i.y.qq.com/tocn 62 | ipset=/iface.iqiyi.com/tocn 63 | ipset=/iface2.iqiyi.com/tocn 64 | ipset=/ifconfig.co/tocn 65 | ipset=/info.zb.qq.com/tocn 66 | ipset=/info.zb.video.qq.com/tocn 67 | ipset=/inner.kandian.com/tocn 68 | ipset=/interface.bilibili.com/tocn 69 | ipset=/internal.check.duokanbox.com/tocn 70 | ipset=/ip.apps.cntv.cn/tocn 71 | ipset=/ip.kankan.com/tocn 72 | ipset=/ip.kugou.com/tocn 73 | ipset=/ip2.kugou.com/tocn 74 | ipset=/ipcheck.kuwo.cn/tocn 75 | ipset=/ipinfo.io/tocn 76 | ipset=/ipip.net/tocn 77 | ipset=/i-play.mobile.youku.com/tocn 78 | ipset=/iplocation.geo.iqiyi.com/tocn 79 | ipset=/iplocation.geo.qiyi.com/tocn 80 | ipset=/ipservice.163.com/tocn 81 | ipset=/kandian.com/tocn 82 | ipset=/letv.cn/tocn 83 | ipset=/letv.com/tocn 84 | ipset=/list.youku.com/tocn 85 | ipset=/listso.m.areainfo.ppstream.com/tocn 86 | ipset=/live.api.hunantv.com/tocn 87 | ipset=/live.g3proxy.lecloud.com/tocn 88 | ipset=/live.gslb.letv.com/tocn 89 | ipset=/live.pptv.com/tocn 90 | ipset=/live.tv.sohu.com/tocn 91 | ipset=/lixian.vip.xunlei.com/tocn 92 | ipset=/lixian.xunlei.com/tocn 93 | ipset=/m.letv.com/tocn 94 | ipset=/m10.music.126.net/tocn 95 | ipset=/mobi.kuwo.cn/tocn 96 | ipset=/mobile.api.hunantv.com/tocn 97 | ipset=/mobilefeedback.kugou.com/tocn 98 | ipset=/mqqplayer.3g.qq.com/tocn 99 | ipset=/music.163.com/tocn 100 | ipset=/music.baidu.com/tocn 101 | ipset=/music.sina.com.cn/tocn 102 | ipset=/my.tv.sohu.com/tocn 103 | ipset=/nmobi.kuwo.cn/tocn 104 | ipset=/openapi.youku.com/tocn 105 | ipset=/pad.tv.sohu.com/tocn 106 | ipset=/pay.tudou.com/tocn 107 | ipset=/pay.video.qq.com/tocn 108 | ipset=/pay.youku.com/tocn 109 | ipset=/paybak.video.qq.com/tocn 110 | ipset=/pcweb.api.mgtv.com/tocn 111 | ipset=/pl-ali.youku.com/tocn 112 | ipset=/play.api.3g.tudou.com/tocn 113 | ipset=/play.api.3g.youku.com/tocn 114 | ipset=/play.api.pptv.com/tocn 115 | ipset=/play.baidu.com/tocn 116 | ipset=/play.youku.com/tocn 117 | ipset=/play-ali.youku.com/tocn 118 | ipset=/play-dxk.youku.com/tocn 119 | ipset=/player.aplus.pptv.com/tocn 120 | ipset=/player.pc.le.com/tocn 121 | ipset=/player-pc.le.com/tocn 122 | ipset=/ppi.api.pptv.com/tocn 123 | ipset=/proxy.music.qq.com/tocn 124 | ipset=/proxymc.qq.com/tocn 125 | ipset=/pstream.api.mgtv.com/tocn 126 | ipset=/qzs.qq.com/tocn 127 | ipset=/s.plcloud.music.qq.com/tocn 128 | ipset=/search.api.3g.tudou.com/tocn 129 | ipset=/search.api.3g.youku.com/tocn 130 | ipset=/search.lekan.letv.com/tocn 131 | ipset=/serviceinfo.sdk.duomi.com/tocn 132 | ipset=/sns.video.qq.com/tocn 133 | ipset=/so.open.163.com/tocn 134 | ipset=/spark.api.xiami.com/tocn 135 | ipset=/sports1pull.live.wscdns.com/tocn 136 | ipset=/ssports.com/tocn 137 | ipset=/ssports.smgbb.cn/tocn 138 | ipset=/st.live.letv.com/tocn 139 | ipset=/static.api.sports.letv.com/tocn 140 | ipset=/static.itv.letv.com/tocn 141 | ipset=/tingapi.ting.baidu.com/tocn 142 | ipset=/tms.is.ysten.com/tocn 143 | ipset=/tools.aplusapi.pptv.com/tocn 144 | ipset=/tv.api.3g.tudou.com/tocn 145 | ipset=/tv.api.3g.youku.com/tocn 146 | ipset=/tv.weibo.com/tocn 147 | ipset=/u.y.qq.com/tocn 148 | ipset=/ups.youku.com/tocn 149 | ipset=/v.api.hunantv.com/tocn 150 | ipset=/v.api.mgtv.com/tocn 151 | ipset=/v.iask.com/tocn 152 | ipset=/v.pps.tv/tocn 153 | ipset=/v.pptv.com/tocn 154 | ipset=/v.youku.com/tocn 155 | ipset=/v5.pc.duomi.com/tocn 156 | ipset=/vd.l.qq.com/tocn 157 | ipset=/vdn.apps.cntv.cn/tocn 158 | ipset=/vdn.live.cntv.cn/tocn 159 | ipset=/vi.l.qq.com/tocn 160 | ipset=/video.qq.com/tocn 161 | ipset=/video.sina.com.cn/tocn 162 | ipset=/video.tudou.com/tocn 163 | ipset=/vip.sports.cntv.cn/tocn 164 | ipset=/vxml.56.com/tocn 165 | ipset=/web-play.pplive.cn/tocn 166 | ipset=/web-play.pptv.com/tocn 167 | ipset=/wtv.v.iask.com/tocn 168 | ipset=/www.acfun.cn/tocn 169 | ipset=/www.bilibili.com/tocn 170 | ipset=/www.iqiyi.com/tocn 171 | ipset=/www.kugou.com/tocn 172 | ipset=/www.kuwo.cn/tocn 173 | ipset=/www.qie.tv/tocn 174 | ipset=/www.soku.com/tocn 175 | ipset=/www.tudou.com/tocn 176 | ipset=/www.xiami.com/tocn 177 | ipset=/www.yinyuetai.com/tocn 178 | ipset=/www.youku.com/tocn 179 | ipset=/zb.s.qq.com/tocn 180 | 181 | -------------------------------------------------------------------------------- /start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 写入防火墙规则 3 | 4 | logger -t "【fakeincn】" "防火墙规则恢复,开始返回国内规则" 5 | 6 | ipset -! -N tocn iphash 7 | 8 | iptables -t nat -D PREROUTING -p tcp -m set --match-set tocn dst -j REDIRECT --to-port 1008 9 | iptables -t nat -D OUTPUT -p tcp -m set --match-set tocn dst -j REDIRECT --to-port 1008 10 | iptables -t nat -A PREROUTING -p tcp -m set --match-set tocn dst -j REDIRECT --to-port 1008 11 | iptables -t nat -A OUTPUT -p tcp -m set --match-set tocn dst -j REDIRECT --to-port 1008 12 | 13 | while read line ; do ipset add tocn $line ;done <<-EOF 14 | 101.227.139.217 15 | 101.227.169.200 16 | 103.65.41.125 17 | 103.65.41.126 18 | 103.7.30.79 19 | 103.7.30.89 20 | 103.7.31.186 21 | 106.11.186.4 22 | 106.11.209.2 23 | 106.11.47.19 24 | 106.11.47.20 25 | 111.13.127.46 26 | 111.206.208.163 27 | 111.206.208.164 28 | 111.206.208.166 29 | 111.206.208.36 30 | 111.206.208.37 31 | 111.206.208.38 32 | 111.206.208.61 33 | 111.206.208.62 34 | 111.206.211.129 35 | 111.206.211.130 36 | 111.206.211.131 37 | 111.206.211.145 38 | 111.206.211.146 39 | 111.206.211.147 40 | 111.206.211.148 41 | 115.182.200.50 42 | 115.182.200.51 43 | 115.182.200.52 44 | 115.182.200.53 45 | 115.182.200.54 46 | 115.182.63.51 47 | 115.182.63.93 48 | 117.185.116.152 49 | 118.244.244.124 50 | 120.92.96.181 51 | 122.72.82.31 52 | 123.125.89.101 53 | 123.125.89.102 54 | 123.125.89.103 55 | 123.125.89.157 56 | 123.125.89.159 57 | 123.125.89.6 58 | 123.126.32.134 59 | 123.126.99.39 60 | 123.126.99.57 61 | 123.59.122.104 62 | 123.59.122.75 63 | 123.59.122.75 64 | 123.59.122.76 65 | 123.59.122.77 66 | 14.152.77.22 67 | 14.152.77.25 68 | 14.152.77.26 69 | 14.152.77.32 70 | 14.18.245.250 71 | 140.207.69.99 72 | 163.177.90.61 73 | 180.153.225.136 74 | 182.16.230.98 75 | 182.254.11.174 76 | 182.254.116.117 77 | 182.254.34.151 78 | 182.254.4.234 79 | 183.192.192.139 80 | 183.232.119.198 81 | 183.232.126.23 82 | 183.232.229.21 83 | 183.232.229.22 84 | 183.232.229.25 85 | 183.232.229.32 86 | 203.205.151.23 87 | 210.129.145.150 88 | 211.151.157.15 89 | 211.151.158.155 90 | 211.151.50.10 91 | 220.181.153.113 92 | 220.181.154.137 93 | 220.181.185.150 94 | 220.249.243.70 95 | 223.167.82.139 96 | 36.110.222.105 97 | 36.110.222.119 98 | 36.110.222.146 99 | 36.110.222.156 100 | 59.37.96.220 101 | 61.135.196.99 102 | EOF 103 | 104 | logger -t "【fakeincn】" "国内IP规则设置完成" 105 | 106 | 107 | 108 | ipset -! -N rtocn hash:net 109 | ipset add rtocn 106.11.1.1/16 110 | 111 | iptables -t nat -D PREROUTING -p tcp -m set --match-set rtocn dst -j REDIRECT --to-port 1008 112 | iptables -t nat -D OUTPUT -p tcp -m set --match-set rtocn dst -j REDIRECT --to-port 1008 113 | iptables -t nat -A PREROUTING -p tcp -m set --match-set rtocn dst -j REDIRECT --to-port 1008 114 | iptables -t nat -A OUTPUT -p tcp -m set --match-set rtocn dst -j REDIRECT --to-port 1008 115 | logger -t "【fakeincn】" "优酷IP规则设置完成" 116 | 117 | cp -f r.tocn.conf /etc/storage/dnsmasq/dnsmasq.d/r.tocn.conf 118 | 119 | restart_dhcpd 120 | 121 | -------------------------------------------------------------------------------- /添加其他应用的方法.txt: -------------------------------------------------------------------------------- 1 | 2 | 抓取方法分为两种 3 | 1. 设备可以指定 http 或者 https 代理的 4 | 使用Charles 方法进行分析,简单直接,可以直接查看。 5 | 6 | 2. 设备无法指定代理的 7 | 在路由上使用 tcpdump 导出日志记录后,使用 wireshark 分析 8 | tcpdump 在PDCN 固件里面已经内置了,建议配合U盘或者 TF卡,写入文件后,可以直接smb 复制出来。 9 | wireshark找数据的时候,基本上只要查看http 或者 https 的请求,大部分的IP验证机制都是用这种方式进行的。 10 | 11 | 抓取技巧 12 | 13 | 不需要一开始就抓取,目前大部分的视频app都是在媒体文件播放时才验证的,而音乐播放软件则是在获取歌曲列表时进行IP验证,找到合适的时机进行数据抓取会大大减少无用数据。 14 | 15 | 分析后的数据,域名可以加入到 r.tocn.conf 里面,ip 则要加到 start.sh 的对应部分。 16 | r.tocn.conf 更新后,需要重启 dnsmasq 进程,在pdcn固件里面,可以使用restart_dhcpd。 17 | start.sh 更新的,直接重新运行就好了。 18 | 19 | --------------------------------------------------------------------------------