Total Pageviews

Sunday, 7 October 2018

利用wcf翻墙

登陆linux vps.
首先搭建go环境。然后,
git clone https://github.com/xxxsen/wcf.git --depth=1
cd wcf
chmod 755 get_all_package.sh
chmod 755 build_all.sh
./get_all_package.sh
./build_all.sh
 
root@ve3961441593185503:~/wcf# ls
build_all.sh  get_all_package.sh  LICENSE  README.md  releases wcf
(生成了releases目录)
root@ve3961441593185503:~/wcf# cd releases
root@ve3961441593185503:~/wcf/releases# ls
wcf_config_2019_11_21_23_00_39.tar.gz  wcf_server_2019_11_21_23_00_39.tar.gz
wcf_local_2019_11_21_23_00_39.tar.gz
root@ve3961441593185503:~/wcf/releases# tar xvf wcf_server_2019_11_21_23_00_39.tar.gz
wcf_server_darwin_386
wcf_server_darwin_amd64
wcf_server_linux_386
wcf_server_linux_amd64
wcf_server_windows_386.exe
wcf_server_windows_amd64.exe
root@ve3961441593185503:~/wcf/releases# rm -rf wcf_server_darwin_386 wcf_server_darwin_amd64 wcf_server_windows_386.exe wcf_server_windows_amd64.exe
root@ve3961441593185503:~/wcf/releases# ls
wcf_config_2019_11_21_23_00_39.tar.gz  wcf_server_linux_386
wcf_local_2019_11_21_23_00_39.tar.gz   wcf_server_linux_amd64
wcf_server_2019_11_21_23_00_39.tar.gz
root@ve3961441593185503:~/wcf/releases# uname -a
Linux ve3961441593185503.vserver.site 4.9.0-4-amd64 #1 SMP Debian 4.9.65-3+deb9u1 (2017-12-23) x86_64 GNU/Linux
root@ve3961441593185503:~/wcf/releases# rm -rf wcf_server_linux_386
root@ve3961441593185503:~/wcf/releases# ls
wcf_config_2019_11_21_23_00_39.tar.gz  wcf_server_2019_11_21_23_00_39.tar.gz
wcf_local_2019_11_21_23_00_39.tar.gz   wcf_server_linux_amd64
root@ve3961441593185503:~/wcf/releases# ls
wcf_config_2019_11_21_23_00_39.tar.gz  wcf_server_2019_11_21_23_00_39.tar.gz
wcf_local_2019_11_21_23_00_39.tar.gz   wcf_server_linux_amd64
root@ve3961441593185503:~/wcf/releases# tar xvf wcf_config_2019_11_21_23_00_39.tar.gz
fake_cert/
fake_cert/ca.crt
fake_cert/ca.key
fake_cert/README.txt
local_host.rule
local.json
redirect.json
server_host.rule
server.json
transport.json
userinfo.dat
visitor/
visitor/sqlite/
visitor/sqlite/visitor.json
visitor/json/
visitor/json/visitor.json
root@ve3961441593185503:~/wcf/releases# nano server.json 
root@ve3961441593185503:~/wcf/releases# cat server.json
{
 "localaddr":[
  {
   "address": "0.0.0.0:8023",
   "protocol": "tcp",
   "timeout": 5,
   "encrypt": "aes-256-cfb",
   "key": "iloveson",
   "redirect": {
    "enable": true,
    "redirector": "http"
   },
   "message_alive": 5
  },
  {
   "address": "0.0.0.0:8020",
   "protocol": "tcp_pad",
   "timeout": 2,
   "encrypt": "blowfish",
   "key": "iloveson",
   "redirect": {
    "enable": true,
    "redirector": "http"
   },
   "message_alive": 0
  },
  {
   "address": "0.0.0.0:8025",
   "protocol": "http_get",
   "timeout": 5,
   "encrypt": "salsa20",
   "key": "iloveson",
   "redirect": {
    "enable": true,
    "redirector": "timeout"
   },
   "message_alive": 0
  }
 ],
 "redirect_config": "redirect.json",
 "userinfo": "userinfo.dat",
 "host": "server_host.rule",
 "transport": "transport.json",
 "report":{
  "enable":true,
  "visitor":"json",
  "visitor_config":"visitor/json/visitor.json"
 }
}
root@ve3961441593185503:~/wcf/releases# ./wcf_server_linux_amd64 -config server.json
不过命令:./wcf_server_linux_amd64 -config server.json是运行在前台的,我们
可以利用systemd把它运行为service:
nano /etc/systemd/system/wcf.service
cat /etc/systemd/system/wcf.service
[Unit]
After=network.target

[Service]
WorkingDirectory=/root/wcf/releases/
ExecStart=/root/wcf/releases/wcf_server_linux_amd64 -config server.json
Restart=always

[Install]
WantedBy=multi-user.target 

然后,
systemctl start wcf
systemctl enable wcf
服务器端搭建完成。

在客户机器mac上。
首先搭建go环境。然后,
git clone https://github.com/xxxsen/wcf --depth=1
cd wcf
chmod 755 get_all_package.sh
chmod 755 build_all.sh
./get_all_package.sh
./build_all.sh
 
yudeMacBook-Air:wcf brite$ ls
LICENSE   build_all.sh  releases
README.md  get_all_package.sh wcf
yudeMacBook-Air:wcf brite$ cd releases
yudeMacBook-Air:releases brite$ ls
wcf_config_2019_11_22_13_03_08.tar.gz wcf_server_2019_11_22_13_03_08.tar.gz
wcf_local_2019_11_22_13_03_08.tar.gz
yudeMacBook-Air:releases brite$ tar xvf wcf_local_2019_11_22_13_03_08.tar.gz
x wcf_local_darwin_386
x wcf_local_darwin_amd64
x wcf_local_linux_386
x wcf_local_linux_amd64
x wcf_local_windows_386.exe
x wcf_local_windows_amd64.exe
yudeMacBook-Air:releases brite$ rm -rf  wcf_local_windows_amd64.exe wcf_local_windows_386.exe wcf_local_linux_amd64  wcf_local_linux_386 wcf_local_darwin_386
yudeMacBook-Air:releases brite$ ls
wcf_config_2019_11_22_13_03_08.tar.gz wcf_local_darwin_amd64
wcf_local_2019_11_22_13_03_08.tar.gz wcf_server_2019_11_22_13_03_08.tar.gz
yudeMacBook-Air:releases brite$ tar xvf wcf_config_2019_11_22_13_03_08.tar.gz 
yudeMacBook-Air:releases brite$ rm -rf wcf_server_2019_11_22_13_03_08.tar.gz

yudeMacBook-Air:releases brite$ ls
fake_cert    transport.json
local.json    userinfo.dat
local_host.rule    visitor
redirect.json    wcf_config_2019_11_22_13_03_08.tar.gz
server.json    wcf_local_2019_11_22_13_03_08.tar.gz
server_host.rule   wcf_local_darwin_amd64
yudeMacBook-Air:releases brite$ nano local.json
yudeMacBook-Air:releases brite$ cat local.json
{
 "localaddr": [
  {"name":"socks", "address":"127.0.0.1:8010"},
  {"name":"http", "address":"127.0.0.1:8011"},
  {"name":"forward", "address":"127.0.0.1:8012", "extra":"127.0.0.1:8000"}
 ],
 "loadbalance":{
  "enable": true,
  "max_errcnt":5,
  "max_failtime":30
 },
 "proxyaddr":[
  {
   "enable": true,
   "addr": "my-vps-ip:8023",
   "weight": 100,
   "protocol": "tcp",
   "user": "test",
   "pwd": "xxx",
   "timeout": 5,
   "encrypt": "aes-256-cfb",
   "key": "iloveson"
  },
  {
   "enable": true,
   "addr": "my-vps-ip:8020",
   "weight": 100,
   "protocol": "tcp_pad",
   "user": "hello",
   "pwd": "world",
   "timeout": 6,
   "encrypt": "blowfish",
   "key": "iloveson"
  },
  {
   "enable": true,
   "addr": "my-vps-ip:8025",
   "weight": 100,
   "protocol": "http_get",
   "user": "test",
   "pwd": "xxx",
   "timeout": 5,
   "encrypt": "salsa20",
   "key": "iloveson"
  }
 ],
 "smart_proxy": false,
 "host":"local_host.rule",
 "transport":"transport.json"
}
yudeMacBook-Air:releases brite$ rm -rf server.json server_host.rule
yudeMacBook-Air:releases brite$ ./wcf_local_darwin_amd64 -config local.json
不要关闭此terminal.

然后设置本地机器的浏览器的socks5代理服务器地址为127.0.0.1 ,端口8010或者
设置本地机器的浏览器的http代理服务器地址为127.0.0.1 ,端口8011 ,浏览器即可翻墙。

项目地址:https://github.com/xxxsen/wcf
 u
相关帖子:https://briteming.blogspot.com/2016/06/sockstunnel.html ,这是该作者的另一个翻墙项目sockstunnel,此项目已被该作者删除,不过在他删除前,我克隆了此项目的代码到本地机器,我把克隆到本地机器的代码上传到了google drive:https://drive.google.com/file/d/1UOtpuqGD55_XOixA56ATV-Wx72sgXuCm/view 

下面的虚线以下的内容是旧版,不用看了。
-------------------

登陆linux vps.
首先搭建go环境。然后,
git clone https://github.com/briteming/wcf wcf-by-briteming
cd wcf-by-briteming
cd wcf


root@umh:~/wcf-by-briteming/wcf# ls
bin  build.bat pkg  src
root@umh:~/wcf-by-briteming/wcf# export GOPATH=`pwd`
(把当前目录设为GOPATH的路径)
root@umh:~/wcf-by-briteming/wcf# echo $GOPATH
/root/wcf-by-briteming/wcf
root@umh:~/wcf-by-briteming/wcf# go get -u -v github.com/golang/protobuf/proto
root@umh:~/wcf-by-briteming/wcf# go get -u -v github.com/pkg/errors
root@umh:~/wcf-by-briteming/wcf# go get -u -v github.com/sirupsen/logrus
root@umh:~/wcf-by-briteming/wcf# cd src/wcf/cmd/server/
root@umh:~/wcf-by-briteming/wcf/src/wcf/cmd/server# go build server.go
(成功生成了可执行文件server)
root@umh:~/wcf-by-briteming/wcf/src/wcf/cmd/server# ls
host.rule server server.go server.json userinfo.dat
root@umh:~/wcf-by-briteming/wcf/src/wcf/cmd/server# nano server.json
root@umh:~/wcf-by-briteming/wcf/src/wcf/cmd/server# cat server.json
{
"localaddr":"0.0.0.0:8020",
"timeout":2,
"userinfo":"/root/wcf-by-briteming/wcf/src/wcf/cmd/server/userinfo.dat",
"encrypt":"xor",
"key":"my-key",
"host":"/root/wcf-by-briteming/wcf/src/wcf/cmd/server/host.rule"
}
root@umh:~/wcf-by-briteming/wcf/src/wcf/cmd/server# ./server -config server.json

不过命令./server -config server.json是运行在前台的,容易退出,我们可以利用systemd把该命令运行为service:
nano /etc/systemd/system/wcf.service
内容为:
[Unit]
After=network.target

[Service]
WorkingDirectory=/root/wcf-by-briteming/wcf/src/wcf/cmd/server
ExecStart=/root/wcf-by-briteming/wcf/src/wcf/cmd/server/server -config server.json
Restart=always

[Install]
WantedBy=multi-user.target

然后运行,
systemctl start wcf
systemctl enable wcf
服务器端搭建完成。

在客户机器mac上。
mkdir wcf-client
cd wcf-client
wget https://github.com/luckypoem/wcf/raw/master/releases/local-releases_2018_10_07_16_48_26.tar.gz
tar zxvf local-releases_2018_10_07_16_48_26.tar.gz
cd wcf
cd src/wcf/cmd/local/
wget https://github.com/luckypoem/wcf/raw/master/wcf/src/wcf/cmd/local/local.json
cp local.json local.json.bak

bogon:local brite$ ls
host.rule local.json.bak
local.json local_darwin_amd64
bogon:local brite$ nano local.json
bogon:local brite$ cat local.json
{
"localaddr": [
{"name":"socks", "address":"127.0.0.1:8010"},
{"name":"http", "address":"127.0.0.1:8011"},
{"name":"forward", "address":"127.0.0.1:8012"}
],
"loadbalance":{
"enable":false,
"max_errcnt":5,
"max_failtime":30
},
"proxyaddr":[
{"addr":"my-vps-ip:8020", "weight":100, "protocol":"tcp"}
],
"user":"test",
"pwd":"xxx",
"timeout":2,
"host":"/Users/xyz/wcf-client/wcf/src/wcf/cmd/local/host.rule",
"encrypt":"xor",
"key":"my-key"
}
bogon:local brite$ nano host.rule
bogon:local brite$ cat host.rule
127.0.0.0/8,direct
baidu.com,block
192.168.0.0/16,direct
10.0.0.0/8,direct
172.0.0.0/8,direct
solidot.org,direct
bogon:local brite$ ./local_darwin_amd64 -config local.json
(不要关闭此terminal窗口)

然后设置本地机器的浏览器的socks5代理服务器地址为127.0.0.1 ,端口8010或者
设置本地机器的浏览器的http代理服务器地址为127.0.0.1 ,端口8011 ,浏览器即可翻墙。

项目地址:
https://github.com/briteming/wcf
https://github.com/luckypoem/wcf
https://github.com/xxxsen/wcf
https://github.com/xxxsen/wcf/issues/1