Total Pageviews

Thursday 5 May 2016

翻墙工具xSocks的安装与使用

使用xSocks的主要步骤如下。
(A)服务端的安装
(1)安装最新版的libtool(xSocks-0.4.4要求libtool的版本为1.4.2或其以上)。到GNU libtool的官网首页查看其最新版的版本号及其下载链地址,最新版为2.4.6,于是安装它:
wget http://ftpmirror.gnu.org/libtool/libtool-2.4.6.tar.gz
tar zxvf libtool-2.4.6.tar.gz
cd libtool-2.4.6
./configure && make && make install
装完后,用 libtool --version 查看版本,确认已是最新的 2.4.6。
注意:不要用apt-get install libtool来安装,因为这样装上的版本太低。

(2)安装autoconf和pkg-config:
apt-get install autoconf pkg-config
(3)下载源码包:
git clone https://github.com/lparam/xSocks
cd xSocks
make    //这一步耗时7-14分钟。
make install
上面make这一步,如果你遇到错误:

error: possibly undefined macro: AC_LIBTOOL_WIN32_DLL
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
autoreconf: /usr/bin/autoconf failed with exit status: 1


解决办法:
“autoreconf: /usr/bin/autoconf failed with exit status: 1”透露了出错的关键所在。
运行apt-cache search autoreconf
在展示的结果中,选择安装dh-autoreconf 。
运行apt-get install dh-autoreconf即可解决问题。再次运行make,不会再出错。


 至此,xSocks就安装完成了。建议在debian8下安装!我在centos7,debian7,ubuntu14.04下,都安装失败。


在make完成后,在xSocks/目录里会生成5个可执行文件:xSocksd,xSocks,xTproxy,xForwarder, xTunnel.
make install的作用就是把这5个可执行文件分别做软链接到/usr/local/bin/下, /usr/local/bin/下将会出现5个文件(其实是快捷方式):xSocksd,xSocks,xTproxy,xForwarder, xTunnel.
我们暂时只需要使用xSocksd.
在服务端运行,使用xSocksd命令,直接执行xSocksd或xSocksd --help(注意大小写),就能输出该命令的使用方法:
root@hostname:~# xSocksd
xSocksd Version: xSocksd/0.4.4 Maintained by lparam
Usage: xSocksd [-l bind] <-k password> [-p pidfile] [-c concurrency] [-t timeout] [-s signal] [-nhvV]

mkdir /var/run/xSocks/
然后运行:
xSocksd -l 0.0.0.0:1073 -k your_password -p /var/run/xSocks/xSocksd.pid

1073可替换为其他未被占用的端口。
服务器端就搭建好了。

 (B)客户端
Windows下的客户端。作者已经提供了编译好的Windows客户端-
https://github.com/lparam/xSocks-windows/releases/download/v1.1.3/Xsocks.exe
在你的windows机器上,需先安装.net framework3.5环境。
Windows下的客户端如下图:
 诶,这个界面是不是和我们所熟悉的某个工具极其相似呢?使用方法和SS的客户端几乎一样,运行该客户端后,设置浏览器的socks5代理为127.0.0.1:1081,即可翻墙。
把鼠标悬停在系统托盘处的XSOCKS图标上,可看到本地的SOCKS5代理的端口号

(2) Linux桌面系统下的客户端
Linux客户端的安装与服务端一样,不同的是,通过xSocks命令来运行。类似地,可以执行xSocks或xSocks --help来查看使用说明.


项目地址:
https://github.com/lparam/xSocks
https://github.com/lparam/xSocks-windows
-------------------------------------------------------------

我用此Xsocks.exe在windows系统下,翻墙成功。不过在mac下,编译 xSocks的客户端失败。

解决办法:

"ld: library not found for -l...." 问题的解决

现象:
在编译工程时,有时会遇到类似“ld: library not found for -l....”的错误提示。
原因:
通常这是由于工程在编译时找不到需要的链接库而导致的。
解决方法:
一般可以通过如下方法解决,在工程的Target中选中要执行编译的某个target,然后“get info”,打开Build设置页面,
在“Library Search Path”中添加缺失链接库的所在文件夹的路径即可。

from http://www.cnblogs.com/zhulin/archive/2011/12/04/2275205.html”

看样子需要在mac上,先安装Xcode才行。
-----------------------------

xSocks

A secure and fast proxy for protect your network traffic

Introdution

  • xSocksd: Backend of xSocks, xTproxy, xForwarder
  • xSocks: A socks5 server
  • xTproxy: A Transparent Proxy
  • xForwarder: Forward data to a specific server
  • xTunnel: Like xForwarder, but standalone and specify target on server side

Features

  • Transparent Proxy for all tcp traffic and udp packet
  • Multithreading
  • Cross-platform, including PC (Linux, Windows), Mobile (Android and Router (OpenWRT,Tomatoware)

BUILD

Linux

make && sudo make install

OpenWRT

# At OpenWRT build root
git clone https://github.com/lparam/xSocks.git package/xSocks
make package/xSocks/openwrt/compile

Windows

# win32
make mingw32 HOST=i686-w64-mingw32
# win64
make mingw32 HOST=x86_64-w64-mingw32

Tomatoware

# Install Tomatoware on your router from: https://github.com/lancethepants/tomatoware
git clone https://github.com/lparam/xSocks.git
make STATIC=1

Usage

Server

xSocksd -k PASSWORD
xTunnel -m server -k PASSWORD -t TARGET:PORT
Multithreading:
xSocksd -k PASSWORD -c THREADS
Stop:
xSocksd --signal stop

Client

xSocks -s SERVER:PORT -k PASSWORD
xForwarder -s SERVER:PORT -k PASSWORD -d DESTINATION:PORT
xTunnel -m client -k PASSWORD -t TARGET:PORT

Transparent Proxy

Proxy all tcp traffic and udp packet transparently on gateway.
root@OpenWrt:~# opkg install iptables-mod-tproxy
root@OpenWrt:~# opkg install xSocks_VER_ARCH.ipk
Modify your SERVER and PASSWORD in /etc/init.d/xSocks
#!/bin/sh /etc/rc.common
# Copyright (C) 2006-2014 OpenWrt.org

START=72
STOP=30
FIREWALL_RELOAD=0

SERVER=IP:PORT
PASSWORD=PASSWORD

LISTEN_PORT=1070
IP_ROUTE_TABLE_NUMBER=100
FWMARK="0x01/0x01"
SETNAME=wall
CHAIN=XSOCKS


start() {
    tproxy_start
    mkdir -p /var/run/xSocks
    xSocks -s $SERVER -k $PASSWORD
    xTproxy -s $SERVER -k $PASSWORD
    xForwarder -l 0.0.0.0:5533 -d 8.8.8.8:53 -s $SERVER -k $PASSWORD
}

stop() {
    tproxy_stop
    xSocks --signal stop
    xTproxy --signal stop
    xForwarder --signal stop
}

shutdown() {
    tproxy_stop
    xSocks --signal quit
    xTproxy --signal quit
    xForwarder --signal quit
}

tproxy_start() {
    iptables -t nat -D PREROUTING -p tcp -j $CHAIN > /dev/null 2>&1
    iptables -t nat -F $CHAIN > /dev/null 2>&1
    iptables -t nat -X $CHAIN > /dev/null 2>&1

    iptables -t mangle -D PREROUTING -j $CHAIN > /dev/null 2>&1
    iptables -t mangle -F $CHAIN > /dev/null 2>&1
    iptables -t mangle -X $CHAIN > /dev/null 2>&1

    iptables -t nat -N $CHAIN
    iptables -t mangle -N $CHAIN

    ipset -N $SETNAME iphash -exist

    ### TCP
    iptables -t nat -A $CHAIN -p tcp -m set --match-set $SETNAME dst -j REDIRECT --to-port $LISTEN_PORT
    iptables -t nat -A PREROUTING -p tcp -j $CHAIN

    ### UDP
    ip rule del fwmark $FWMARK table $IP_ROUTE_TABLE_NUMBER > /dev/null 2>&1
    ip route del local 0.0.0.0/0 dev lo table $IP_ROUTE_TABLE_NUMBER > /dev/null 2>&1

    ip rule add fwmark $FWMARK table $IP_ROUTE_TABLE_NUMBER
    ip route add local 0.0.0.0/0 dev lo table $IP_ROUTE_TABLE_NUMBER

    iptables -t mangle -A $CHAIN -p udp -m set --match-set $SETNAME dst -j TPROXY \
        --on-port $LISTEN_PORT --tproxy-mark $FWMARK
    iptables -t mangle -A PREROUTING -j $CHAIN
}

tproxy_stop() {
    iptables -t nat -D PREROUTING -p tcp -j $CHAIN > /dev/null 2>&1
    iptables -t nat -F $CHAIN > /dev/null 2>&1
    iptables -t nat -X $CHAIN > /dev/null 2>&1

    iptables -t mangle -D PREROUTING -j $CHAIN > /dev/null 2>&1
    iptables -t mangle -F $CHAIN > /dev/null 2>&1
    iptables -t mangle -X $CHAIN > /dev/null 2>&1

    ip rule del fwmark $FWMARK table $IP_ROUTE_TABLE_NUMBER > /dev/null 2>&1
    ip route del local 0.0.0.0/0 dev lo table $IP_ROUTE_TABLE_NUMBER > /dev/null 2>&1
}
root@OpenWrt:~# /etc/init.d/xSocks start
root@OpenWrt:~# ipset add SETNAME IP
 
from https://github.com/lparam/xSocks 
----------------
 
安卓下的客户端程序:
https://github.com/lparam/xSocks-android/releases/download/v1.5.0/xSocks-v1.5.0.apk
xSocks-v1.5.0.apk