Total Pageviews

Thursday 31 March 2016

使用obfsproxy的srcamblesuit版混淆http代理服务器程序的流量或socks代理服务器程序的流量,用来翻墙(测试成功)


obfsproxy是由Tor Project为Tor在被审查的国家使用而开发出的流量混淆插件以规避这些国家的防火墙…不过这个插件不仅可以用在Tor网桥上,还可以用在socks代理服务器程序/http代理服务器程序上。你可以通过obfsproxy混淆socks代理服务器程序/http代理服务器程序的流量。
配置服务端:
我们可以从python-pip安装,或者从torbrowser提取,不建议使用debian/ubuntu源安装,因为缺少scramblesuit特性..
如果是Debian/Ubuntu类系统:
先安装环境
apt-get install python-setuptools python-dev gcc 
如果是CentOS则执行
yum install python-setuptools python-devel pycrypto gcc && easy_install pip
之后安装obfsproxy:
pip install obfsproxy
(或者不装pip,直接运行easy_install  obfsproxy也行!)


执行obfsproxy,查看支持的混淆方式:
xiaolan@cui:~$ obfsproxy
usage: obfsproxy [-h] [-v] [--log-file LOG_FILE]
[--log-min-severity {error,warning,info,debug}] [--no-log]
[--no-safe-logging] [--data-dir DATA_DIR] [--proxy PROXY]
{managed,obfs2,dummy,obfs3,scramblesuit,b64} …
运行服务端
一般使用scramblesuit模式.
scramblesuit是obfs3的加强版,使用密码加密..使得GFW无法模拟obfs客户端来探测被混淆的是什么..我们这里以scramblesuit作为示范..
注意:scramblesuit的密码必须为BASE32字符..
BASE32字符是:FANGBINXINGFUCKYOURMOTHERSASS444且必须为32位!
obfsproxy --data-dir /tmp/scramblesuit-server scramblesuit --password FANGBINXINGFUCKYOURMOTHERSASS444 --dest 127.0.0.1:10080 server 0.0.0.0:2333 > /dev/null &
127.0.0.1:10080 是转发到的服务(比如socks代理服务器程序或http代理服务器程序)的端口。注意:这里的‘--dest 127.0.0.1:10080’ 必须放在 ‘server 0.0.0.0:2333’的前面。而且127.0.0.1不能替换为localhost.
(这里10080是我搭建在vps上的socks代理服务器程序mocks的端口号.mocks的搭建在此:
http://briteming.blogspot.com/2012/02/socks-server-mocks.html
0.0.0.0:2333 是obfsproxy所监听的端口。
那一大串长的是密码.
如果运行成功后应该会提示:
2015-08-21 22:54:12,282 [WARNING] Obfsproxy (version: 0.2.13) starting up.
2015-08-21 22:54:12,282 [ERROR]
################################################
Do NOT rely on ScrambleSuit for strong security!
################################################
至此服务端已经配置完成….
运行客户端:
Windows请下载Tor Browser后, 解压打开Browser\TorBrowser\Tor\PluggableTransports\obfsproxy.exe复制出来,用法同下:
obfsproxy --data-dir /tmp/scramblesuit-server scramblesuit --password FANGBINXINGFUCKYOURMOTHERSASS444 --dest your_vps_ip:2333 client 127.0.0.1:2345 

注意:这里的‘--dest your_vps_ip:2333’ 必须放在 ‘client 127.0.0.1:2345 ’的前面。
your_vps_ip:2333是你的obfsproxy程序所在服务器的IP地址:所监听的端口号。
FANGBINXINGFUCKYOURMOTHERSASS444是密码,需与服务端一致.
设置你的浏览器的socks代理为127.0.0.1:2345,浏览器即可翻墙。
你在服务器上所运行的后端代理服务器程序是socks代理服务器程序(比如mocks/kingate),则本地机器的浏览器的代理就设为socks代理;
你在服务器上所运行的后端代理服务器程序是http代理服务器程序(比如squid/tinyproxy),则本地机器的浏览器的代理就设为http代理;
修改自https://xiaolan.me/obfsproxy.html
注1:你的vps需要有虚拟内存。在不带虚拟内存的vps上安装,运行obfsproxy --data-dir /tmp/scramblesuit-server scramblesuit --password FANGBINXINGFUCKYOURMOTHERSASS444 --dest 127.0.0.1:10080 server 0.0.0.0:2333 ,会遇到错误:
 Could not verify the authentication message's HMAC。
如果想给Xen/KVM VPS添加SWAP,可读http://briteming.blogspot.com/2016/03/vpsswapxen.html

注2:如果你的vps是centos6,系统自带的python是2.6版,太低了。python需为2.7版,方能成功安装obfsproxy. centos7自带的python是2.7版,因此建议升级centos6到centos7或重新安装新的系统centos7.我在centos7上,虽然服务器端obfsproxy正常运行中,也开放了2333端口,客户端机器的obfsproxy也在运行中,可还是翻墙失败。而在debian8下,就轻松搞定了。所以服务器系统建议选择debian8或ubuntu14.04(含)或更高版本

注3: 后端的代理服务器程序建议还是选择socks proxy app.我另外搭建了一个http proxy app - tinyproxy(tinproxy.conf中的Allow 127.0.0.1这行不要注释掉!)作为后端,但是翻墙速度很慢。

obfsproxy的版本 1, 2, 3 都已经被某长城识别并成功实现干扰或者封锁。如果哪一天obfsproxy的scramblesuit模式也被gfw破解了,那就改用obfs4: https://github.com/Yawning/obfs4
https://github.com/FredericJacobs/obfsproxy-c 

相关帖子:http://briteming.blogspot.com/2015/08/obfs4proxy-shadowsocks.html 
(这里说的用obfsproxy混淆shadowsocks流量,其意义不大,因为
shadowsocks本身就有混淆流量的作用。而通常的socks代理服务器程序/http代理服务器程序是明文代理,因此无法用它们来直接翻墙,这时用obfsproxy混淆socks代理服务器程序/http代理服务器程序的流量,二者结合,就可顺利的翻墙了。)
--------------------------------------
附录:
在mac上,安装obfsproxy
 
首先按此文http://briteming.blogspot.com/2015/10/macosproxychains.html,在mac上,安装proxychains。然后运行:
proxychains4 git clone https://git.torproject.org/pluggable-transports/obfsproxy
即可把被封的obfsproxy克隆下来。也可这样做:
ALL_PROXY=socks5://localhost:1080 git clone https://git.torproject.org/pluggable-transports/obfsproxy
同样可以把被封的obfsproxy源码克隆下来。这里的localhost:1080是一个在本地运行的socks代理,比如ss或ssh tunnel)
cd obfsproxy (里面有setup.py文件)
python setup.py install   
 
 安装好之后,运行:
obfsproxy --data-dir /tmp/scramblesuit-server scramblesuit --password FANGBINXINGFUCKYOURMOTHERSASS444 --dest your_vps_ip:2333 client 127.0.0.1:2345
obfsproxy的客户端就运行起来了。
如果运行obfsproxy --data-dir /tmp/scramblesuit-server scramblesuit --password FANGBINXINGFUCKYOURMOTHERSASS444 --dest your_vps_ip:2333 client 0.0.0.0:2345遇到错误, 则运行sudo pip install twisted

https://github.com/NullHypothesis/obfsproxy (这个仓库不错)


https://github.com/isislovecruft/obfsproxy
(Python version of obfsproxy, forked from https://git.torproject.org/pluggable-transports/obfsproxy.git)
https://github.com/isislovecruft/obfsproxy-legacy
--------------------------------

利用obfsproxy混淆任意流量

服务器端安装与配置: 
安装obfsproxy 
1、[root@1st ~]# yum install gcc python-pip python-devel 
2、[root@1st ~]# pip install obfsproxy 
3、[root@1st ~]# obfsproxy 
usage: obfsproxy [-h] [-v] [–log-file LOG_FILE] [–log-min-severity {error,warning,info,debug}] [–no-log] [–no-safe-logging] [–data-dir DATA_DIR] [–proxy PROXY] {managed,obfs2,dummy,obfs3,scramblesuit,b64} … 
以上三步,我们就完成了obfsproxy的安装工作,接下来我们开始配置。obfsproxy一般使用scramblesuit模式,scramblesuit是obfs3的加强版,使用密码加密。下面以scramblesuit作为示范。 注意:scramblesuit的密码必须为BASE32字符。 BASE32字符是由:ABCDEFGHIJKLMNOPQRSTUVWXYZ234567组成,且必须为32位。
[root@1st ~]# obfsproxy –data-dir ~/.obfs/ scramblesuit –dest 127.0.0.1:1194 –password ABCDEFGHIJKLMNOPQRSTUVWXYZ234567 server 0.0.0.0:1234 &
上面的命令中:127.0.0.1:1194就是需要被混淆的端口(比如http proxy程序tinyproxy的端口或者某个socks proxy程序的端口),0.0.0.0:1234是混淆后对外监听的端口。如果不需要后台运行则去掉最后的 & 。
运行成功后应该会提示:
2015-08-21 22:54:12,282 [WARNING] Obfsproxy (version: 0.2.13) starting up. 2015-08-21 22:54:12,282 [ERROR] ################################################ Do NOT rely on ScrambleSuit for strong security! ################################################ 至此服务端已经配置完成。
客户端安装与配置:
pip install obfsproxy
如果一切顺利,就可以执行下面的命令了: 
obfsproxy scramblesuit --dest vps-ip:1234 --password ABCDEFGHIJKLMNOPQRSTUVWXYZ234567 client 127.0.0.1:56789
-------------------
A python implementation of obfsproxy.
This is a python implementation of the Pluggable Transports for Circumvention specification for Tor:
https://gitweb.torproject.org/torspec.git/blob_plain/HEAD:/proposals/180-pluggable-transport.txt

from  https://github.com/blanu/py-obfsproxy